微信小程序免密支付解绑(微信小程序免密代扣)

1.定义好pay.wxml,确定绑定小程序的app-id,接下来我们就来聊聊关于微信小程序免密支付解绑?以下内容大家不妨参考一二希望能帮到您!

微信小程序免密支付解绑(微信小程序免密代扣)

微信小程序免密支付解绑

1.定义好pay.wxml,确定绑定小程序的app-id

<view class='btn_box'> <navigator target='miniProgram' extra-data='{{extraData}}' path='pages/index/index' app-id='wxbd687630cd02ce1d' hover-class="none"> <view class='btn_btn nor_linear_bg'>开通免密支付</view> </navigator> </view>

2.设置好pay.js参数处理

var util = require('../../utils/util.js'); const app = getApp(); Page({ onShow: function (options) { console.log(options,'pay.js start'); }, data:{ extraData:'', localCity:'' }, onLoad: function() { this.setData({ extraData:util.getextraData(), localCity:wx.getStorageSync(util.key.cityName) || app.globalData.baseInfo.cityName }) } })

绑定免密签证参数设置:

function getextraData() { const app = getApp(); var extraDataValue = { appid: app.globalData.baseInfo.appId, mch_id: app.globalData.baseInfo.mchId, sub_mch_id: app.globalData.baseInfo.subMchId, notify_url: app.globalData.baseInfo.notifyUrl, contract_code: config.contractCode, contract_display_account: app.globalData.baseInfo.contractDisplayAccount, plan_id: app.globalData.baseInfo.planId, request_serial: config.requestSerial, timestamp: config.timestamp, sub_appid: app.globalData.baseInfo.subAppId }; var extraDataSortValue = getSort(extraDataValue); var signValue = getSign(extraDataSortValue, app.globalData.baseInfo.appSecret); extraDataValue['sign'] = signValue; log(TAG, "signSign=[" signValue "]length=" String(signValue).length); return extraDataValue; }

3.app.js中 处理绑定后返回值

onShow: function (options) { let that = this; var bindStatus = wx.getStorageSync(util.key.bindStatus) || 0; if (options.scene == 1038) { var errorCode = options.referrerInfo && options.referrerInfo.extraData && options.referrerInfo.extraData.return_code ? options.referrerInfo.extraData.return_code:''; if (errorCode == 'SUCCESS') { var appid = options.referrerInfo.appId; var contractId = options.referrerInfo.extraData.contract_id; console.log("签约成功"); that.globalData.baseInfo.appid = appid; that.globalData.baseInfo.contractId = contractId; that.globalData.baseInfo.contractIds = contractId; that.globalData.baseInfo.bindStatus = 1; wx.setStorageSync(util.key.bindStatus, 1); //add by wupeng for jump scan //认证绑定后通过navigateBack跳转到首页scan可以直接退出 var pagelist = getCurrentPages(); var len = pagelist.length; var init = 0; var index = 0; for (var i = 0; i < len; i ) { if (pagelist[i].route.indexOf("scan/scan") >= 0) {//看路由里面是否有首页 init = 1; index = i; } } if (init == 1) { wx.navigateBack({ delta: len - index - 1 }); } else { wx.reLaunch({ url: "../scan/scan"//这个是默认的单页 }); } //end add by wupeng } else { var msg = options.referrerInfo.extraData.return_msg; wx.showModal({ title: errorCode, content: msg, }); console.log(TAG ':签约失败'); } } // } },

注意主小程序与微信免密小程序跳转存在参数认证问题。

多次绑定和解绑定可能会被微信平台判断拉黑导致再次免密失败。

,

免责声明:本文仅代表文章作者的个人观点,与本站无关。其原创性、真实性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容文字的真实性、完整性和原创性本站不作任何保证或承诺,请读者仅作参考,并自行核实相关内容。文章投诉邮箱:anhduc.ph@yahoo.com

    分享
    投诉
    首页