修改订单金额
更新时间:2025.03.06订单collection.state为USER_PAYING待支付状态时,商户可调用该接口下调收款金额。
注:
1.先免模式,用户确认订单评估不通过时交了押金/预付款/保证金来使用服务的情况,不支持修改金额。
2.待支付状态的订单,若用户正在通过支付分订单页拉起收银台主动支付或者支付分正在进行自动扣款时,调用修改支付分订单金额API可能会出现"单据正在扣款中,请稍后再试"的报错,可等待3min后重试。
3.已支付的订单,不支持修改订单金额,商户只能通过退款接口将差价退回用户。
接口说明
支持商户:【普通商户】
请求方式:【POST】/v3/payscore/serviceorder/{out_order_no}/modify
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Content-Type 必填 string
请设置为application/json
path 路径参数
out_order_no 必填 string(32)
【商户服务订单号】商户系统内部服务订单号,商户在创建支付分接口中填入的out_order_no参数。
body 包体参数
appid 必填 string(32)
【公众账号ID】是微信开放平台和微信公众平台为开发者的应用程序(APP、小程序、公众号)提供的一个唯一标识。 开发者需要先在微信开放平台或微信公众平台中申请ID,然后在商户平台中绑定,详见直连商户与AppID账号关联管理。完结订单和取消订单需要和创单传入的appid保持一致。
service_id 必填 string(32)
【服务ID】商户支付分服务的唯一标识,由32位数字组成。支付分产品权限审核通过后,微信支付运营会向商户提供该ID。
post_payments 必填 array[Payment]
【后付费项目】用于展示订单后付费项目明细,商户需要按照所属行业规程传参,详见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[ServiceOrderCoupon]
【后付费商户优惠】用于展示订单优惠项目明细,最多30条,完结订单时传的收款总金额需满足计算条件(收款总金额=后付费项目amount和-优惠项目amount和)
属性 | |
name 选填 string(20) 【优惠名称】用于描述优惠项目,不超过20个字符,同一单多个优惠项目名称不可重复。 description 选填 string(30) 【优惠说明】用于描述优惠项目使用条件,不超过30个字符。 amount 选填 integer 【优惠金额】优惠项目金额 count 选填 integer 【优惠数量】整型,用于描述优惠项目使用数量,例如用户使用了两张同一活动优惠券,则count填2。 |
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元。
reason 必填 string(50)
【修改原因】支付分修改订单原因,长度不能超过50个字符。
device 选填 object
【设备信息】
属性 | |
start_device_id 选填 string(50) 【服务开始的设备ID】 某一设备在商户对应服务ID下的唯一标识,由商户自行填写,建议采用设备SN值。售货机、充电宝、充电桩等无人自助设备行业必传。 end_device_id 选填 string(50) 【服务结束的设备ID】 某一设备在商户对应服务ID下的唯一标识,由商户自行填写,建议采用设备SN值。售货机、充电宝、充电桩等无人自助设备行业必传。 materiel_no 选填 string(100) 【物料编码】 若商家参与政策,则商家填写行业侧给到商家的物料码(字母+数字的形式);若商家未参与政策,则商家填写URL链接。 |
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/payscore/serviceorder/1234323JKHDFE1243252/modify \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "appid" : "wxd678efh567hg6787", 8 "service_id" : "2002000000000558128851361561536", 9 "post_payments" : [ 10 { 11 "name" : "就餐费用", 12 "amount" : 40000, 13 "description" : "就餐人均100元", 14 "count" : 4 15 } 16 ], 17 "post_discounts" : [ 18 { 19 "name" : "满20减1元", 20 "description" : "不与其他优惠叠加", 21 "amount" : 100, 22 "count" : 2 23 } 24 ], 25 "total_amount" : 50000, 26 "reason" : "用户投诉", 27 "device" : { 28 "start_device_id" : "HG123456", 29 "end_device_id" : "HG123456", 30 "materiel_no" : "example_materiel_no" 31 } 32 }' 33
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831 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 ModifyServiceOrder { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/payscore/serviceorder/{out_order_no}/modify"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 32 ModifyServiceOrder client = new ModifyServiceOrder( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 ModifyServiceOrderRequest request = new ModifyServiceOrderRequest(); 41 request.outOrderNo = "1234323JKHDFE1243252"; 42 request.appid = "wxd678efh567hg6787"; 43 request.serviceId = "2002000000000558128851361561536"; 44 request.postPayments = new ArrayList<>(); 45 { 46 Payment postPaymentsItem = new Payment(); 47 postPaymentsItem.name = "就餐费用"; 48 postPaymentsItem.amount = 40000L; 49 postPaymentsItem.description = "就餐人均100元"; 50 postPaymentsItem.count = 4L; 51 request.postPayments.add(postPaymentsItem); 52 }; 53 request.postDiscounts = new ArrayList<>(); 54 { 55 ServiceOrderCoupon postDiscountsItem = new ServiceOrderCoupon(); 56 postDiscountsItem.name = "满20减1元"; 57 postDiscountsItem.description = "不与其他优惠叠加"; 58 postDiscountsItem.amount = 100L; 59 postDiscountsItem.count = 2L; 60 request.postDiscounts.add(postDiscountsItem); 61 }; 62 request.totalAmount = 50000L; 63 request.reason = "用户投诉"; 64 request.device = new Device(); 65 request.device.startDeviceId = "HG123456"; 66 request.device.endDeviceId = "HG123456"; 67 request.device.materielNo = "example_materiel_no"; 68 try { 69 ServiceOrderEntity response = client.run(request); 70 // TODO: 请求成功,继续业务逻辑 71 System.out.println(response); 72 } catch (WXPayUtility.ApiException e) { 73 // TODO: 请求失败,根据状态码执行不同的逻辑 74 e.printStackTrace(); 75 } 76 } 77 78 public ServiceOrderEntity run(ModifyServiceOrderRequest request) { 79 String uri = PATH; 80 uri = uri.replace("{out_order_no}", WXPayUtility.urlEncode(request.outOrderNo)); 81 String reqBody = WXPayUtility.toJson(request); 82 83 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 84 reqBuilder.addHeader("Accept", "application/json"); 85 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 86 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 87 reqBuilder.addHeader("Content-Type", "application/json"); 88 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 89 reqBuilder.method(METHOD, requestBody); 90 Request httpRequest = reqBuilder.build(); 91 92 // 发送HTTP请求 93 OkHttpClient client = new OkHttpClient.Builder().build(); 94 try (Response httpResponse = client.newCall(httpRequest).execute()) { 95 String respBody = WXPayUtility.extractBody(httpResponse); 96 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 97 // 2XX 成功,验证应答签名 98 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 99 httpResponse.headers(), respBody); 100 101 // 从HTTP应答报文构建返回数据 102 return WXPayUtility.fromJson(respBody, ServiceOrderEntity.class); 103 } else { 104 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 105 } 106 } catch (IOException e) { 107 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 108 } 109 } 110 111 private final String mchid; 112 private final String certificateSerialNo; 113 private final PrivateKey privateKey; 114 private final String wechatPayPublicKeyId; 115 private final PublicKey wechatPayPublicKey; 116 117 public ModifyServiceOrder(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 118 this.mchid = mchid; 119 this.certificateSerialNo = certificateSerialNo; 120 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 121 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 122 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 123 } 124 125 public static class ModifyServiceOrderRequest { 126 @SerializedName("out_order_no") 127 @Expose(serialize = false) 128 public String outOrderNo; 129 130 @SerializedName("appid") 131 public String appid; 132 133 @SerializedName("service_id") 134 public String serviceId; 135 136 @SerializedName("post_payments") 137 public List<Payment> postPayments = new ArrayList<Payment>(); 138 139 @SerializedName("post_discounts") 140 public List<ServiceOrderCoupon> postDiscounts; 141 142 @SerializedName("total_amount") 143 public Long totalAmount; 144 145 @SerializedName("reason") 146 public String reason; 147 148 @SerializedName("device") 149 public Device device; 150 } 151 152 public static class ServiceOrderEntity { 153 @SerializedName("out_order_no") 154 public String outOrderNo; 155 156 @SerializedName("service_id") 157 public String serviceId; 158 159 @SerializedName("appid") 160 public String appid; 161 162 @SerializedName("mchid") 163 public String mchid; 164 165 @SerializedName("service_introduction") 166 public String serviceIntroduction; 167 168 @SerializedName("state") 169 public String state; 170 171 @SerializedName("state_description") 172 public String stateDescription; 173 174 @SerializedName("post_payments") 175 public Payment postPayments; 176 177 @SerializedName("post_discounts") 178 public List<ServiceOrderCoupon> postDiscounts; 179 180 @SerializedName("risk_fund") 181 public RiskFund riskFund; 182 183 @SerializedName("total_amount") 184 public Long totalAmount; 185 186 @SerializedName("need_collection") 187 public Boolean needCollection; 188 189 @SerializedName("collection") 190 public Collection collection; 191 192 @SerializedName("time_range") 193 public TimeRange timeRange; 194 195 @SerializedName("location") 196 public Location location; 197 198 @SerializedName("attach") 199 public String attach; 200 201 @SerializedName("notify_url") 202 public String notifyUrl; 203 204 @SerializedName("openid") 205 public String openid; 206 207 @SerializedName("order_id") 208 public String orderId; 209 } 210 211 public static class Payment { 212 @SerializedName("name") 213 public String name; 214 215 @SerializedName("amount") 216 public Long amount; 217 218 @SerializedName("description") 219 public String description; 220 221 @SerializedName("count") 222 public Long count; 223 } 224 225 public static class ServiceOrderCoupon { 226 @SerializedName("name") 227 public String name; 228 229 @SerializedName("description") 230 public String description; 231 232 @SerializedName("amount") 233 public Long amount; 234 235 @SerializedName("count") 236 public Long count; 237 } 238 239 public static class Device { 240 @SerializedName("start_device_id") 241 public String startDeviceId; 242 243 @SerializedName("end_device_id") 244 public String endDeviceId; 245 246 @SerializedName("materiel_no") 247 public String materielNo; 248 } 249 250 public static class RiskFund { 251 @SerializedName("name") 252 public String name; 253 254 @SerializedName("amount") 255 public Long amount; 256 257 @SerializedName("description") 258 public String description; 259 } 260 261 public static class Collection { 262 @SerializedName("state") 263 public String state; 264 265 @SerializedName("total_amount") 266 public Long totalAmount; 267 268 @SerializedName("paying_amount") 269 public Long payingAmount; 270 271 @SerializedName("paid_amount") 272 public Long paidAmount; 273 274 @SerializedName("details") 275 public List<Detail> details; 276 } 277 278 public static class TimeRange { 279 @SerializedName("start_time") 280 public String startTime; 281 282 @SerializedName("end_time") 283 public String endTime; 284 285 @SerializedName("start_time_remark") 286 public String startTimeRemark; 287 288 @SerializedName("end_time_remark") 289 public String endTimeRemark; 290 } 291 292 public static class Location { 293 @SerializedName("start_location") 294 public String startLocation; 295 296 @SerializedName("end_location") 297 public String endLocation; 298 } 299 300 public static class Detail { 301 @SerializedName("seq") 302 public Long seq; 303 304 @SerializedName("amount") 305 public Long amount; 306 307 @SerializedName("paid_type") 308 public String paidType; 309 310 @SerializedName("paid_time") 311 public String paidTime; 312 313 @SerializedName("transaction_id") 314 public String transactionId; 315 } 316 317} 318
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/merchant/4015119334 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10 "strings" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &ModifyServiceOrderRequest{ 28 OutOrderNo: wxpay_utility.String("1234323JKHDFE1243252"), 29 Appid: wxpay_utility.String("wxd678efh567hg6787"), 30 ServiceId: wxpay_utility.String("2002000000000558128851361561536"), 31 PostPayments: []Payment{Payment{ 32 Name: wxpay_utility.String("就餐费用"), 33 Amount: wxpay_utility.Int64(40000), 34 Description: wxpay_utility.String("就餐人均100元"), 35 Count: wxpay_utility.Int64(4), 36 }}, 37 PostDiscounts: []ServiceOrderCoupon{ServiceOrderCoupon{ 38 Name: wxpay_utility.String("满20减1元"), 39 Description: wxpay_utility.String("不与其他优惠叠加"), 40 Amount: wxpay_utility.Int64(100), 41 Count: wxpay_utility.Int64(2), 42 }}, 43 TotalAmount: wxpay_utility.Int64(50000), 44 Reason: wxpay_utility.String("用户投诉"), 45 Device: &Device{ 46 StartDeviceId: wxpay_utility.String("HG123456"), 47 EndDeviceId: wxpay_utility.String("HG123456"), 48 MaterielNo: wxpay_utility.String("example_materiel_no"), 49 }, 50 } 51 52 response, err := ModifyServiceOrder(config, request) 53 if err != nil { 54 fmt.Printf("请求失败: %+v\n", err) 55 // TODO: 请求失败,根据状态码执行不同的处理 56 return 57 } 58 59 // TODO: 请求成功,继续业务逻辑 60 fmt.Printf("请求成功: %+v\n", response) 61} 62 63func ModifyServiceOrder(config *wxpay_utility.MchConfig, request *ModifyServiceOrderRequest) (response *ServiceOrderEntity, err error) { 64 const ( 65 host = "https://api.mch.weixin.qq.com" 66 method = "POST" 67 path = "/v3/payscore/serviceorder/{out_order_no}/modify" 68 ) 69 70 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 71 if err != nil { 72 return nil, err 73 } 74 reqUrl.Path = strings.Replace(reqUrl.Path, "{out_order_no}", url.PathEscape(*request.OutOrderNo), -1) 75 reqBody, err := json.Marshal(request) 76 if err != nil { 77 return nil, err 78 } 79 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 80 if err != nil { 81 return nil, err 82 } 83 httpRequest.Header.Set("Accept", "application/json") 84 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 85 httpRequest.Header.Set("Content-Type", "application/json") 86 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 87 if err != nil { 88 return nil, err 89 } 90 httpRequest.Header.Set("Authorization", authorization) 91 92 client := &http.Client{} 93 httpResponse, err := client.Do(httpRequest) 94 if err != nil { 95 return nil, err 96 } 97 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 98 if err != nil { 99 return nil, err 100 } 101 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 102 // 2XX 成功,验证应答签名 103 err = wxpay_utility.ValidateResponse( 104 config.WechatPayPublicKeyId(), 105 config.WechatPayPublicKey(), 106 &httpResponse.Header, 107 respBody, 108 ) 109 if err != nil { 110 return nil, err 111 } 112 response := &ServiceOrderEntity{} 113 if err := json.Unmarshal(respBody, response); err != nil { 114 return nil, err 115 } 116 117 return response, nil 118 } else { 119 return nil, wxpay_utility.NewApiException( 120 httpResponse.StatusCode, 121 httpResponse.Header, 122 respBody, 123 ) 124 } 125} 126 127type ModifyServiceOrderRequest struct { 128 OutOrderNo *string `json:"out_order_no,omitempty"` 129 Appid *string `json:"appid,omitempty"` 130 ServiceId *string `json:"service_id,omitempty"` 131 PostPayments []Payment `json:"post_payments,omitempty"` 132 PostDiscounts []ServiceOrderCoupon `json:"post_discounts,omitempty"` 133 TotalAmount *int64 `json:"total_amount,omitempty"` 134 Reason *string `json:"reason,omitempty"` 135 Device *Device `json:"device,omitempty"` 136} 137 138func (o *ModifyServiceOrderRequest) MarshalJSON() ([]byte, error) { 139 type Alias ModifyServiceOrderRequest 140 a := &struct { 141 OutOrderNo *string `json:"out_order_no,omitempty"` 142 *Alias 143 }{ 144 // 序列化时移除非 Body 字段 145 OutOrderNo: nil, 146 Alias: (*Alias)(o), 147 } 148 return json.Marshal(a) 149} 150 151type ServiceOrderEntity struct { 152 OutOrderNo *string `json:"out_order_no,omitempty"` 153 ServiceId *string `json:"service_id,omitempty"` 154 Appid *string `json:"appid,omitempty"` 155 Mchid *string `json:"mchid,omitempty"` 156 ServiceIntroduction *string `json:"service_introduction,omitempty"` 157 State *string `json:"state,omitempty"` 158 StateDescription *string `json:"state_description,omitempty"` 159 PostPayments *Payment `json:"post_payments,omitempty"` 160 PostDiscounts []ServiceOrderCoupon `json:"post_discounts,omitempty"` 161 RiskFund *RiskFund `json:"risk_fund,omitempty"` 162 TotalAmount *int64 `json:"total_amount,omitempty"` 163 NeedCollection *bool `json:"need_collection,omitempty"` 164 Collection *Collection `json:"collection,omitempty"` 165 TimeRange *TimeRange `json:"time_range,omitempty"` 166 Location *Location `json:"location,omitempty"` 167 Attach *string `json:"attach,omitempty"` 168 NotifyUrl *string `json:"notify_url,omitempty"` 169 Openid *string `json:"openid,omitempty"` 170 OrderId *string `json:"order_id,omitempty"` 171} 172 173type Payment struct { 174 Name *string `json:"name,omitempty"` 175 Amount *int64 `json:"amount,omitempty"` 176 Description *string `json:"description,omitempty"` 177 Count *int64 `json:"count,omitempty"` 178} 179 180type ServiceOrderCoupon struct { 181 Name *string `json:"name,omitempty"` 182 Description *string `json:"description,omitempty"` 183 Amount *int64 `json:"amount,omitempty"` 184 Count *int64 `json:"count,omitempty"` 185} 186 187type Device struct { 188 StartDeviceId *string `json:"start_device_id,omitempty"` 189 EndDeviceId *string `json:"end_device_id,omitempty"` 190 MaterielNo *string `json:"materiel_no,omitempty"` 191} 192 193type RiskFund struct { 194 Name *string `json:"name,omitempty"` 195 Amount *int64 `json:"amount,omitempty"` 196 Description *string `json:"description,omitempty"` 197} 198 199type Collection struct { 200 State *string `json:"state,omitempty"` 201 TotalAmount *int64 `json:"total_amount,omitempty"` 202 PayingAmount *int64 `json:"paying_amount,omitempty"` 203 PaidAmount *int64 `json:"paid_amount,omitempty"` 204 Details []Detail `json:"details,omitempty"` 205} 206 207type TimeRange struct { 208 StartTime *string `json:"start_time,omitempty"` 209 EndTime *string `json:"end_time,omitempty"` 210 StartTimeRemark *string `json:"start_time_remark,omitempty"` 211 EndTimeRemark *string `json:"end_time_remark,omitempty"` 212} 213 214type Location struct { 215 StartLocation *string `json:"start_location,omitempty"` 216 EndLocation *string `json:"end_location,omitempty"` 217} 218 219type Detail struct { 220 Seq *int64 `json:"seq,omitempty"` 221 Amount *int64 `json:"amount,omitempty"` 222 PaidType *string `json:"paid_type,omitempty"` 223 PaidTime *string `json:"paid_time,omitempty"` 224 TransactionId *string `json:"transaction_id,omitempty"` 225} 226
应答参数
|
out_order_no 必填 string(32)
【商户服务订单号】商户系统内部服务订单号,商户在创建支付分接口中填入的out_order_no参数。
service_id 必填 string(32)
【服务ID】商户支付分服务的唯一标识,由32位数字组成。支付分产品权限审核通过后,微信支付运营会向商户提供该ID。
appid 必填 string(32)
【公众账号ID】是微信开放平台和微信公众平台为开发者的应用程序(APP、小程序、公众号)提供的一个唯一标识。 开发者需要先在微信开放平台或微信公众平台中申请ID,然后在商户平台中绑定,详见直连商户与AppID账号关联管理。完结订单和取消订单需要和创单传入的appid保持一致。
mchid 必填 string(32)
【商户号】调用支付分创单接口提交的商户号,商户号需开通支付分产品权限,且与appid有绑定关系,详见直连商户与AppID账号关联管理。
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个字符,需严格按照不能超过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) 【风险名称】 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) 【服务开始时间】 end_time 选填 string(14) 【服务结束时间】 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填写注意事项规范填写。
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 "service_introduction" : "XX充电宝", 7 "state" : "CREATED", 8 "state_description" : "MCH_COMPLETE", 9 "post_payments" : { 10 "name" : "就餐费用", 11 "amount" : 40000, 12 "description" : "就餐人均100元", 13 "count" : 4 14 }, 15 "post_discounts" : [ 16 { 17 "name" : "满20减1元", 18 "description" : "不与其他优惠叠加", 19 "amount" : 100, 20 "count" : 2 21 } 22 ], 23 "risk_fund" : { 24 "name" : "DEPOSIT", 25 "amount" : 10000, 26 "description" : "就餐的预估费用" 27 }, 28 "total_amount" : 40000, 29 "need_collection" : true, 30 "collection" : { 31 "state" : "USER_PAID", 32 "total_amount" : 50000, 33 "paying_amount" : 40000, 34 "paid_amount" : 10000, 35 "details" : [ 36 { 37 "seq" : 1, 38 "amount" : 10000, 39 "paid_type" : "NEWTON", 40 "paid_time" : "20091225091210", 41 "transaction_id" : "15646546545165651651" 42 } 43 ] 44 }, 45 "time_range" : { 46 "start_time" : "20091225091010", 47 "end_time" : "20091225121010", 48 "start_time_remark" : "备注1", 49 "end_time_remark" : "备注2" 50 }, 51 "location" : { 52 "start_location" : "嗨客时尚主题展餐厅", 53 "end_location" : "嗨客时尚主题展餐厅" 54 }, 55 "attach" : "Easdfowealsdkjfnlaksjdlfkwqoi&wl3l2sald", 56 "notify_url" : "https://api.test.com", 57 "openid" : "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o", 58 "order_id" : "0000300001201908301055157220022" 59} 60
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
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开头的状态码都为系统问题,请使用相同参数稍后重新调用 |