查询支付分订单
更新时间:2024.12.06当商户创建支付分订单成功后,可以通过该接口查询订单状态,可具体可参考支付分订单状态流转图。
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/payscore/partner/serviceorder
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
query 查询参数
service_id 选填 string(32)
【服务ID】 商户支付分服务的唯一标识,由32位数字组成。支付分产品权限审核通过后,微信支付运营会向商户提供该ID。
sub_mchid 必填 string(32)
【子商户号】服务商下的子商户商户号,普通服务商使用特约商户进件生成,平台收付通服务商使用二级商户进件生成。
out_order_no 选填 string(32)
【商户服务订单号】 商户系统内部服务订单号,要求32个字符内,只能是数字、大小写字母_-|* 且在同一个商户号下唯一。需要开发者特别注意,该参数不可用于申请退款接口中的 out_trade_no 参数。
query_id 选填 string(512)
【查单ID】 商户调起支付分小程序确认订单页后,用户回到商户前端时会返回query_id参数。调用支付分查单接口时out_order_no字段和query_id字段必填一个(不允许都填写或都不填写)。
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/payscore/partner/serviceorder?service_id=2002000000000558128851361561536&sub_mchid=1900000109&out_order_no=1234323JKHDFE1243252&query_id=15646546545165651651 \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 查询订单 24 */ 25public class GetPartnerServiceOrder { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/payscore/partner/serviceorder"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 GetPartnerServiceOrder client = new GetPartnerServiceOrder( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 GetPartnerServiceOrderRequest request = new GetPartnerServiceOrderRequest(); 41 request.serviceId = "2002000000000558128851361561536"; 42 request.subMchid = "1900000109"; 43 request.outOrderNo = "1234323JKHDFE1243252"; 44 request.queryId = "15646546545165651651"; 45 try { 46 ServiceOrderEntity response = client.run(request); 47 // TODO: 请求成功,继续业务逻辑 48 System.out.println(response); 49 } catch (WXPayUtility.ApiException e) { 50 // TODO: 请求失败,根据状态码执行不同的逻辑 51 e.printStackTrace(); 52 } 53 } 54 55 public ServiceOrderEntity run(GetPartnerServiceOrderRequest request) { 56 String uri = PATH; 57 Map<String, Object> args = new HashMap<>(); 58 args.put("service_id", request.serviceId); 59 args.put("sub_mchid", request.subMchid); 60 args.put("out_order_no", request.outOrderNo); 61 args.put("query_id", request.queryId); 62 String queryString = WXPayUtility.urlEncode(args); 63 if (!queryString.isEmpty()) { 64 uri = uri + "?" + queryString; 65 } 66 67 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 68 reqBuilder.addHeader("Accept", "application/json"); 69 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 70 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 71 reqBuilder.method(METHOD, null); 72 Request httpRequest = reqBuilder.build(); 73 74 // 发送HTTP请求 75 OkHttpClient client = new OkHttpClient.Builder().build(); 76 try (Response httpResponse = client.newCall(httpRequest).execute()) { 77 String respBody = WXPayUtility.extractBody(httpResponse); 78 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 79 // 2XX 成功,验证应答签名 80 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 81 httpResponse.headers(), respBody); 82 83 // 从HTTP应答报文构建返回数据 84 return WXPayUtility.fromJson(respBody, ServiceOrderEntity.class); 85 } else { 86 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 87 } 88 } catch (IOException e) { 89 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 90 } 91 } 92 93 private final String mchid; 94 private final String certificateSerialNo; 95 private final PrivateKey privateKey; 96 private final String wechatPayPublicKeyId; 97 private final PublicKey wechatPayPublicKey; 98 99 public GetPartnerServiceOrder(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 100 this.mchid = mchid; 101 this.certificateSerialNo = certificateSerialNo; 102 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 103 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 104 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 105 } 106 107 public static class GetPartnerServiceOrderRequest { 108 @SerializedName("service_id") 109 @Expose(serialize = false) 110 public String serviceId; 111 112 @SerializedName("sub_mchid") 113 @Expose(serialize = false) 114 public String subMchid; 115 116 @SerializedName("out_order_no") 117 @Expose(serialize = false) 118 public String outOrderNo; 119 120 @SerializedName("query_id") 121 @Expose(serialize = false) 122 public String queryId; 123 } 124 125 public static class ServiceOrderEntity { 126 @SerializedName("out_order_no") 127 public String outOrderNo; 128 129 @SerializedName("service_id") 130 public String serviceId; 131 132 @SerializedName("appid") 133 public String appid; 134 135 @SerializedName("mchid") 136 public String mchid; 137 138 @SerializedName("sub_appid") 139 public String subAppid; 140 141 @SerializedName("sub_mchid") 142 public String subMchid; 143 144 @SerializedName("service_introduction") 145 public String serviceIntroduction; 146 147 @SerializedName("state") 148 public String state; 149 150 @SerializedName("state_description") 151 public String stateDescription; 152 153 @SerializedName("post_payments") 154 public List<Payment> postPayments; 155 156 @SerializedName("post_discounts") 157 public List<ServiceOrderCoupon> postDiscounts; 158 159 @SerializedName("risk_fund") 160 public RiskFund riskFund; 161 162 @SerializedName("total_amount") 163 public Long totalAmount; 164 165 @SerializedName("need_collection") 166 public Boolean needCollection; 167 168 @SerializedName("collection") 169 public Collection collection; 170 171 @SerializedName("time_range") 172 public TimeRange timeRange; 173 174 @SerializedName("location") 175 public Location location; 176 177 @SerializedName("attach") 178 public String attach; 179 180 @SerializedName("notify_url") 181 public String notifyUrl; 182 183 @SerializedName("sub_openid") 184 public String subOpenid; 185 186 @SerializedName("order_id") 187 public String orderId; 188 } 189 190 public static class Payment { 191 @SerializedName("name") 192 public String name; 193 194 @SerializedName("amount") 195 public Long amount; 196 197 @SerializedName("description") 198 public String description; 199 200 @SerializedName("count") 201 public Long count; 202 } 203 204 public static class ServiceOrderCoupon { 205 @SerializedName("name") 206 public String name; 207 208 @SerializedName("description") 209 public String description; 210 211 @SerializedName("amount") 212 public Long amount; 213 } 214 215 public static class RiskFund { 216 @SerializedName("name") 217 public String name; 218 219 @SerializedName("amount") 220 public Long amount; 221 222 @SerializedName("description") 223 public String description; 224 } 225 226 public static class Collection { 227 @SerializedName("state") 228 public String state; 229 230 @SerializedName("total_amount") 231 public Long totalAmount; 232 233 @SerializedName("paying_amount") 234 public Long payingAmount; 235 236 @SerializedName("paid_amount") 237 public Long paidAmount; 238 239 @SerializedName("details") 240 public List<Detail> details; 241 } 242 243 public static class TimeRange { 244 @SerializedName("start_time") 245 public String startTime; 246 247 @SerializedName("end_time") 248 public String endTime; 249 250 @SerializedName("start_time_remark") 251 public String startTimeRemark; 252 253 @SerializedName("end_time_remark") 254 public String endTimeRemark; 255 } 256 257 public static class Location { 258 @SerializedName("start_location") 259 public String startLocation; 260 261 @SerializedName("end_location") 262 public String endLocation; 263 } 264 265 public static class Detail { 266 @SerializedName("seq") 267 public Long seq; 268 269 @SerializedName("amount") 270 public Long amount; 271 272 @SerializedName("paid_type") 273 public String paidType; 274 275 @SerializedName("paid_time") 276 public String paidTime; 277 278 @SerializedName("transaction_id") 279 public String transactionId; 280 } 281 282} 283
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9) 10 11func main() { 12 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 13 config, err := wxpay_utility.CreateMchConfig( 14 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 16 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 17 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 18 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 19 ) 20 if err != nil { 21 fmt.Println(err) 22 return 23 } 24 25 request := &GetPartnerServiceOrderRequest{ 26 ServiceId: wxpay_utility.String("2002000000000558128851361561536"), 27 SubMchid: wxpay_utility.String("1900000109"), 28 OutOrderNo: wxpay_utility.String("1234323JKHDFE1243252"), 29 QueryId: wxpay_utility.String("15646546545165651651"), 30 } 31 32 response, err := GetPartnerServiceOrder(config, request) 33 if err != nil { 34 fmt.Printf("请求失败: %+v\n", err) 35 // TODO: 请求失败,根据状态码执行不同的处理 36 return 37 } 38 39 // TODO: 请求成功,继续业务逻辑 40 fmt.Printf("请求成功: %+v\n", response) 41} 42 43func GetPartnerServiceOrder(config *wxpay_utility.MchConfig, request *GetPartnerServiceOrderRequest) (response *ServiceOrderEntity, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/payscore/partner/serviceorder" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 query := reqUrl.Query() 55 if request.ServiceId != nil { 56 query.Add("service_id", *request.ServiceId) 57 } 58 if request.SubMchid != nil { 59 query.Add("sub_mchid", *request.SubMchid) 60 } 61 if request.OutOrderNo != nil { 62 query.Add("out_order_no", *request.OutOrderNo) 63 } 64 if request.QueryId != nil { 65 query.Add("query_id", *request.QueryId) 66 } 67 reqUrl.RawQuery = query.Encode() 68 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 69 if err != nil { 70 return nil, err 71 } 72 httpRequest.Header.Set("Accept", "application/json") 73 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 74 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 75 if err != nil { 76 return nil, err 77 } 78 httpRequest.Header.Set("Authorization", authorization) 79 80 client := &http.Client{} 81 httpResponse, err := client.Do(httpRequest) 82 if err != nil { 83 return nil, err 84 } 85 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 86 if err != nil { 87 return nil, err 88 } 89 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 90 // 2XX 成功,验证应答签名 91 err = wxpay_utility.ValidateResponse( 92 config.WechatPayPublicKeyId(), 93 config.WechatPayPublicKey(), 94 &httpResponse.Header, 95 respBody, 96 ) 97 if err != nil { 98 return nil, err 99 } 100 response := &ServiceOrderEntity{} 101 if err := json.Unmarshal(respBody, response); err != nil { 102 return nil, err 103 } 104 105 return response, nil 106 } else { 107 return nil, wxpay_utility.NewApiException( 108 httpResponse.StatusCode, 109 httpResponse.Header, 110 respBody, 111 ) 112 } 113} 114 115type GetPartnerServiceOrderRequest struct { 116 ServiceId *string `json:"service_id,omitempty"` 117 SubMchid *string `json:"sub_mchid,omitempty"` 118 OutOrderNo *string `json:"out_order_no,omitempty"` 119 QueryId *string `json:"query_id,omitempty"` 120} 121 122func (o *GetPartnerServiceOrderRequest) MarshalJSON() ([]byte, error) { 123 type Alias GetPartnerServiceOrderRequest 124 a := &struct { 125 ServiceId *string `json:"service_id,omitempty"` 126 SubMchid *string `json:"sub_mchid,omitempty"` 127 OutOrderNo *string `json:"out_order_no,omitempty"` 128 QueryId *string `json:"query_id,omitempty"` 129 *Alias 130 }{ 131 // 序列化时移除非 Body 字段 132 ServiceId: nil, 133 SubMchid: nil, 134 OutOrderNo: nil, 135 QueryId: nil, 136 Alias: (*Alias)(o), 137 } 138 return json.Marshal(a) 139} 140 141type ServiceOrderEntity struct { 142 OutOrderNo *string `json:"out_order_no,omitempty"` 143 ServiceId *string `json:"service_id,omitempty"` 144 Appid *string `json:"appid,omitempty"` 145 Mchid *string `json:"mchid,omitempty"` 146 SubAppid *string `json:"sub_appid,omitempty"` 147 SubMchid *string `json:"sub_mchid,omitempty"` 148 ServiceIntroduction *string `json:"service_introduction,omitempty"` 149 State *string `json:"state,omitempty"` 150 StateDescription *string `json:"state_description,omitempty"` 151 PostPayments []Payment `json:"post_payments,omitempty"` 152 PostDiscounts []ServiceOrderCoupon `json:"post_discounts,omitempty"` 153 RiskFund *RiskFund `json:"risk_fund,omitempty"` 154 TotalAmount *int64 `json:"total_amount,omitempty"` 155 NeedCollection *bool `json:"need_collection,omitempty"` 156 Collection *Collection `json:"collection,omitempty"` 157 TimeRange *TimeRange `json:"time_range,omitempty"` 158 Location *Location `json:"location,omitempty"` 159 Attach *string `json:"attach,omitempty"` 160 NotifyUrl *string `json:"notify_url,omitempty"` 161 SubOpenid *string `json:"sub_openid,omitempty"` 162 OrderId *string `json:"order_id,omitempty"` 163} 164 165type Payment struct { 166 Name *string `json:"name,omitempty"` 167 Amount *int64 `json:"amount,omitempty"` 168 Description *string `json:"description,omitempty"` 169 Count *int64 `json:"count,omitempty"` 170} 171 172type ServiceOrderCoupon struct { 173 Name *string `json:"name,omitempty"` 174 Description *string `json:"description,omitempty"` 175 Amount *int64 `json:"amount,omitempty"` 176} 177 178type RiskFund struct { 179 Name *string `json:"name,omitempty"` 180 Amount *int64 `json:"amount,omitempty"` 181 Description *string `json:"description,omitempty"` 182} 183 184type Collection struct { 185 State *string `json:"state,omitempty"` 186 TotalAmount *int64 `json:"total_amount,omitempty"` 187 PayingAmount *int64 `json:"paying_amount,omitempty"` 188 PaidAmount *int64 `json:"paid_amount,omitempty"` 189 Details []Detail `json:"details,omitempty"` 190} 191 192type TimeRange struct { 193 StartTime *string `json:"start_time,omitempty"` 194 EndTime *string `json:"end_time,omitempty"` 195 StartTimeRemark *string `json:"start_time_remark,omitempty"` 196 EndTimeRemark *string `json:"end_time_remark,omitempty"` 197} 198 199type Location struct { 200 StartLocation *string `json:"start_location,omitempty"` 201 EndLocation *string `json:"end_location,omitempty"` 202} 203 204type Detail struct { 205 Seq *int64 `json:"seq,omitempty"` 206 Amount *int64 `json:"amount,omitempty"` 207 PaidType *string `json:"paid_type,omitempty"` 208 PaidTime *string `json:"paid_time,omitempty"` 209 TransactionId *string `json:"transaction_id,omitempty"` 210} 211
应答参数
200 OK
out_order_no 必填 string(32)
【商户服务订单号】 商户系统内部服务订单号,要求32个字符内,只能是数字、大小写字母_-|* 且在同一个商户号下唯一。需要开发者特别注意,该参数不可用于申请退款接口中的 out_trade_no 参数。
service_id 必填 string(32)
【服务ID】 商户支付分服务的唯一标识,由32位数字组成。支付分产品权限审核通过后,微信支付运营会向商户提供该ID。
appid 必填 string(32)
【公众账号ID】公众账号ID也称APPID,是(微信开放平台、微信公众平台)为开发者提供的一个唯一标识,用于识别开发者的应用程序(APP、小程序、公众号)。 开发者需要先在微信开放平台或微信公众平台中申请ID,然后在服务商平台中绑定,详见服务商商户号与AppID账号关联管理。完结订单和取消订单需要和创单传入的appid保持一致。
mchid 必填 string(32)
【服务商商户号】 调用支付分创单接口提交的服务商商户号,商户号需开通支付分产品权限,且与appid有绑定关系,详见服务商商户号与AppID账号关联管理。
sub_appid 选填 string(32)
【子商户公众账号ID】 公众账号ID也称APPID,是(微信开放平台、微信公众平台)为开发者提供的一个唯一标识,用于识别开发者的应用程序(APP、小程序、公众号)。需要登录服务商平台操作绑定,具体参考服务商为特约商户配置AppID(即sub_appid)操作方法。
sub_mchid 选填 string(32)
【子商户号】服务商下的子商户商户号,普通服务商使用特约商户进件生成,平台收付通服务商使用二级商户进件生成。
service_introduction 必填 string(20)
【服务信息】 用于介绍本订单所提供的服务 ,长度不能超过20个字符(汉字、数字、字母、特殊符号都按照1个字符计算)。
state 必填 string(32)
【服务订单状态】 表示支付分订单状态CREATED
:商户已创建服务订单DOING
:服务订单进行中DONE
:服务订单完成(终态)REVOKED
:商户取消服务订单(终态)EXPIRED
:服务订单已失效,"商户已创建服务订单"状态超过30天未变动,则订单失效(终态)
该状态需结合collection.state字段和state_description字段一起判断,具体可参考支付分订单状态流转图。
state_description 选填 string(32)
【订单状态说明】此参数用于对服务订单处于DOING状态时的附加说明,非DOIING状态将不会返回该参数。具体状态如下:USER_CONFIRM
:用户已确认状态,表示用户成功确认订单后所处状态。MCH_COMPLETE
:商户已完结状态,指商户调用完结接口成功后至扣款成功前的状态。
该状态需结合collection.state字段和state字段一起判断,具体可参考支付分订单状态流转图。
post_payments 选填 array[object]
【后付费项目】 用于展示订单后付费项目明细,商户需要按照所属行业规程传参,详见post_payments(后付费项目)字段传参说明。
属性 | |
name 选填 string(20) 【付费名称】 不能超过20个字符,需严格按照post_payments(后付费项目)字段传参说明传参。 amount 选填 integer 【付费金额】 付费项目金额,整型,大于等于0(等于0时表示不需要扣费),单位为分,需严格按照post_payments(后付费项目)字段传参说明传参。 description 选填 string(30) 【付费说明】 对付费项目的详细说明,不超过30个字符,需严格按照post_payments(后付费项目)字段传参说明传参。 count 选填 integer 【付费数量】 后付费项目的数量,为整型。相同的后付费项目建议合并计算amount和count。 |
post_discounts 选填 array[object]
【商户优惠】 用于展示订单优惠项目明细,最多30条,完结订单时传的收款总金额需满足计算条件(收款总金额=后付费项目amount和-优惠项目amount和)
属性 | |
name 选填 string(20) 【优惠名称】 用于描述优惠项目,不超过20个字符,同一单多个优惠项目名称不可重复。 description 选填 string(30) 【优惠说明】 用于描述优惠项目使用条件,不超过30个字符。 amount 选填 integer 【优惠金额】 整型,单位为分,用于描述优惠项目金额。 count 选填 integer 【优惠数量】 整型,用于描述优惠项目使用数量,例如用户使用了两张同一活动优惠券,则count填2。 |
risk_fund 选填 object
【服务风险金】 本笔订单的风险金额描述
属性 | |
name 必填 string(30) 【风险名称】 (1)、在先免模式下:只能传以下枚举值: (2)、先享模式:只能传“ 详细说明参考产品介绍-先免模式和先享模式。 amount 必填 integer 【风险金额】 这笔订单的风险金额,风险金额大小会影响评估,理论上金额越高评估通过率越低,商户按照实际场景传入即可,评估不通过是正常风控拦截。 description 选填 string(30) 【风险说明】 用于描述说明该风险金,不能超过30字符。 |
total_amount 选填 integer
【总金额】
订单最终收款总金额,整型,单位为分,商户调用完结订单接口和修改订单金额接口传入,受服务ID风险金额上限影响,服务ID风险金额上限具体请与BD确认。
先免模式:total_amount<=创单risk_fund.amount(押金金额)<=服务ID风险金额上限。
先享模式:total_amount<=服务ID风险金额上限。
需满足计算条件:total_amount = 后付费项目金额(post_payments.amount总和) - 优惠项目金额(post_discounts.amount总和),例如商户后付费项目金额总和为10元,优惠项目金额总和为2元,则订单收款总金额为8元。
need_collection 选填 boolean
【是否需要收款】 订单是否需要收款,固定返回true需收款。
collection 选填 object
【收款信息】 订单收款信息,仅在调用完结支付分订单后返回(若完结订单 total_amount 等于 0 元,则不返回此字段)。
属性 | |||||||||||||
state 必填 string(32) 【收款状态】
total_amount 选填 integer 【总收款金额】 订单最终收款总金额,整型,单位为分,商户调用完结订单接口和修改订单金额接口传入,受服务ID风险金额上限影响,服务ID风险金额上限具体请与BD确认。 paying_amount 选填 integer 【待收金额】 用户待支付金额,完结成功后收款成功前,等于订单收款总金额total_amount。收款成功后为0。 paid_amount 选填 integer 【已收金额】 用户已支付金额,完结成功后收款成功前为0,收款成功后等于订单收款总金额total_amount。 details 选填 array[object] 【收款明细列表】 收款明细列表
|
time_range 选填 object
【服务时间】 用于描述订单的服务开始和结束时间。
属性 | |
start_time 选填 string(14) 【服务开始时间】 1、商户提供服务的开始时间。例如,用户今天下单,商户明天提供服务,这里的时间指的是明天。 end_time 选填 string(14) 【服务结束时间】 1、商户提供服务的结束时间。例如,商户明天提供服务,3天后结束服务,这里的时间指的是3天后的时间。 start_time_remark 选填 string(20) 【服务开始时间备注】 当有传入服务开始时间时,可添加备注说明,不超过20个字符。 end_time_remark 选填 string(20) 【服务结束时间备注】 当有传入服务结束时间时,可添加备注说明,不超过20个字符。 |
location 选填 object
【服务位置】 用于描述用户使用服务的地理位置
属性 | |
start_location 选填 string(20) 【服务开始地点】 用户开始使用服务的地点,不超过20个字符。 end_location 选填 string(20) 【服务结束地点】用户结束使用服务的地点,不超过20个字符。 |
attach 选填 string(256)
【商户数据包】 商户在创建订单时传入的自定义数据包,用户不可见。用于存放订单的商户自定义数据,需要先进行urlencode编码,总长度不超过256字符。确认订单回调通知和支付成功回调通知时会回传该字段给商户。
notify_url 选填 string(256)
【商户回调地址】 商户接收确认订单回调通知和支付成功回调通知的地址,创单时传入,需按照notify-url填写注意事项规范填写。
openid 选填 string(128)
【用户标识】用户在服务商appid下的唯一标识(不传sub_appid的情况下返回)。
sub_openid 选填 string(128)
【用户标识】用户在子商户sub_appid下的唯一标识(传了sub_appid的情况下返回)。
order_id 选填 string(64)
【微信支付服务订单号】 支付分订单在微信侧的唯一标识,31位数字,开头由1000000000+年月日组成。
应答示例
200 OK
1{ 2 "out_order_no" : "1234323JKHDFE1243252", 3 "service_id" : "2002000000000558128851361561536", 4 "appid" : "wxd678efh567hg6787", 5 "mchid" : "1230000109", 6 "sub_appid" : "wxd678efh567hg6999", 7 "sub_mchid" : "1900000109", 8 "service_introduction" : "XX充电宝", 9 "state" : "CREATED", 10 "state_description" : "MCH_COMPLETE", 11 "post_payments" : [ 12 { 13 "name" : "就餐费用", 14 "amount" : 40000, 15 "description" : "就餐人均100元", 16 "count" : 4 17 } 18 ], 19 "post_discounts" : [ 20 { 21 "name" : "满20减1元", 22 "description" : "不与其他优惠叠加", 23 "amount" : 100 24 } 25 ], 26 "risk_fund" : { 27 "name" : "DEPOSIT", 28 "amount" : 10000, 29 "description" : "就餐的预估费用" 30 }, 31 "total_amount" : 40000, 32 "need_collection" : true, 33 "collection" : { 34 "state" : "USER_PAID", 35 "total_amount" : 50000, 36 "paying_amount" : 40000, 37 "paid_amount" : 10000, 38 "details" : [ 39 { 40 "seq" : 1, 41 "amount" : 10000, 42 "paid_type" : "NEWTON", 43 "paid_time" : "20091225091210", 44 "transaction_id" : "15646546545165651651" 45 } 46 ] 47 }, 48 "time_range" : { 49 "start_time" : "20091225091010", 50 "end_time" : "20091225121010", 51 "start_time_remark" : "备注1", 52 "end_time_remark" : "备注2" 53 }, 54 "location" : { 55 "start_location" : "嗨客时尚主题展餐厅", 56 "end_location" : "嗨客时尚主题展餐厅" 57 }, 58 "attach" : "Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald", 59 "notify_url" : "https://api.test.com", 60 "sub_openid" : "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o", 61 "order_id" : "0000300001201908301055157220022" 62} 63
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | INVALID_ORDER_STATE | 单据状态错误 | 确认操作是否符合流程 |
400 | INVALID_REQUEST | 请求参数符合参数格式,但不符合业务规则 | 请确认相同单号是否使用了不同的参数 |
400 | ORDER_CANCELED | 单据已取消 | 当前状态无需操作 |
400 | ORDER_DONE | 订单已完成 | 当前状态无需操作 |
403 | NO_AUTH | 商户信息不合法 | 登录服务商平台核对,传入正确信息 |
404 | ORDER_NOT_ EXIST | 订单不存在 | 确认入参,传入正确单据 |
429 | FREQUENCY_LIMITED | 频率超限 | 请求量不要超过接口调用频率限制 |
500 | SYSTEM_ERROR | 系统错误 | 5开头的状态码都为系统问题,请使用相同参数稍后重新调用 |