查询停车费用
更新时间:2026.06.29对商户提供查询停车费用接口
接口说明
支持商户:【普通服务商】 【平台商户】
请求方式:【POST】/v3/parking/reminders/parking-fee
请求域名:【主域名】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字符将被拦截。
plate_number 选填 string(16)
【车牌号】 国内车牌,省份简称+6~7位字母或数字(新能源绿牌8位)。
out_parking_id 选填 string(64)
【商户停车场ID】 与进件接口中的 out_parking_lot_id 同义,为本接口历史字段命名。商户侧自定义的停车场唯一标识,在「提交停车场进件申请」时传入。仅支持字母、数字、下划线、连字符,长度1~64字符,同一商户号下不可重复。
请求示例
POST
1curl -X POST \ 2 https://api.mch.weixin.qq.com/v3/parking/reminders/parking-fee \ 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 "out_parking_id" : "lot_sz_tencent_001" 10 }' 11
需配合微信支付工具库 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 QueryParkingFee { 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/parking-fee"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 QueryParkingFee client = new QueryParkingFee( 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 QueryParkingFeeRequest request = new QueryParkingFeeRequest(); 41 request.outSerialNumber = "PARK20260423001"; 42 request.plateNumber = "粤B12345"; 43 request.outParkingId = "lot_sz_tencent_001"; 44 try { 45 QueryParkingFeeResponse response = client.run(request); 46 // TODO: 请求成功,继续业务逻辑 47 System.out.println(response); 48 } catch (WXPayUtility.ApiException e) { 49 // TODO: 请求失败,根据状态码执行不同的逻辑 50 e.printStackTrace(); 51 } 52 } 53 54 public QueryParkingFeeResponse run(QueryParkingFeeRequest request) { 55 String uri = PATH; 56 String reqBody = WXPayUtility.toJson(request); 57 58 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 59 reqBuilder.addHeader("Accept", "application/json"); 60 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 61 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 62 reqBuilder.addHeader("Content-Type", "application/json"); 63 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 64 reqBuilder.method(METHOD, requestBody); 65 Request httpRequest = reqBuilder.build(); 66 67 // 发送HTTP请求 68 OkHttpClient client = new OkHttpClient.Builder().build(); 69 try (Response httpResponse = client.newCall(httpRequest).execute()) { 70 String respBody = WXPayUtility.extractBody(httpResponse); 71 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 72 // 2XX 成功,验证应答签名 73 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 74 httpResponse.headers(), respBody); 75 76 // 从HTTP应答报文构建返回数据 77 return WXPayUtility.fromJson(respBody, QueryParkingFeeResponse.class); 78 } else { 79 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 80 } 81 } catch (IOException e) { 82 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 83 } 84 } 85 86 private final String mchid; 87 private final String certificateSerialNo; 88 private final PrivateKey privateKey; 89 private final String wechatPayPublicKeyId; 90 private final PublicKey wechatPayPublicKey; 91 92 public QueryParkingFee(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 93 this.mchid = mchid; 94 this.certificateSerialNo = certificateSerialNo; 95 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 96 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 97 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 98 } 99 100 public static class QueryParkingFeeRequest { 101 @SerializedName("out_serial_number") 102 public String outSerialNumber; 103 104 @SerializedName("plate_number") 105 public String plateNumber; 106 107 @SerializedName("out_parking_id") 108 public String outParkingId; 109 } 110 111 public static class QueryParkingFeeResponse { 112 @SerializedName("code") 113 public String code; 114 115 @SerializedName("message") 116 public String message; 117 118 @SerializedName("total_amount") 119 public Long totalAmount; 120 121 @SerializedName("parking_timestamp") 122 public Long parkingTimestamp; 123 124 @SerializedName("parking_state") 125 public ParkingState parkingState; 126 127 @SerializedName("pay_state") 128 public PayStatus payState; 129 130 @SerializedName("allowed_exit_timestamp") 131 public Long allowedExitTimestamp; 132 133 @SerializedName("next_raise_price") 134 public Long nextRaisePrice; 135 136 @SerializedName("next_raise_timestamp") 137 public Long nextRaiseTimestamp; 138 139 @SerializedName("payable_amount") 140 public Long payableAmount; 141 142 @SerializedName("paid_amount") 143 public Long paidAmount; 144 } 145 146 public enum ParkingState { 147 @SerializedName("PARKING_STATE_UNKNOWN") 148 PARKING_STATE_UNKNOWN, 149 @SerializedName("PARKING_STATE_ENTERED") 150 PARKING_STATE_ENTERED, 151 @SerializedName("PARKING_STATE_EXIT_GATE") 152 PARKING_STATE_EXIT_GATE, 153 @SerializedName("PARKING_STATE_EXITED") 154 PARKING_STATE_EXITED, 155 @SerializedName("PARKING_STATE_UNEXPECTED_CLOSE") 156 PARKING_STATE_UNEXPECTED_CLOSE 157 } 158 159 public enum PayStatus { 160 @SerializedName("PAY_STATUS_UNKNOWN") 161 PAY_STATUS_UNKNOWN, 162 @SerializedName("PAY_STATUS_UNPAID") 163 PAY_STATUS_UNPAID, 164 @SerializedName("PAY_STATUS_PAID") 165 PAY_STATUS_PAID 166 } 167 168} 169
需配合微信支付工具库 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 := &QueryParkingFeeRequest{ 27 OutSerialNumber: wxpay_utility.String("PARK20260423001"), 28 PlateNumber: wxpay_utility.String("粤B12345"), 29 OutParkingId: wxpay_utility.String("lot_sz_tencent_001"), 30 } 31 32 response, err := QueryParkingFee(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 QueryParkingFee(config *wxpay_utility.MchConfig, request *QueryParkingFeeRequest) (response *QueryParkingFeeResponse, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "POST" 47 path = "/v3/parking/reminders/parking-fee" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 reqBody, err := json.Marshal(request) 55 if err != nil { 56 return nil, err 57 } 58 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 59 if err != nil { 60 return nil, err 61 } 62 httpRequest.Header.Set("Accept", "application/json") 63 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 64 httpRequest.Header.Set("Content-Type", "application/json") 65 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 66 if err != nil { 67 return nil, err 68 } 69 httpRequest.Header.Set("Authorization", authorization) 70 71 client := &http.Client{} 72 httpResponse, err := client.Do(httpRequest) 73 if err != nil { 74 return nil, err 75 } 76 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 77 if err != nil { 78 return nil, err 79 } 80 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 81 // 2XX 成功,验证应答签名 82 err = wxpay_utility.ValidateResponse( 83 config.WechatPayPublicKeyId(), 84 config.WechatPayPublicKey(), 85 &httpResponse.Header, 86 respBody, 87 ) 88 if err != nil { 89 return nil, err 90 } 91 response := &QueryParkingFeeResponse{} 92 if err := json.Unmarshal(respBody, response); err != nil { 93 return nil, err 94 } 95 96 return response, nil 97 } else { 98 return nil, wxpay_utility.NewApiException( 99 httpResponse.StatusCode, 100 httpResponse.Header, 101 respBody, 102 ) 103 } 104} 105 106type QueryParkingFeeRequest struct { 107 OutSerialNumber *string `json:"out_serial_number,omitempty"` 108 PlateNumber *string `json:"plate_number,omitempty"` 109 OutParkingId *string `json:"out_parking_id,omitempty"` 110} 111 112type QueryParkingFeeResponse struct { 113 Code *string `json:"code,omitempty"` 114 Message *string `json:"message,omitempty"` 115 TotalAmount *int64 `json:"total_amount,omitempty"` 116 ParkingTimestamp *int64 `json:"parking_timestamp,omitempty"` 117 ParkingState *ParkingState `json:"parking_state,omitempty"` 118 PayState *PayStatus `json:"pay_state,omitempty"` 119 AllowedExitTimestamp *int64 `json:"allowed_exit_timestamp,omitempty"` 120 NextRaisePrice *int64 `json:"next_raise_price,omitempty"` 121 NextRaiseTimestamp *int64 `json:"next_raise_timestamp,omitempty"` 122 PayableAmount *int64 `json:"payable_amount,omitempty"` 123 PaidAmount *int64 `json:"paid_amount,omitempty"` 124} 125 126type ParkingState string 127 128func (e ParkingState) Ptr() *ParkingState { 129 return &e 130} 131 132const ( 133 PARKINGSTATE_PARKING_STATE_UNKNOWN ParkingState = "PARKING_STATE_UNKNOWN" 134 PARKINGSTATE_PARKING_STATE_ENTERED ParkingState = "PARKING_STATE_ENTERED" 135 PARKINGSTATE_PARKING_STATE_EXIT_GATE ParkingState = "PARKING_STATE_EXIT_GATE" 136 PARKINGSTATE_PARKING_STATE_EXITED ParkingState = "PARKING_STATE_EXITED" 137 PARKINGSTATE_PARKING_STATE_UNEXPECTED_CLOSE ParkingState = "PARKING_STATE_UNEXPECTED_CLOSE" 138) 139 140type PayStatus string 141 142func (e PayStatus) Ptr() *PayStatus { 143 return &e 144} 145 146const ( 147 PAYSTATUS_PAY_STATUS_UNKNOWN PayStatus = "PAY_STATUS_UNKNOWN" 148 PAYSTATUS_PAY_STATUS_UNPAID PayStatus = "PAY_STATUS_UNPAID" 149 PAYSTATUS_PAY_STATUS_PAID PayStatus = "PAY_STATUS_PAID" 150) 151
应答参数
200 OK
code 选填 string(32)
【响应码】 仅接口调用失败时返回;调用成功时不返回此字段。失败时返回错误码字符串,具体见接口错误码列表。
message 选填 string(256)
【返回信息】 仅接口调用失败时返回;调用成功时不返回此字段。失败时返回错误原因描述。
total_amount 选填 integer
【当前总费用】 查询成功且存在停车单时返回,单位为分。
parking_timestamp 选填 integer
【已停时长】 查询成功且存在停车单时返回,单位为秒。
parking_state 选填 string
【停车状态】 查询成功且存在停车单时返回。
可选取值
PARKING_STATE_UNKNOWN: 未知PARKING_STATE_ENTERED: 已入场PARKING_STATE_EXIT_GATE: 到闸口PARKING_STATE_EXITED: 已离场PARKING_STATE_UNEXPECTED_CLOSE: 异常关单
pay_state 选填 string
【支付状态】 查询成功且停车单已有支付记录时返回。
可选取值
PAY_STATUS_UNKNOWN: 未知PAY_STATUS_UNPAID: 未支付PAY_STATUS_PAID: 已支付
allowed_exit_timestamp 选填 integer
【免费待出场时间】 查询成功且车场配置了免费出场时段时返回,单位为秒。
next_raise_price 选填 integer
【下一次跳价价格】 查询成功且车场开启跳价提醒且未触达封顶时返回,单位为分。
next_raise_timestamp 选填 integer
【下一次跳价时间】 查询成功且车场开启跳价提醒且未触达封顶时返回,秒级时间戳。
payable_amount 选填 integer
【应付金额】 查询成功且存在应付费用时返回,单位为分。
paid_amount 选填 integer
【已付金额】 查询成功且存在已支付记录时返回,单位为分。
应答示例
200 OK
1{ 2 "code" : "PARAM_ERROR", 3 "message" : "参数错误", 4 "total_amount" : 1, 5 "parking_timestamp" : 1, 6 "parking_state" : "PARKING_STATE_UNKNOWN", 7 "pay_state" : "PAY_STATUS_UNKNOWN", 8 "allowed_exit_timestamp" : 1, 9 "next_raise_price" : 1, 10 "next_raise_timestamp" : 1, 11 "payable_amount" : 1, 12 "paid_amount" : 1 13} 14
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
