扣费受理
更新时间:2025.03.11商户请求扣费受理接口,会完成订单受理。微信支付进行异步扣款,支付完成后,会将订单支付结果发送给商户。
接口说明
支持商户:【普通服务商】
请求方式:【POST】/v3/vehicle/transactions/parking
请求域名:【主域名】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
body 包体参数
appid 必填 string(32)
【公众账号ID】 AppID是商户在微信申请公众号或移动应用成功后分配的账号ID,登录平台为mp.weixin.qq.com或open.weixin.qq.com
sub_appid 选填 string(32)
【子公众账号ID】子公众账号ID,服务商模式下选传,用于扣费信息的商户信息展示,
sub_mchid 必填 string(32)
【子商户号】微信支付分配的子商户号,服务商模式下必传
description 必填 string(128)
【服务描述】商户自定义字段,用于交易账单中对扣费服务的描述。
attach 选填 string(128)
【附加数据】附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
out_trade_no 必填 string(32)
【商户订单号】商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
trade_scene 必填 string(16)
【交易场景】交易场景值,目前支持 :PARKING:车场停车场景
goods_tag 选填 string(32)
【订单优惠标记】代金券或立减优惠功能的参数,说明详见代金券或立减优惠
notify_url 必填 string(256)
【回调通知URL】接受扣款结果异步回调通知的URL,注意回调URL只接受HTTPS
profit_sharing 选填 string(16)
【分账标识】Y:是,需要分账
N:否,不分账
字母要求大写,不传默认不分账,分账详细说明见直连分账API、服务商分账API文档
amount 必填 object
【订单金额】订单金额信息
属性 | |
total 必填 integer 【订单金额】订单总金额,单位为分,只能为整数 currency 选填 string(16) 【货币类型】符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY |
parking_info 选填 object
【停车场景信息】当交易场景为PARKING时,需要在该字段添加停车场景信息
属性 | |
parking_id 必填 string(32) 【入场ID】微信支付分停车服务为商户分配的入场ID,商户通过入场通知接口获取入场ID plate_number 必填 string(32) 【车牌号】车牌号,仅包括省份+车牌,不包括特殊字符。 plate_color 必填 string 【车牌颜色】车牌颜色 可选取值:
start_time 必填 string(32) 【入场时间】用户入场时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 end_time 必填 string(32) 【出场时间】用户出场时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 parking_name 必填 string(32) 【停车场名称】所在停车位车场的名称 charging_duration 必填 integer 【计费时长】计费的时间长,单位为秒 device_id 必填 string(32) 【停车场设备ID】停车场设备ID |
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/vehicle/transactions/parking \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "appid" : "wxcbda96de0b165486", 8 "sub_appid" : "wxcbda96de0b165486", 9 "sub_mchid" : "1900000109", 10 "description" : "停车场扣费", 11 "attach" : "深圳分店", 12 "out_trade_no" : "20150806125346", 13 "trade_scene" : "PARKING", 14 "goods_tag" : "WXG", 15 "notify_url" : "https://www.weixin.qq.com/wxpay/pay.php", 16 "profit_sharing" : "Y", 17 "amount" : { 18 "total" : 888, 19 "currency" : "CNY" 20 }, 21 "parking_info" : { 22 "parking_id" : "5K8264ILTKCH16CQ250", 23 "plate_number" : "粤B888888", 24 "plate_color" : "BLUE", 25 "start_time" : "2017-08-26T10:43:39+08:00", 26 "end_time" : "2017-08-26T10:43:39+08:00", 27 "parking_name" : "欢乐海岸停车场", 28 "charging_duration" : 3600, 29 "device_id" : "12313" 30 } 31 }' 32
需配合微信支付工具库 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 CreateTransaction { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/vehicle/transactions/parking"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 CreateTransaction client = new CreateTransaction( 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 CreateTransactionRequest request = new CreateTransactionRequest(); 41 request.appid = "wxcbda96de0b165486"; 42 request.subAppid = "wxcbda96de0b165486"; 43 request.subMchid = "1900000109"; 44 request.description = "停车场扣费"; 45 request.attach = "深圳分店"; 46 request.outTradeNo = "20150806125346"; 47 request.tradeScene = "PARKING"; 48 request.goodsTag = "WXG"; 49 request.notifyUrl = "https://www.weixin.qq.com/wxpay/pay.php"; 50 request.profitSharing = "Y"; 51 request.amount = new OrderAmount(); 52 request.amount.total = 888L; 53 request.amount.currency = "CNY"; 54 request.parkingInfo = new ParkingTradeScene(); 55 request.parkingInfo.parkingId = "5K8264ILTKCH16CQ250"; 56 request.parkingInfo.plateNumber = "粤B888888"; 57 request.parkingInfo.plateColor = PlateColor.BLUE; 58 request.parkingInfo.startTime = "2017-08-26T10:43:39+08:00"; 59 request.parkingInfo.endTime = "2017-08-26T10:43:39+08:00"; 60 request.parkingInfo.parkingName = "欢乐海岸停车场"; 61 request.parkingInfo.chargingDuration = 3600L; 62 request.parkingInfo.deviceId = "12313"; 63 try { 64 Transaction response = client.run(request); 65 // TODO: 请求成功,继续业务逻辑 66 System.out.println(response); 67 } catch (WXPayUtility.ApiException e) { 68 // TODO: 请求失败,根据状态码执行不同的逻辑 69 e.printStackTrace(); 70 } 71 } 72 73 public Transaction run(CreateTransactionRequest request) { 74 String uri = PATH; 75 String reqBody = WXPayUtility.toJson(request); 76 77 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 78 reqBuilder.addHeader("Accept", "application/json"); 79 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 80 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 81 reqBuilder.addHeader("Content-Type", "application/json"); 82 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 83 reqBuilder.method(METHOD, requestBody); 84 Request httpRequest = reqBuilder.build(); 85 86 // 发送HTTP请求 87 OkHttpClient client = new OkHttpClient.Builder().build(); 88 try (Response httpResponse = client.newCall(httpRequest).execute()) { 89 String respBody = WXPayUtility.extractBody(httpResponse); 90 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 91 // 2XX 成功,验证应答签名 92 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 93 httpResponse.headers(), respBody); 94 95 // 从HTTP应答报文构建返回数据 96 return WXPayUtility.fromJson(respBody, Transaction.class); 97 } else { 98 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 99 } 100 } catch (IOException e) { 101 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 102 } 103 } 104 105 private final String mchid; 106 private final String certificateSerialNo; 107 private final PrivateKey privateKey; 108 private final String wechatPayPublicKeyId; 109 private final PublicKey wechatPayPublicKey; 110 111 public CreateTransaction(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 112 this.mchid = mchid; 113 this.certificateSerialNo = certificateSerialNo; 114 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 115 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 116 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 117 } 118 119 public static class CreateTransactionRequest { 120 @SerializedName("appid") 121 public String appid; 122 123 @SerializedName("sub_appid") 124 public String subAppid; 125 126 @SerializedName("sub_mchid") 127 public String subMchid; 128 129 @SerializedName("description") 130 public String description; 131 132 @SerializedName("attach") 133 public String attach; 134 135 @SerializedName("out_trade_no") 136 public String outTradeNo; 137 138 @SerializedName("trade_scene") 139 public String tradeScene; 140 141 @SerializedName("goods_tag") 142 public String goodsTag; 143 144 @SerializedName("notify_url") 145 public String notifyUrl; 146 147 @SerializedName("profit_sharing") 148 public String profitSharing; 149 150 @SerializedName("amount") 151 public OrderAmount amount; 152 153 @SerializedName("parking_info") 154 public ParkingTradeScene parkingInfo; 155 } 156 157 public static class Transaction { 158 @SerializedName("appid") 159 public String appid; 160 161 @SerializedName("sub_appid") 162 public String subAppid; 163 164 @SerializedName("sp_mchid") 165 public String spMchid; 166 167 @SerializedName("sub_mchid") 168 public String subMchid; 169 170 @SerializedName("description") 171 public String description; 172 173 @SerializedName("create_time") 174 public String createTime; 175 176 @SerializedName("out_trade_no") 177 public String outTradeNo; 178 179 @SerializedName("transaction_id") 180 public String transactionId; 181 182 @SerializedName("trade_state") 183 public String tradeState; 184 185 @SerializedName("trade_state_description") 186 public String tradeStateDescription; 187 188 @SerializedName("success_time") 189 public String successTime; 190 191 @SerializedName("bank_type") 192 public String bankType; 193 194 @SerializedName("user_repaid") 195 public String userRepaid; 196 197 @SerializedName("attach") 198 public String attach; 199 200 @SerializedName("trade_scene") 201 public String tradeScene; 202 203 @SerializedName("parking_info") 204 public ParkingTradeScene parkingInfo; 205 206 @SerializedName("payer") 207 public Payer payer; 208 209 @SerializedName("amount") 210 public QueryOrderAmount amount; 211 212 @SerializedName("promotion_detail") 213 public List<PromotionDetail> promotionDetail; 214 } 215 216 public static class OrderAmount { 217 @SerializedName("total") 218 public Long total; 219 220 @SerializedName("currency") 221 public String currency; 222 } 223 224 public static class ParkingTradeScene { 225 @SerializedName("parking_id") 226 public String parkingId; 227 228 @SerializedName("plate_number") 229 public String plateNumber; 230 231 @SerializedName("plate_color") 232 public PlateColor plateColor; 233 234 @SerializedName("start_time") 235 public String startTime; 236 237 @SerializedName("end_time") 238 public String endTime; 239 240 @SerializedName("parking_name") 241 public String parkingName; 242 243 @SerializedName("charging_duration") 244 public Long chargingDuration; 245 246 @SerializedName("device_id") 247 public String deviceId; 248 } 249 250 public static class Payer { 251 @SerializedName("openid") 252 public String openid; 253 254 @SerializedName("sub_openid") 255 public String subOpenid; 256 } 257 258 public static class QueryOrderAmount { 259 @SerializedName("total") 260 public Long total; 261 262 @SerializedName("currency") 263 public String currency; 264 265 @SerializedName("payer_total") 266 public Long payerTotal; 267 268 @SerializedName("discount_total") 269 public Long discountTotal; 270 } 271 272 public static class PromotionDetail { 273 @SerializedName("coupon_id") 274 public String couponId; 275 276 @SerializedName("name") 277 public String name; 278 279 @SerializedName("scope") 280 public String scope; 281 282 @SerializedName("type") 283 public String type; 284 285 @SerializedName("stock_id") 286 public String stockId; 287 288 @SerializedName("amount") 289 public Long amount; 290 291 @SerializedName("wechatpay_contribute") 292 public Long wechatpayContribute; 293 294 @SerializedName("merchant_contribute") 295 public Long merchantContribute; 296 297 @SerializedName("other_contribute") 298 public Long otherContribute; 299 300 @SerializedName("currency") 301 public String currency; 302 } 303 304 public enum PlateColor { 305 @SerializedName("BLUE") 306 BLUE, 307 @SerializedName("GREEN") 308 GREEN, 309 @SerializedName("YELLOW") 310 YELLOW, 311 @SerializedName("BLACK") 312 BLACK, 313 @SerializedName("WHITE") 314 WHITE, 315 @SerializedName("LIMEGREEN") 316 LIMEGREEN 317 } 318 319} 320
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &CreateTransactionRequest{ 28 Appid: wxpay_utility.String("wxcbda96de0b165486"), 29 SubAppid: wxpay_utility.String("wxcbda96de0b165486"), 30 SubMchid: wxpay_utility.String("1900000109"), 31 Description: wxpay_utility.String("停车场扣费"), 32 Attach: wxpay_utility.String("深圳分店"), 33 OutTradeNo: wxpay_utility.String("20150806125346"), 34 TradeScene: wxpay_utility.String("PARKING"), 35 GoodsTag: wxpay_utility.String("WXG"), 36 NotifyUrl: wxpay_utility.String("https://www.weixin.qq.com/wxpay/pay.php"), 37 ProfitSharing: wxpay_utility.String("Y"), 38 Amount: &OrderAmount{ 39 Total: wxpay_utility.Int64(888), 40 Currency: wxpay_utility.String("CNY"), 41 }, 42 ParkingInfo: &ParkingTradeScene{ 43 ParkingId: wxpay_utility.String("5K8264ILTKCH16CQ250"), 44 PlateNumber: wxpay_utility.String("粤B888888"), 45 PlateColor: PLATECOLOR_BLUE.Ptr(), 46 StartTime: wxpay_utility.Time(time.Now()), 47 EndTime: wxpay_utility.Time(time.Now()), 48 ParkingName: wxpay_utility.String("欢乐海岸停车场"), 49 ChargingDuration: wxpay_utility.Int64(3600), 50 DeviceId: wxpay_utility.String("12313"), 51 }, 52 } 53 54 response, err := CreateTransaction(config, request) 55 if err != nil { 56 fmt.Printf("请求失败: %+v\n", err) 57 // TODO: 请求失败,根据状态码执行不同的处理 58 return 59 } 60 61 // TODO: 请求成功,继续业务逻辑 62 fmt.Printf("请求成功: %+v\n", response) 63} 64 65func CreateTransaction(config *wxpay_utility.MchConfig, request *CreateTransactionRequest) (response *Transaction, err error) { 66 const ( 67 host = "https://api.mch.weixin.qq.com" 68 method = "POST" 69 path = "/v3/vehicle/transactions/parking" 70 ) 71 72 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 73 if err != nil { 74 return nil, err 75 } 76 reqBody, err := json.Marshal(request) 77 if err != nil { 78 return nil, err 79 } 80 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 81 if err != nil { 82 return nil, err 83 } 84 httpRequest.Header.Set("Accept", "application/json") 85 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 86 httpRequest.Header.Set("Content-Type", "application/json") 87 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 88 if err != nil { 89 return nil, err 90 } 91 httpRequest.Header.Set("Authorization", authorization) 92 93 client := &http.Client{} 94 httpResponse, err := client.Do(httpRequest) 95 if err != nil { 96 return nil, err 97 } 98 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 99 if err != nil { 100 return nil, err 101 } 102 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 103 // 2XX 成功,验证应答签名 104 err = wxpay_utility.ValidateResponse( 105 config.WechatPayPublicKeyId(), 106 config.WechatPayPublicKey(), 107 &httpResponse.Header, 108 respBody, 109 ) 110 if err != nil { 111 return nil, err 112 } 113 response := &Transaction{} 114 if err := json.Unmarshal(respBody, response); err != nil { 115 return nil, err 116 } 117 118 return response, nil 119 } else { 120 return nil, wxpay_utility.NewApiException( 121 httpResponse.StatusCode, 122 httpResponse.Header, 123 respBody, 124 ) 125 } 126} 127 128type CreateTransactionRequest struct { 129 Appid *string `json:"appid,omitempty"` 130 SubAppid *string `json:"sub_appid,omitempty"` 131 SubMchid *string `json:"sub_mchid,omitempty"` 132 Description *string `json:"description,omitempty"` 133 Attach *string `json:"attach,omitempty"` 134 OutTradeNo *string `json:"out_trade_no,omitempty"` 135 TradeScene *string `json:"trade_scene,omitempty"` 136 GoodsTag *string `json:"goods_tag,omitempty"` 137 NotifyUrl *string `json:"notify_url,omitempty"` 138 ProfitSharing *string `json:"profit_sharing,omitempty"` 139 Amount *OrderAmount `json:"amount,omitempty"` 140 ParkingInfo *ParkingTradeScene `json:"parking_info,omitempty"` 141} 142 143type Transaction struct { 144 Appid *string `json:"appid,omitempty"` 145 SubAppid *string `json:"sub_appid,omitempty"` 146 SpMchid *string `json:"sp_mchid,omitempty"` 147 SubMchid *string `json:"sub_mchid,omitempty"` 148 Description *string `json:"description,omitempty"` 149 CreateTime *time.Time `json:"create_time,omitempty"` 150 OutTradeNo *string `json:"out_trade_no,omitempty"` 151 TransactionId *string `json:"transaction_id,omitempty"` 152 TradeState *string `json:"trade_state,omitempty"` 153 TradeStateDescription *string `json:"trade_state_description,omitempty"` 154 SuccessTime *time.Time `json:"success_time,omitempty"` 155 BankType *string `json:"bank_type,omitempty"` 156 UserRepaid *string `json:"user_repaid,omitempty"` 157 Attach *string `json:"attach,omitempty"` 158 TradeScene *string `json:"trade_scene,omitempty"` 159 ParkingInfo *ParkingTradeScene `json:"parking_info,omitempty"` 160 Payer *Payer `json:"payer,omitempty"` 161 Amount *QueryOrderAmount `json:"amount,omitempty"` 162 PromotionDetail []PromotionDetail `json:"promotion_detail,omitempty"` 163} 164 165type OrderAmount struct { 166 Total *int64 `json:"total,omitempty"` 167 Currency *string `json:"currency,omitempty"` 168} 169 170type ParkingTradeScene struct { 171 ParkingId *string `json:"parking_id,omitempty"` 172 PlateNumber *string `json:"plate_number,omitempty"` 173 PlateColor *PlateColor `json:"plate_color,omitempty"` 174 StartTime *time.Time `json:"start_time,omitempty"` 175 EndTime *time.Time `json:"end_time,omitempty"` 176 ParkingName *string `json:"parking_name,omitempty"` 177 ChargingDuration *int64 `json:"charging_duration,omitempty"` 178 DeviceId *string `json:"device_id,omitempty"` 179} 180 181type Payer struct { 182 Openid *string `json:"openid,omitempty"` 183 SubOpenid *string `json:"sub_openid,omitempty"` 184} 185 186type QueryOrderAmount struct { 187 Total *int64 `json:"total,omitempty"` 188 Currency *string `json:"currency,omitempty"` 189 PayerTotal *int64 `json:"payer_total,omitempty"` 190 DiscountTotal *int64 `json:"discount_total,omitempty"` 191} 192 193type PromotionDetail struct { 194 CouponId *string `json:"coupon_id,omitempty"` 195 Name *string `json:"name,omitempty"` 196 Scope *string `json:"scope,omitempty"` 197 Type *string `json:"type,omitempty"` 198 StockId *string `json:"stock_id,omitempty"` 199 Amount *int64 `json:"amount,omitempty"` 200 WechatpayContribute *int64 `json:"wechatpay_contribute,omitempty"` 201 MerchantContribute *int64 `json:"merchant_contribute,omitempty"` 202 OtherContribute *int64 `json:"other_contribute,omitempty"` 203 Currency *string `json:"currency,omitempty"` 204} 205 206type PlateColor string 207 208func (e PlateColor) Ptr() *PlateColor { 209 return &e 210} 211 212const ( 213 PLATECOLOR_BLUE PlateColor = "BLUE" 214 PLATECOLOR_GREEN PlateColor = "GREEN" 215 PLATECOLOR_YELLOW PlateColor = "YELLOW" 216 PLATECOLOR_BLACK PlateColor = "BLACK" 217 PLATECOLOR_WHITE PlateColor = "WHITE" 218 PLATECOLOR_LIMEGREEN PlateColor = "LIMEGREEN" 219) 220
应答参数
|
appid 必填 string(32)
【公众账号ID】AppID是商户在微信申请公众号或移动应用成功后分配的账号ID,登录平台为mp.weixin.qq.com或open.weixin.qq.com
sub_appid 选填 string(32)
【子商户公众账号ID】子商户申请的公众号或移动应用AppID,需要在服务商的商户平台为子商户绑定
sp_mchid 必填 string(32)
【商户号】微信支付分配的商户号
sub_mchid 必填 string(32)
【子商户号】微信支付分配的子商户号
description 必填 string(128)
【服务描述】商户自定义字段,用于交易账单中对扣费服务的描述。
create_time 必填 string(32)
【订单创建时间】订单成功创建时返回,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
out_trade_no 必填 string(32)
【商户订单号】商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
transaction_id 选填 string(32)
【微信支付订单号】微信支付订单号
trade_state 必填 string(32)
【交易状态】SUCCESS—支付成功
ACCEPTED—已接收,等待扣款
PAY_FAIL–支付失败(其他原因,如银行返回失败)
REFUND—转入退款
trade_state_description 选填 string(256)
【交易状态描述】对当前订单状态的描述和下一步操作的指引
success_time 选填 string(32)
【支付完成时间】订单支付完成时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。
bank_type 选填 string(16)
【付款银行】银行类型,采用字符串类型的银行标识。BPA:该笔订单由微信进行垫付
user_repaid 选填 string(1)
【用户是否已还款】枚举值:
Y:用户已还款
N:用户未还款
注意:使用此字段前需先确认bank_type字段值为BPA以及 trade_state字段值为SUCCESS。
attach 选填 string(128)
【附加数据】附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用
trade_scene 必填 string(32)
【交易场景】交易场景值,目前支持 :PARKING:车场停车场景
parking_info 选填 object
【停车场景信息】返回信息中的trade_scene为PARKING,返回该场景信息
属性 | |
parking_id 必填 string(32) 【入场ID】微信支付分停车服务为商户分配的入场ID,商户通过入场通知接口获取入场ID plate_number 必填 string(32) 【车牌号】车牌号,仅包括省份+车牌,不包括特殊字符。 plate_color 必填 string 【车牌颜色】车牌颜色 可选取值:
start_time 必填 string(32) 【入场时间】用户入场时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 end_time 必填 string(32) 【出场时间】用户出场时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 parking_name 必填 string(32) 【停车场名称】所在停车位车场的名称 charging_duration 必填 integer 【计费时长】计费的时间长,单位为秒 device_id 必填 string(32) 【停车场设备ID】停车场设备ID |
payer 必填 object
【支付者信息】支付者信息
属性 | |
openid 必填 string(32) 【用户在AppID下的标识】 用户在AppID下的唯一标识 sub_openid 选填 string(32) 【用户在Sub_AppID下的标识】 用户在Sub_AppID下的标识,商户扣费时传入了Sub_AppID,则会返回该用户在Sub_AppID下的标识 |
amount 必填 object
【订单金额信息】订单金额信息
属性 | |
total 必填 integer 【订单金额】订单总金额,单位为分,只能为整数,详见支付金额 currency 必填 string(16) 【货币类型】符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY payer_total 选填 integer 【用户实际支付金额】用户实际支付金额,单位为分,只能为整数,详见支付金额 discount_total 选填 integer 【折扣】订单折扣 |
promotion_detail 选填 array[object]
【优惠信息】优惠信息
属性 | |
coupon_id 必填 string(32) 【券ID】券或者立减优惠ID name 选填 string(128) 【优惠名称】优惠名称 scope 选填 string(32) 【优惠范围】GLOBAL-全场代金券, type 选填 string(16) 【优惠类型】枚举值: stock_id 选填 string(32) 【活动ID】在微信商户后台配置的批次ID amount 必填 integer 【优惠券面额】用户享受优惠的金额 wechatpay_contribute 选填 integer 【微信出资】特指由微信支付商户平台创建的优惠,出资金额等于本项优惠总金额,单位为分 merchant_contribute 选填 integer 【商户出资】特指商户自己创建的优惠,出资金额等于本项优惠总金额,单位为分 other_contribute 选填 integer 【其他出资】其他出资方出资金额,单位为分 currency 选填 string(16) 【优惠币种】CNY:人民币,境内商户号仅支持人民币。 |
应答示例
200 OK
1{ 2 "appid" : "wxcbda96de0b165486", 3 "sub_appid" : "wxcbda96de0b165489", 4 "sp_mchid" : "1230000109", 5 "sub_mchid" : "1900000109", 6 "description" : "停车场扣费", 7 "create_time" : "2017-08-26T10:43:39+08:00", 8 "out_trade_no" : "20150806125346", 9 "transaction_id" : "1009660380201506130728806387", 10 "trade_state" : "SUCCESS", 11 "trade_state_description" : "支付失败,请重新下单支付", 12 "success_time" : "2017-08-26T10:43:39+08:00", 13 "bank_type" : "CMC", 14 "user_repaid" : "Y", 15 "attach" : "深圳分店", 16 "trade_scene" : "PARKING", 17 "parking_info" : { 18 "parking_id" : "5K8264ILTKCH16CQ250", 19 "plate_number" : "粤B888888", 20 "plate_color" : "BLUE", 21 "start_time" : "2017-08-26T10:43:39+08:00", 22 "end_time" : "2017-08-26T10:43:39+08:00", 23 "parking_name" : "欢乐海岸停车场", 24 "charging_duration" : 3600, 25 "device_id" : "12313" 26 }, 27 "payer" : { 28 "openid" : "oUpF8uMuAJOM2pxb1Q", 29 "sub_openid" : "oUpF8uMuAJOM2pxb1Q" 30 }, 31 "amount" : { 32 "total" : 888, 33 "currency" : "CNY", 34 "payer_total" : 100, 35 "discount_total" : 100 36 }, 37 "promotion_detail" : [ 38 { 39 "coupon_id" : "109519", 40 "name" : "单品惠-6", 41 "scope" : "SINGLE", 42 "type" : "CASH", 43 "stock_id" : "931386", 44 "amount" : 5, 45 "wechatpay_contribute" : 1, 46 "merchant_contribute" : 1, 47 "other_contribute" : 1, 48 "currency" : "CNY" 49 } 50 ] 51} 52
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | ALREADY_EXISTS | out_trade_no冲突 | out_trade_no冲突,不同的订单请保证 out_trade_no 唯一 |
400 | INVALID_REQUEST | 非法商户,服务商模式下请确认子商户正确 | 微信支付分停车服务不支持当前商户访问,请确认商户已获得本产品权限。服务商模式下请同时确认子商户无误且已获得本产品权限 |
400 | INVALID_REQUEST | 商户号和公众号没有绑定关系 | 检查请求中的AppID与商户号(服务商模式下则为服务商商户号)是否匹配,然后重试 |
400 | INVALID_REQUEST | 商户号、子商户号以及子公众号没有绑定关系 | 检查请求中的 |
400 | INVALID_REQUEST | 用户状态异常 | 风控失败或者用户账户冻结 |
400 | INVALID_REQUEST | 停车入场ID不存在 | 商户传参的停车入场ID是非法,请填写微信支付分停车服务分配的停车入场ID |
400 | INVALID_REQUEST | 场景信息和停车入场ID不匹配 | 场景信息内容与入场ID不对应 |
400 | INVALID_REQUEST | 扣款额度超出限制 | 请检查确保发起扣款的订单额度不超过微信支付分停车支持的单笔及单日扣款额度 |
403 | NO_AUTH | 当前商户无法扣款 | 当前扣款商户无权限扣款,请确认当前扣款商户已开通微信支付分停车产品权限 |
403 | NOT_ENOUGH | 用户欠款过多,暂停交易 | 用户在微信支付分停车服务中欠款过多,不能进行扣款 |
429 | RATELIMIT_EXCEEDED | 达到调用速率限制 | 接口调用频率过快,请降低请求频率 |
500 | SYSTEM_ERROR | 出现内部服务器错误 | 5开头的错误码均为系统错误,请使用相同的参数稍后重试 |