同步支付结果通知
更新时间:2026.06.29对商户提供同步支付结果通知接口
接口说明
支持商户:【普通服务商】 【平台商户】
请求方式:【POST】/v3/parking/reminders/payment
请求域名:【主域名】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 包体参数
out_serial_number 必填 string(64)
【商户停车单号】 商户系统自行生成,须在同一商户号下全局唯一。建议不超过32字符,超过64字符将被拦截。与入场时同步的 out_serial_number 保持一致。
plate_number 必填 string(16)
【车牌号】 国内车牌,省份简称+6~7位字母或数字(新能源绿牌8位)。
parking_id 必填 string(64)
【微信停车场ID】 停车场进件审核通过且运营入驻完成后,由微信支付分配。可通过「查询停车场进件申请单」或「查询停车场信息」接口获取;入场/离场/支付等接口须与入场时保持一致。须与入场时同步的微信停车场ID保持一致,不一致将报错。
parking_state 必填 string
【停车状态】 按照本文档提供的停车状态枚举值传入,各枚举值含义见字段枚举说明。
可选取值
PARKING_STATUS_UNKNOWN: 未知PARKING_STATUS_PARKING: 停车中PARKING_STATUS_NOT_PARKING: 非停车中
pay_type 必填 string
【支付类型】 按照本文档提供的支付类型枚举值传入,各枚举值含义见字段枚举说明。仅支持微信支付(PAY_TYPE_WXPAY),非微信支付将拒绝同步。
可选取值
PAY_TYPE_UNKNOWN: 未知PAY_TYPE_WXPAY: 微信支付PAY_TYPE_OTHERS: 其他支付
openid 选填 string(128)
【付款用户OpenID】 支付渠道为微信支付时必填。获取方式详见参数说明。
sub_mchid 选填 string(32)
【特约商户号】 微信支付分配的特约商户号。支付渠道为微信支付且存在特约商户时必填。
total_amount 必填 integer
【总费用】 单位为分,必填
paid_amount 必填 integer
【已支付费用】 单位为分,必填;当支付渠道为微信支付时,不允许为零
out_trade_no 选填 string(64)
【商户支付订单号】 商户侧支付订单号;与 wx_trade_no 至少二选一必传,建议全填。长度1~64字符,同一商户号下建议唯一。
pay_channel 选填 string
【支付渠道】 已支付状态下建议填写,用于标识支付来源。
可选取值
PAY_CHANNEL_UNKNOWN: 未知PAY_CHANNEL_WECHAT_PAY_NOTIF: 微信支付通知消息PAY_CHANNEL_SCAN_QRCODE: 扫码PAY_CHANNEL_OFFICIAL_ACCOUNT: 公众号PAY_CHANNEL_MCH_MINI_PROG: 商户小程序PAY_CHANNEL_OTHERS: 其他
pay_time 选填 integer
【支付时间】 支付完成时刻,秒级时间戳(Unix timestamp)。例如:1719128975 表示北京时间2024-06-23 13:29:35。
token 选填 string(256)
【消息支付防伪凭证】 原样回传微信支付随缴费入口下发的凭证;用于服务端验真消息支付,缺省即未回传
wx_trade_no 选填 string(64)
【微信支付订单号】 微信支付订单号;与 out_trade_no 至少二选一必传,建议全填。长度1~64字符。
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/parking/reminders/payment \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Content-Type: application/json" \ 6 -d '{ 7 "out_serial_number" : "PARK20260423001", 8 "plate_number" : "粤B12345", 9 "parking_id" : "21232735744117624001123604298240", 10 "parking_state" : "PARKING_STATUS_UNKNOWN", 11 "pay_type" : "PAY_TYPE_UNKNOWN", 12 "openid" : "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o", 13 "sub_mchid" : "1900000109", 14 "total_amount" : 1, 15 "paid_amount" : 1, 16 "out_trade_no" : "4200001234567890123456789012", 17 "pay_channel" : "PAY_CHANNEL_UNKNOWN", 18 "pay_time" : 1719128975, 19 "token" : "msg_pay_token_example", 20 "wx_trade_no" : "4200001234567890123456789012" 21 }' 22
需配合微信支付工具库 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 SyncParkingPaymentResult { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/v3/parking/reminders/payment"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 SyncParkingPaymentResult client = new SyncParkingPaymentResult( 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 SyncParkingPaymentRequest request = new SyncParkingPaymentRequest(); 41 request.outSerialNumber = "PARK20260423001"; 42 request.plateNumber = "粤B12345"; 43 request.parkingId = "21232735744117624001123604298240"; 44 request.parkingState = ParkingStatus.PARKING_STATUS_UNKNOWN; 45 request.payType = PayType.PAY_TYPE_UNKNOWN; 46 request.openid = "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"; 47 request.subMchid = "1900000109"; 48 request.totalAmount = 1L; 49 request.paidAmount = 1L; 50 request.outTradeNo = "4200001234567890123456789012"; 51 request.payChannel = PayChannel.PAY_CHANNEL_UNKNOWN; 52 request.payTime = 1719128975L; 53 request.token = "msg_pay_token_example"; 54 request.wxTradeNo = "4200001234567890123456789012"; 55 try { 56 SyncParkingPaymentResponse response = client.run(request); 57 // TODO: 请求成功,继续业务逻辑 58 System.out.println(response); 59 } catch (WXPayUtility.ApiException e) { 60 // TODO: 请求失败,根据状态码执行不同的逻辑 61 e.printStackTrace(); 62 } 63 } 64 65 public SyncParkingPaymentResponse run(SyncParkingPaymentRequest request) { 66 String uri = PATH; 67 String reqBody = WXPayUtility.toJson(request); 68 69 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 70 reqBuilder.addHeader("Accept", "application/json"); 71 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 72 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 73 reqBuilder.addHeader("Content-Type", "application/json"); 74 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 75 reqBuilder.method(METHOD, requestBody); 76 Request httpRequest = reqBuilder.build(); 77 78 // 发送HTTP请求 79 OkHttpClient client = new OkHttpClient.Builder().build(); 80 try (Response httpResponse = client.newCall(httpRequest).execute()) { 81 String respBody = WXPayUtility.extractBody(httpResponse); 82 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 83 // 2XX 成功,验证应答签名 84 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 85 httpResponse.headers(), respBody); 86 87 // 从HTTP应答报文构建返回数据 88 return WXPayUtility.fromJson(respBody, SyncParkingPaymentResponse.class); 89 } else { 90 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 91 } 92 } catch (IOException e) { 93 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 94 } 95 } 96 97 private final String mchid; 98 private final String certificateSerialNo; 99 private final PrivateKey privateKey; 100 private final String wechatPayPublicKeyId; 101 private final PublicKey wechatPayPublicKey; 102 103 public SyncParkingPaymentResult(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 104 this.mchid = mchid; 105 this.certificateSerialNo = certificateSerialNo; 106 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 107 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 108 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 109 } 110 111 public static class SyncParkingPaymentRequest { 112 @SerializedName("out_serial_number") 113 public String outSerialNumber; 114 115 @SerializedName("plate_number") 116 public String plateNumber; 117 118 @SerializedName("parking_id") 119 public String parkingId; 120 121 @SerializedName("parking_state") 122 public ParkingStatus parkingState; 123 124 @SerializedName("pay_type") 125 public PayType payType; 126 127 @SerializedName("openid") 128 public String openid; 129 130 @SerializedName("sub_mchid") 131 public String subMchid; 132 133 @SerializedName("total_amount") 134 public Long totalAmount; 135 136 @SerializedName("paid_amount") 137 public Long paidAmount; 138 139 @SerializedName("out_trade_no") 140 public String outTradeNo; 141 142 @SerializedName("pay_channel") 143 public PayChannel payChannel; 144 145 @SerializedName("pay_time") 146 public Long payTime; 147 148 @SerializedName("token") 149 public String token; 150 151 @SerializedName("wx_trade_no") 152 public String wxTradeNo; 153 } 154 155 public static class SyncParkingPaymentResponse { 156 @SerializedName("code") 157 public String code; 158 159 @SerializedName("message") 160 public String message; 161 } 162 163 public enum ParkingStatus { 164 @SerializedName("PARKING_STATUS_UNKNOWN") 165 PARKING_STATUS_UNKNOWN, 166 @SerializedName("PARKING_STATUS_PARKING") 167 PARKING_STATUS_PARKING, 168 @SerializedName("PARKING_STATUS_NOT_PARKING") 169 PARKING_STATUS_NOT_PARKING 170 } 171 172 public enum PayType { 173 @SerializedName("PAY_TYPE_UNKNOWN") 174 PAY_TYPE_UNKNOWN, 175 @SerializedName("PAY_TYPE_WXPAY") 176 PAY_TYPE_WXPAY, 177 @SerializedName("PAY_TYPE_OTHERS") 178 PAY_TYPE_OTHERS 179 } 180 181 public enum PayChannel { 182 @SerializedName("PAY_CHANNEL_UNKNOWN") 183 PAY_CHANNEL_UNKNOWN, 184 @SerializedName("PAY_CHANNEL_WECHAT_PAY_NOTIF") 185 PAY_CHANNEL_WECHAT_PAY_NOTIF, 186 @SerializedName("PAY_CHANNEL_SCAN_QRCODE") 187 PAY_CHANNEL_SCAN_QRCODE, 188 @SerializedName("PAY_CHANNEL_OFFICIAL_ACCOUNT") 189 PAY_CHANNEL_OFFICIAL_ACCOUNT, 190 @SerializedName("PAY_CHANNEL_MCH_MINI_PROG") 191 PAY_CHANNEL_MCH_MINI_PROG, 192 @SerializedName("PAY_CHANNEL_OTHERS") 193 PAY_CHANNEL_OTHERS 194 } 195 196} 197
需配合微信支付工具库 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) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 14 config, err := wxpay_utility.CreateMchConfig( 15 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 16 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 17 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &SyncParkingPaymentRequest{ 27 OutSerialNumber: wxpay_utility.String("PARK20260423001"), 28 PlateNumber: wxpay_utility.String("粤B12345"), 29 ParkingId: wxpay_utility.String("21232735744117624001123604298240"), 30 ParkingState: PARKINGSTATUS_PARKING_STATUS_UNKNOWN.Ptr(), 31 PayType: PAYTYPE_PAY_TYPE_UNKNOWN.Ptr(), 32 Openid: wxpay_utility.String("oUpF8uMuAJO_M2pxb1Q9zNjWeS6o"), 33 SubMchid: wxpay_utility.String("1900000109"), 34 TotalAmount: wxpay_utility.Int64(1), 35 PaidAmount: wxpay_utility.Int64(1), 36 OutTradeNo: wxpay_utility.String("4200001234567890123456789012"), 37 PayChannel: PAYCHANNEL_PAY_CHANNEL_UNKNOWN.Ptr(), 38 PayTime: wxpay_utility.Int64(1719128975), 39 Token: wxpay_utility.String("msg_pay_token_example"), 40 WxTradeNo: wxpay_utility.String("4200001234567890123456789012"), 41 } 42 43 response, err := SyncParkingPaymentResult(config, request) 44 if err != nil { 45 fmt.Printf("请求失败: %+v\n", err) 46 // TODO: 请求失败,根据状态码执行不同的处理 47 return 48 } 49 50 // TODO: 请求成功,继续业务逻辑 51 fmt.Printf("请求成功: %+v\n", response) 52} 53 54func SyncParkingPaymentResult(config *wxpay_utility.MchConfig, request *SyncParkingPaymentRequest) (response *SyncParkingPaymentResponse, err error) { 55 const ( 56 host = "https://api.mch.weixin.qq.com" 57 method = "POST" 58 path = "/v3/parking/reminders/payment" 59 ) 60 61 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 62 if err != nil { 63 return nil, err 64 } 65 reqBody, err := json.Marshal(request) 66 if err != nil { 67 return nil, err 68 } 69 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 70 if err != nil { 71 return nil, err 72 } 73 httpRequest.Header.Set("Accept", "application/json") 74 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 75 httpRequest.Header.Set("Content-Type", "application/json") 76 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 77 if err != nil { 78 return nil, err 79 } 80 httpRequest.Header.Set("Authorization", authorization) 81 82 client := &http.Client{} 83 httpResponse, err := client.Do(httpRequest) 84 if err != nil { 85 return nil, err 86 } 87 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 88 if err != nil { 89 return nil, err 90 } 91 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 92 // 2XX 成功,验证应答签名 93 err = wxpay_utility.ValidateResponse( 94 config.WechatPayPublicKeyId(), 95 config.WechatPayPublicKey(), 96 &httpResponse.Header, 97 respBody, 98 ) 99 if err != nil { 100 return nil, err 101 } 102 response := &SyncParkingPaymentResponse{} 103 if err := json.Unmarshal(respBody, response); err != nil { 104 return nil, err 105 } 106 107 return response, nil 108 } else { 109 return nil, wxpay_utility.NewApiException( 110 httpResponse.StatusCode, 111 httpResponse.Header, 112 respBody, 113 ) 114 } 115} 116 117type SyncParkingPaymentRequest struct { 118 OutSerialNumber *string `json:"out_serial_number,omitempty"` 119 PlateNumber *string `json:"plate_number,omitempty"` 120 ParkingId *string `json:"parking_id,omitempty"` 121 ParkingState *ParkingStatus `json:"parking_state,omitempty"` 122 PayType *PayType `json:"pay_type,omitempty"` 123 Openid *string `json:"openid,omitempty"` 124 SubMchid *string `json:"sub_mchid,omitempty"` 125 TotalAmount *int64 `json:"total_amount,omitempty"` 126 PaidAmount *int64 `json:"paid_amount,omitempty"` 127 OutTradeNo *string `json:"out_trade_no,omitempty"` 128 PayChannel *PayChannel `json:"pay_channel,omitempty"` 129 PayTime *int64 `json:"pay_time,omitempty"` 130 Token *string `json:"token,omitempty"` 131 WxTradeNo *string `json:"wx_trade_no,omitempty"` 132} 133 134type SyncParkingPaymentResponse struct { 135 Code *string `json:"code,omitempty"` 136 Message *string `json:"message,omitempty"` 137} 138 139type ParkingStatus string 140 141func (e ParkingStatus) Ptr() *ParkingStatus { 142 return &e 143} 144 145const ( 146 PARKINGSTATUS_PARKING_STATUS_UNKNOWN ParkingStatus = "PARKING_STATUS_UNKNOWN" 147 PARKINGSTATUS_PARKING_STATUS_PARKING ParkingStatus = "PARKING_STATUS_PARKING" 148 PARKINGSTATUS_PARKING_STATUS_NOT_PARKING ParkingStatus = "PARKING_STATUS_NOT_PARKING" 149) 150 151type PayType string 152 153func (e PayType) Ptr() *PayType { 154 return &e 155} 156 157const ( 158 PAYTYPE_PAY_TYPE_UNKNOWN PayType = "PAY_TYPE_UNKNOWN" 159 PAYTYPE_PAY_TYPE_WXPAY PayType = "PAY_TYPE_WXPAY" 160 PAYTYPE_PAY_TYPE_OTHERS PayType = "PAY_TYPE_OTHERS" 161) 162 163type PayChannel string 164 165func (e PayChannel) Ptr() *PayChannel { 166 return &e 167} 168 169const ( 170 PAYCHANNEL_PAY_CHANNEL_UNKNOWN PayChannel = "PAY_CHANNEL_UNKNOWN" 171 PAYCHANNEL_PAY_CHANNEL_WECHAT_PAY_NOTIF PayChannel = "PAY_CHANNEL_WECHAT_PAY_NOTIF" 172 PAYCHANNEL_PAY_CHANNEL_SCAN_QRCODE PayChannel = "PAY_CHANNEL_SCAN_QRCODE" 173 PAYCHANNEL_PAY_CHANNEL_OFFICIAL_ACCOUNT PayChannel = "PAY_CHANNEL_OFFICIAL_ACCOUNT" 174 PAYCHANNEL_PAY_CHANNEL_MCH_MINI_PROG PayChannel = "PAY_CHANNEL_MCH_MINI_PROG" 175 PAYCHANNEL_PAY_CHANNEL_OTHERS PayChannel = "PAY_CHANNEL_OTHERS" 176) 177
应答参数
200 OK
code 选填 string(32)
【响应码】 仅接口调用失败时返回;调用成功时不返回此字段。失败时返回错误码字符串,具体见接口错误码列表。
message 选填 string(256)
【返回信息】 仅接口调用失败时返回;调用成功时不返回此字段。失败时返回错误原因描述。
应答示例
200 OK
1{ 2 "code" : "PARAM_ERROR", 3 "message" : "参数错误" 4} 5
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
