微信和支付宝JSAPI支付页面 html

欢迎大家进群,一起探讨学习

欢迎大家进群,一起讨论学习

微信公众号,每天给大家提供技术干货

在这里插入图片描述

博主技术笔记 https://notes.xiyankt.com


博主开源微服架构前后端分离技术博客项目源码地址,欢迎各位star https://gitee.com/bright-boy/xiyan-blog


<!doctype  html>
<html>
   <head>
      <head>
    <title>微信和支付宝JSAPI支付页面demo</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8">
</head>
<body>
    </br></br></br></br>
    <div align="center">    
        正在支付,请等待....
    </div>
    <script type="text/javascript" src="http://static.solaridc.com/jquery/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        callpay();
        //调用微信JS api 支付
        function jsApiCall()
        {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                {
                "appId":"wx50207d2390936e26",
                "timeStamp":"1427160790332",
                "signType":"MD5",
                "package":"prepay_id=wx2015032409435699f3c23fd30370937173",
                "nonceStr":"0d6HuxczrznWuXb8",
                "paySign":"D61AE52D8167C42B341A9290E88EE7AA"
                },
                function(res){
                    //WeixinJSBridge.log(res.err_msg);
                    //alert(res.err_code+res.err_desc+res.err_msg);
                    if(res.err_msg == "get_brand_wcpay_request:ok" ) {
                     alert('支付成功!');
                    }
                }
            );
        }


        function callpay()
        {
            if (typeof WeixinJSBridge == "undefined"){
                if( document.addEventListener ){
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }else if (document.attachEvent){
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }else{
                jsApiCall();
            }
        }

        // 支付宝网页版调起支付
        function alipay(data, fun) {
            AlipayJSBridge.call("tradePay", {
                tradeNO : data.tradeNo
            }, function(result) {
                fun(result);
            });
        }

    alipay(data, function(result) {
        if (result.resultCode == "9000") {
          alert('支付成功!');
        } else {
          alert('支付失败!');
        }
    });
    </script>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刘明同学呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值