商户通过调用订单详情接口打开微信支付分小程序,引导用户查看订单详情(App端)
1. 接口说明
接口名称:WXOpenBusinessView(Android、iOS)、OpenBusinessView(鸿蒙)
鸿蒙 openSDK下载地址(版本>=1.0.5):鸿蒙资源下载
2. 接口兼容
3. 接口参数
Android对应对象:WXOpenBusinessView.Req
iOS对应对象:WXOpenBusinessViewReq
鸿蒙应用对象:OpenBusinessViewReq
Object WXOpenBusinessView.Req & Object WXOpenBusinessViewReq & Object OpenBusinessViewReq
|
跳转类型 | businessType | string[1, 16] | 是 | 固定配置:wxpayScoreDetail 示例值:wxpayScoreDetail |
业务参数 | query | string[1, 2048] | 是 | 使用URL的query string方式传递参数,格式为key=value&key2=value2,其中value,value2需要进行UrlEncode处理,详细说明见下文。 |
 | 业务参数 | | |
服务商商户号 | mch_id | string[1,32] | 是 | 服务商的商户号,由微信支付生成并下发 示例值:1230000109 | 服务ID | service_id | string[1,32] | 是 | 服务ID 示例值:88888888000011 | 商户业务订单号 | out_order_no | string[1,32] | 是 | 商户内部的业务订单号,要求32个字符内,只能是数字、大小写字母_-|* 且在同一个商户号下唯一。 示例值:1234323JKHDFE1243252 | 时间戳 | timestamp | string[1,32] | 是 | 生成签名时间戳,单位秒。 示例值:1530097563 | 随机字符串 | nonce_str | string[1,32] | 是 | 生成签名随机串。由数字、大小写字母组成,长度不超过32位。 示例值:zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2 | 签名方式 | sign_type | string[1,32] | 是 | 签名类型,仅支持HMAC-SHA256。 示例值:HMAC-SHA256 | 签名 | sign | string[1,32] | 是 | 使用字段mch_id、service_id、out_order_no、timestamp、nonce_str、sign_type按照 签名生成算法计算得出的签名值。 示例值:029B52F67573D7E3BE74904BF9AEA |
|
|
其他配置 | extInfo | string[1,128] | 否 | 自定义ext信息,json格式,如需指定小程序版本,可填 {"miniProgramType": type}。 type取值: 0:正式版; 1:开发版; 2:体验版 示例值:{"miniProgramType": 0} |
4. query示例

1mch_id=1230000109&service_id=88888888000011&out_order_no=1234323JKHDFE1243252×tamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA
5. 返回参数
无返回数据(HTTP状态码为204)
6. 返回示例

1204 No Content
2
3无返回数据
7. 示例代码

1WXOpenBusinessViewReq *req = [WXOpenBusinessViewReq object];
2req.businessType = @"wxpayScoreDetail";
3req.query = @"mch_id=1230000109&service_id=88888888000011&out_order_no=1234323JKHDFE1243252×tamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA";
4req.extInfo = @"{\"miniProgramType\":0}";
5[WXApi sendReq:req]

1int wxSdkVersion = api.getWXAppSupportAPI();
2if (wxSdkVersion >= Build.OPEN_BUSINESS_VIEW_SDK_INT) {
3 WXOpenBusinessView.Req req = new WXOpenBusinessView.Req();
4 req.businessType = "wxpayScoreDetail";
5 req.query = "mch_id=1230000109&service_id=88888888000011&out_order_no=1234323JKHDFE1243252&
6 timestamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA";
7 req.extInfo = "{"miniProgramType": 0}";
8 boolean ret = api.sendReq(req);
9} else {
10
11}
12
13@Override
14public void onResp(BaseResp r) {
15if (r.getType() == ConstantsAPI.COMMAND_OPEN_BUSINESS_VIEW) {
16WXOpenBusinessView.Resp launchMiniProgramResp = (WXOpenBusinessView.Resp) r;
17String text = String.format("openid=%s\nextMsg=%s\nerrStr=%s\nbusinessType=%s",
18resp.openId, resp.extMsg, resp.errStr, resp.businessType);
19Toast.makeText(this, text, Toast.LENGTH_LONG).show();
20 }
21}

1import * as wxopensdk from '@tencent/wechat_open_sdk';
2
3export const WXApi = wxopensdk.WXAPIFactory.createWXAPI(APP_ID);
4
5
6async sendWxPayScoreDetail() {
7 let req = new wxopensdk.OpenBusinessViewReq
8 req.businessType = "wxpayScoreDetail";
9 req.query = "mch_id=1230000109&service_id=88888888000011&out_order_no=1234323JKHDFE1243252×tamp=1530097563&nonce_str=zyx53Nkey8o4bHpxTQvd8m7e92nG5mG2&sign_type=HMAC-SHA256&sign=029B52F67573D7E3BE74904BF9AEA";
10 req.extInfo = "{miniProgramType:0}";
11 let finished = await WXApi.sendReq(getContext(this) as common.UIAbilityContext, req);
12}
13
14
15
16onResp(resp: wxopensdk.BaseResp): void {
17if (resp instanceof wxopensdk.OpenBusinessViewResp) {
18if ("wxpayScoreDetail" === resp.businessType) {
19
20 }
21 }
22}