微信小程序-支付接口

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ChibiMarukoChan/article/details/84968167

调用wx.requestPayment(OBJECT)发起微信支付

Object参数说明:

参数 类型 必填 说明
timeStamp String 时间戳从1970年1月1日00:00:00至今的秒数,即当前的时间
nonceStr String 随机字符串,长度为32个字符以下。
package String 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*
signType String 签名类型,默认为MD5,支持HMAC-SHA256和MD5。注意此处需与统一下单的签名类型一致
paySign String 签名,具体签名方案参见微信公众号支付帮助文档;
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)
  api.groupPlayOrder(token,data,function(res){
           //data字段包括:订单号、支付金额;后台返回需要填写的支付参数
           wx.requestPayment({
             timeStamp: res.data.timeStamp,
             nonceStr: res.data.nonceStr,
             package: res.data.package,
             signType: res.data.signType,
             paySign: res.data.paySign,
             success:function(res){
               console.log(res)
               wx.showToast({
                 title: '支付成功',
                 icon: 'success',
                 duration: 2000
               });
             },
             fail:function(error){
               console.log(error)
             },
             complete:function(){

             }
           })
      })

猜你喜欢

转载自blog.csdn.net/ChibiMarukoChan/article/details/84968167