Loading…

WeChat official account payment

The h5 webpage opened within WeChat initiates payment through this interface. ![](https://dcdn.it120.cc/yuque/0/2026/png/572726/1775698972163-68d802aa-cd79-4fc4-99e3-33ea253f3225.png) You need to configure the payment directory before you can initiate payment ```javascript WXAPI.wxpayJsapi({ code: '', token: '000', money: 0.01, remark: 'Preferential payment: 0.01', payName: 'Preferential payment' }) ``` + code is a temporary credential returned by WeChat webpage authorization. If the currently logged in user has bound the service account openid, this parameter does not need to be passed, otherwise it must be passed. + token login credentials + money payment amount + payName The purchase name displayed on the payment interface + remark remark information will be recorded in the remark field in the background payment record. It does not need to be passed. + nextAction After the payment is successful, the next operation that needs to be performed does not need to be passed. + shopId the payment store ID, optional ["Detailed explanation of nextAction parameter usage"](https://www.yuque.com/apifm/doc/aetmlb) Return example: ```json { "code": 0, "data": { "timeStamp": "1639303298714", "outTradeId": "ZF2112120443589175", "appid": "wxb3218336ce0c0966", "sign": "A405790D534A73BFE26B59503BF67328", "signType": "MD5", "prepayId": "wx12180138641891714e4f187581b25d0000", "nonceStr": "avXDO8rLjUQNwLFlvhsrhQbdGNmVsY" }, "msg": "success" } ``` After receiving the interface return, use `WeixinJSBridge`Just call to initiate paymentTo use WeixinJSBridge, please refer to the following article: ["v-shop open source project supports WeChat login + WeChat payment"](https://www.yuque.com/apifm/doc/xnsegn) You can also use WeChat’s official js-sdk to initiate payment: ["Official JS-SDK Description"](https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html#58)