Applet micro-channel pay points

Recent marketing department should be required, on the applet plus micro-channel pay points. Micro-channel pay points so far still in beta stage, but has already begun trial. Documentation as follows:

https://pay.weixin.qq.com/wiki/doc/apiv3/payscore.php?chapter=15_6&index=4

Because it is in closed beta stage, so there will certainly be needed to jump pit.

In order to provide confirmation document there are two methods, one is wx.openBusinessView , you do not need to jump to the program in small micro-payment channel, a direct use of wx.navigateToMiniProgram jump to the program in small micro-channel payment. The contrast of these two advantages is certainly the first matter, right, jump and do not need accounting applet places, after jumping to another small program has only 10 places ah.

 My preference is to use wx.openBusinessView this function, simply press the function written documentation of what success do and fail to do anything. Everything looks ok, at least if you pay attention for the first time need to pay points to open when it is perfect.

This function in any ios user the first time opened to the success can enter without any problems , Android users for the first time opened intact. Return time and did not enter any of the callback function which includes complete, the beginning because limited whitelist test quota reasons, and not too much to pay attention to this issue, direct hair edition.

Our business logic is if the free bet is to jump to the successful use of the page. But after we made version, problems arise immediately.

The first question: Andrews user actually first time has opened a successful loan charge-free items, click on micro-channel pay but because there is no return after entering the sub-page wx.openBusinessView any pullback, with the result that there is no rent to the user, again once rented. Caused by multi-user multi-payment.

The second problem: many users because of lack of micro-channel pay points, or because the micro-channel built-in risk control, resulting in many users can not open payment points. And when we do not have to pay the entrance remain common, resulting in many users want to rent items not rent items, resulting in the loss of user traffic!

Can not pay points to open part of the user page is shown below:

In the event of such a situation we immediately withdrew version, go back to the old version with the old process. Points immediately modify the payment module. After the letter with the official micro-communication technology, micro-channel official response is, first with wx.navigateToMiniProgram , try this jump.

That official have spoken, and have testified that function is really a problem, after all, the problem is 100% reproducible. So you can only listen to the words of the official friends.

Then again roll up its sleeves and work.

wx.navigateToMiniProgram this function only bad is the need to go inside to app.js onshow to get a callback, but do not know when the user is returned clicked to confirm or click on the upper left corner of the return or the return button. So then we should go backstage to see in the end the order is confirmed or not confirmed.

I said the following about the process of implementation:

1, first define a variable app.js inside userTouch , for monitoring partial payment is not returned from the micro-channel. If the value of 1.

App({
  onLaunch: function () {
    // 展示本地存储能力
  },
    onShow: function(res) {
        // 展示本地存储能力
        console.log("我进入了app.js的onshow")
        if (res.scene === 1038) { // 场景值1038:从被打开的小程序返回
            console.log("我进入了返回商家小程序")
            this.globalData.userTouch =1;
        }
    },
  globalData: {
    userTouch:0,//押金按钮显示问题

  }
})

In order to prevent users because pay enough points, can not pay, so do the background information if the request is to get an order is canceled, you need to pay a deposit button will be displayed.

So I paid a deposit onshow pages inside to request backstage to see whether the user has confirmed the order, the code below:

onShow: function () {
        console.log('我进入了onshow里面')
        console.log("获取全局变量"+app.globalData.userTouch)

        if (app.globalData.userTouch == 1) {
            console.log("我进入了取消订单")
            let object = this.data.object;
            let params = {};
            util.HttpRequst(true, 'cabinets', 2, { "cmd": "query_payscore_order", "order_id": object.order_id }, "POST", true, (res) => {//这是我自己封装的请求,你们按自己的写即可
                console.log(res)
                if (res.errcode == 0) {
                    app.globalData.userTouch = 0;
                    if (res.order_state == 'CREATED') {//证明订单没有创建完成,此时是需要取消订单的
                        util.HttpRequst(true, 'cabinets', 2, { "cmd": "cancel_payscore_deposit","order_id": object.order_id }, "POST", true, (res) => {
                            console.log(res)
                            if (res.errcode == 0) {
                                wx.showModal({
                                    title: '提示',
                                    content: "您取消了操作,支付失败!",
                                    confirmText: "确定",
                                    showCancel: false,//不显示取消
                                    success: (res) => {
                                        if (res.confirm) {
                                            //如果取消,将原来的支付按钮显示出来
                                            this.setData({ is_no_free: 1, type: 0 }) 
                                        }
                                    }
                                })
                            } 
                        })
                    } else if (res.order_state == 'USER_ACCEPTED') {
                      //如果订单是创建成功的话,就去到使用中界面,object是我自己传的参数
                        wx.redirectTo({
                            url: '../in_used/in_used?object=' + JSON.stringify(object) + "&log=1",
                        })
                    } else {
                        //如果其他情况,将原来的支付按钮显示出来
                        this.setData({ is_no_free: 1, type: 0}) 
                    }
                } else {
                    this.setData({ is_no_free: 1, type: 0 }) 
                    util.tipError(util.errCode[res.errcode])
                }
            })
        }  
    },

In the beginning of the default display only free bet paid as follows:

If at the time of payment in small jumps to program the user clicks on the return or cancel the operation, the page appears as follows:

This ensures that the user can not be opened in time to pay points can also use ordinary payment processes.

 

最后,一定要去后台拿真实的订单状态。后台的订单状态是跟微信要的所以肯定是准确的,只有这样判断才是最准确的。记得将userTouch改回原来的值。

笔记就做到这里了,等微信修改好了wx.openBusinessView函数我再更新这篇文章,毕竟不喜欢小程序占名额,哈哈!

Guess you like

Origin blog.csdn.net/qq_34672907/article/details/94745439