商戶使用微信支付提供的JS調(diào)起微信支付分小程序,引導(dǎo)用戶查看訂單(公眾號端)
# 接口說明
支持商戶: 【普通商戶】
接口名稱: openBusinessView
提示
在JSAPI調(diào)起支付分相關(guān)接口前,需詳細(xì)閱讀JS-SDK說明文檔并進(jìn)行相應(yīng)配置
JS-SDK配置為鏈接: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html (opens new window)
此接口引用 JSAPI版本1.5.0,引用地址:https://res.wx.qq.com/open/js/jweixin-1.5.0.js (opens new window)
要求用戶微信版本>=7.0.5
# 字段說明
# 接口參數(shù)
- businessType 必填 string(16)固定配置:wxpayScoreDetail。
- queryString 必填 string(2048)使用URL的query string方式傳遞參數(shù),格式為key=value&key2=value2,其中value,value2需要進(jìn)行UrlEncode處理。
- 屬性
請求示例
1let wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);2let wechatVersion = wechatInfo[1];3?4if (compareVersion(wechatVersion, '7.0.5') >= 0) {5 goToWXScore();6} else {7 // 提示用戶升級微信客戶端版本8 window.href = 'https://support.weixin.qq.com/cgi-bin/readtemplate?t=page/common_page__upgrade&9 text=text005&btn_text=btn_text_0'10}11?12/**13 * 跳轉(zhuǎn)微信支付分14 */15function goToWXScore() {16 wx.checkJsApi({17 jsApiList: ['openBusinessView'], // 需要檢測的JS接口列表18 success: function (res) {19 // 以鍵值對的形式返回,可用的api值true,不可用為false20 // 如:{"checkResult":{"openBusinessView":true},"errMsg":"checkJsApi:ok"}21 if (res.checkResult.openBusinessView) {22 wx.invoke(23 'openBusinessView', {24 businessType: 'wxpayScoreDetail',25 queryString26:'mch_id=1230000109&service_id=88888888000011&out_order_no=1234323JKHDFE1243252×tamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA'27 },28 29 function (res) {30 // 從支付分返回時會執(zhí)行這個回調(diào)函數(shù)31 if (parseint(res.err_code) === 0) {32 // 返回成功 33 } else {34 // 返回失敗35 }36 });37 }38 }39 });40 }41?42 /**43 * 版本號比較44 * @param {string45} v1 46 * @param {string47} v2 48 */49function compareVersion(v1, v2) {50 v1 = v1.split('.')51 v2 = v2.split('.')52 const len = Math.max(v1.length, v2.length)53 54 while (v1.length < len) {55 v1.push('0')56 }57 while (v2.length < len) {58 v2.push('0')59 }60 61 for (let i = 0; i < len; i++) {62 const num1 = parseint(v1[i])63 const num2 = parseint(v2[i])64 65 if (num1 > num2) {66 return 167 } else if (num1 < num2) {68 return -169 }70 }71 72 return 073 }
# 返回參數(shù)
無