zoukankan      html  css  js  c++  java
  • 微信小程序支付

    微信小程序支付

    微信小程序支付开发流程

    一:小程序支付步骤:

    1、预支付:

    小程序页面将预支付的数据传递到商户后台,代码举例:

    wx.request({
          url: 'https://yourwebsit/service/getPay', // 商户的后台接口
          method: 'POST',
          data: {
            total_fee: total_fee,   /*订单金额*/
            openid: app.globalData._openid
          },
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {
            wx.requestPayment({
              'timeStamp': timeStamp,
              'nonceStr': nonceStr,
              'package': 'prepay_id=' + res.data.prepay_id,
              'signType': 'MD5',
              'paySign': res.data._paySignjs,
              'success': function (res) {
                console.log(res);
              },
              'fail': function (res) {
                console.log('fail:' + JSON.stringify(res));
              }
            })
          },
          fail: function (err) {
            console.log(err)
          }
        })
    

    微信小程序支付开发流程

      

    2、后台根据预支付数据+签名对小程序的支付接口发起请求,成功后会获取的需要的paySign和package。  官方接口文档

    3、后台返回数据,小程序调用微信支付

    wx.requestPayment({
              'timeStamp': timeStamp,
              'nonceStr': nonceStr,
              'package': 'prepay_id=' + res.data.prepay_id,
              'signType': 'MD5',
              'paySign': res.data._paySignjs,
              'success': function (res) {
                console.log(res);
              },
              'fail': function (res) {
                console.log('fail:' + JSON.stringify(res));
              }
    })
    

    微信小程序支付开发流程

  • 相关阅读:
    微信小程序HTTPS
    微信商城-1简介
    va_list
    Event log c++ sample.
    EVENT LOGGING
    Analyze Program Runtime Stack
    unknow table alarmtemp error when drop database (mysql)
    This application has request the Runtime to terminate it in an unusual way.
    How to check if Visual Studio 2005 SP1 is installed
    SetUnhandledExceptionFilter
  • 原文地址:https://www.cnblogs.com/momozjm/p/8509224.html
Copyright © 2011-2022 走看看