评论

小程序支付代码示例

支付接口调试,方便测试直接调用。

小程序支付代码示例

onPayTest() {


    var data = {
      "nonceStr""23",
      "timeStamp""1528098190",
      "signType""MD5",
      "paySign""ED55C8",
      "package""0492238"
    }
    wx.requestPayment({
      'timeStamp': data.timeStamp,
      'nonceStr': data.nonceStr,
      'package'"prepay_id=" + data.package,
      'signType': data.signType,
      'paySign': data.paySign,
      'success'function (res{
        console.log("发起支付 res=>", res);
if (res.errMsg.indexOf("ok") != -1) {
            wx.showModal({
              title'',
              content"已完成支付",
              showCancelfalse,
              successfunction (res{
                
              }
            });
          } else {
            wx.showModal({
              title'',
              content: res.errMsg + "",
              showCancelfalse,
              successfunction (res{
              
              }
            });
          }

      },
      'fail'function (err{
        console.log("发起支付 err=>", err);
  if (err && err.errMsg == "requestPayment:fail cancel") {
            
          //取消支付
          } else {
           
          }

      }
    })
}

参考文档:

1、https://pay.weixin.qq.com/static/applyment_guide/applyment_detail_miniapp.shtml

2、https://developers.weixin.qq.com/miniprogram/dev/api/payment/wx.requestPayment.html


最后一次编辑于  星期二 17:08  
点赞 0
收藏
评论
登录 后发表内容