商戶通過調(diào)用訂單詳情接口打開微信支付分小程序,引導(dǎo)用戶查看訂單詳情(Web端)
在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)
# 接口說明
支持商戶: 【普通商戶】
接口名稱: openBusinessView
# 接口兼容
此接口引用 JSAPI版本1.5.0,引用地址:https://res.wx.qq.com/open/js/jweixin-1.5.0.js (opens new window)
要求用戶微信版本>=7.0.5
# 接口參數(shù)
# Object
- businessType 必填 string(16)固定配置:wxpayScoreDetail。
- queryString 必填 string(2048)使用URL的query string。方式傳遞參數(shù),格式為key=value&key2=value2,其中value,value2需要進(jìn)行UrlEncode處理。
- 屬性
請(qǐng)求示例
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 // 提示用戶升級(jí)微信客戶端版本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'], // 需要檢測(cè)的JS接口列表18 success: function (res) {19 // 以鍵值對(duì)的形式返回,可用的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&27 timestamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&28 sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA'29 },30 31 function (res) {32 // 從支付分返回時(shí)會(huì)執(zhí)行這個(gè)回調(diào)函數(shù)33 if (parseint(res.err_code) === 0) {34 // 返回成功 35 } else {36 // 返回失敗37 }38 });39 }40 }41 });42 }43?44 /**45 * 版本號(hào)比較46 * @param {string47} v1 48 * @param {string49} v2 50 */51function compareVersion(v1, v2) {52 v1 = v1.split('.')53 v2 = v2.split('.')54 const len = Math.max(v1.length, v2.length)55 56 while (v1.length < len) {57 v1.push('0')58 }59 while (v2.length < len) {60 v2.push('0')61 }62 63 for (let i = 0; i < len; i++) {64 const num1 = parseint(v1[i])65 const num2 = parseint(v2[i])66 67 if (num1 > num2) {68 return 169 } else if (num1 < num2) {70 return -171 }72 }73 74 return 075 }