查询在途异常资金付款结果
更新时间:2025.06.26资金交易异常未能及时完成时,可通过该接口快速查询在途异常资金付款流程状态,支持查看付款金额、入账账户、处理进度等信息。
注:接口限频100次/秒。
接口说明
支持商户:【平台商户】 【普通服务商】
请求方式:【GET】/v3/abnormal-fund-processing/receipts/{receipt_id}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
receipt_id 必填 string(64)
【微信支付在途异常资金付款单号】 微信支付返回的在途异常资金付款单号
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/abnormal-fund-processing/receipts/0100011742874700562078230000 \ 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 GetReceipt { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/abnormal-fund-processing/receipts/{receipt_id}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 GetReceipt client = new GetReceipt( 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 GetReceiptRequest request = new GetReceiptRequest(); 41 request.receiptId = "0100011742874700562078230000"; 42 try { 43 AbnormalFundReceipt response = client.run(request); 44 // TODO: 请求成功,继续业务逻辑 45 System.out.println(response); 46 } catch (WXPayUtility.ApiException e) { 47 // TODO: 请求失败,根据状态码执行不同的逻辑 48 e.printStackTrace(); 49 } 50 } 51 52 public AbnormalFundReceipt run(GetReceiptRequest request) { 53 String uri = PATH; 54 uri = uri.replace("{receipt_id}", WXPayUtility.urlEncode(request.receiptId)); 55 56 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 57 reqBuilder.addHeader("Accept", "application/json"); 58 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 59 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 60 reqBuilder.method(METHOD, null); 61 Request httpRequest = reqBuilder.build(); 62 63 // 发送HTTP请求 64 OkHttpClient client = new OkHttpClient.Builder().build(); 65 try (Response httpResponse = client.newCall(httpRequest).execute()) { 66 String respBody = WXPayUtility.extractBody(httpResponse); 67 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 68 // 2XX 成功,验证应答签名 69 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 70 httpResponse.headers(), respBody); 71 72 // 从HTTP应答报文构建返回数据 73 return WXPayUtility.fromJson(respBody, AbnormalFundReceipt.class); 74 } else { 75 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 76 } 77 } catch (IOException e) { 78 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 79 } 80 } 81 82 private final String mchid; 83 private final String certificateSerialNo; 84 private final PrivateKey privateKey; 85 private final String wechatPayPublicKeyId; 86 private final PublicKey wechatPayPublicKey; 87 88 public GetReceipt(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 89 this.mchid = mchid; 90 this.certificateSerialNo = certificateSerialNo; 91 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 92 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 93 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 94 } 95 96 public static class GetReceiptRequest { 97 @SerializedName("receipt_id") 98 @Expose(serialize = false) 99 public String receiptId; 100 } 101 102 public static class AbnormalFundReceipt { 103 @SerializedName("product_name") 104 public String productName; 105 106 @SerializedName("receipt_id") 107 public String receiptId; 108 109 @SerializedName("transfer_amount") 110 public Amount transferAmount; 111 112 @SerializedName("receipt_state") 113 public ReceiptState receiptState; 114 115 @SerializedName("create_time") 116 public String createTime; 117 118 @SerializedName("last_update_time") 119 public String lastUpdateTime; 120 121 @SerializedName("instruction") 122 public Instruction instruction; 123 } 124 125 public static class Amount { 126 @SerializedName("total") 127 public Long total; 128 129 @SerializedName("currency") 130 public Currency currency; 131 } 132 133 public enum ReceiptState { 134 @SerializedName("RECEIPT_STATE_PENDING") 135 RECEIPT_STATE_PENDING, 136 @SerializedName("RECEIPT_STATE_PROGRESS") 137 RECEIPT_STATE_PROGRESS, 138 @SerializedName("RECEIPT_STATE_COMPLETED") 139 RECEIPT_STATE_COMPLETED 140 } 141 142 public static class Instruction { 143 @SerializedName("out_instruction_no") 144 public String outInstructionNo; 145 146 @SerializedName("commander") 147 public Commander commander; 148 149 @SerializedName("transfer_mode") 150 public TransferModeType transferMode; 151 152 @SerializedName("receiver") 153 public Receiver receiver; 154 155 @SerializedName("instruction_state") 156 public InstructionState instructionState; 157 158 @SerializedName("create_time") 159 public String createTime; 160 161 @SerializedName("success_time") 162 public String successTime; 163 164 @SerializedName("notify_url") 165 public String notifyUrl; 166 } 167 168 public enum Currency { 169 @SerializedName("CNY") 170 CNY 171 } 172 173 public static class Commander { 174 @SerializedName("operator") 175 public Operator operator; 176 177 @SerializedName("mchid") 178 public String mchid; 179 } 180 181 public enum TransferModeType { 182 @SerializedName("TRANSFER_TO_ORIGINAL_RECEIVE_USER") 183 TRANSFER_TO_ORIGINAL_RECEIVE_USER, 184 @SerializedName("TRANSFER_TO_ORIGINAL_RECEIVE_MERCHANT") 185 TRANSFER_TO_ORIGINAL_RECEIVE_MERCHANT, 186 @SerializedName("TRANSFER_TO_SPECIFIED_RECEIVE_MERCHANT") 187 TRANSFER_TO_SPECIFIED_RECEIVE_MERCHANT 188 } 189 190 public static class Receiver { 191 @SerializedName("account_type") 192 public String accountType; 193 194 @SerializedName("openid") 195 public String openid; 196 197 @SerializedName("appid") 198 public String appid; 199 200 @SerializedName("mchid") 201 public String mchid; 202 } 203 204 public enum InstructionState { 205 @SerializedName("INSTRUCTION_STATE_PENDING") 206 INSTRUCTION_STATE_PENDING, 207 @SerializedName("INSTRUCTION_STATE_IN_PROGRESS") 208 INSTRUCTION_STATE_IN_PROGRESS, 209 @SerializedName("INSTRUCTION_STATE_CLOSED") 210 INSTRUCTION_STATE_CLOSED, 211 @SerializedName("INSTRUCTION_STATE_SUCCESS") 212 INSTRUCTION_STATE_SUCCESS 213 } 214 215 public enum Operator { 216 @SerializedName("MERCHANT") 217 MERCHANT 218 } 219 220} 221
需配合微信支付工具库 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 "strings" 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 := &GetReceiptRequest{ 28 ReceiptId: wxpay_utility.String("0100011742874700562078230000"), 29 } 30 31 response, err := GetReceipt(config, request) 32 if err != nil { 33 fmt.Printf("请求失败: %+v\n", err) 34 // TODO: 请求失败,根据状态码执行不同的处理 35 return 36 } 37 38 // TODO: 请求成功,继续业务逻辑 39 fmt.Printf("请求成功: %+v\n", response) 40} 41 42func GetReceipt(config *wxpay_utility.MchConfig, request *GetReceiptRequest) (response *AbnormalFundReceipt, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/abnormal-fund-processing/receipts/{receipt_id}" 47 ) 48 49 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 50 if err != nil { 51 return nil, err 52 } 53 reqUrl.Path = strings.Replace(reqUrl.Path, "{receipt_id}", url.PathEscape(*request.ReceiptId), -1) 54 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 55 if err != nil { 56 return nil, err 57 } 58 httpRequest.Header.Set("Accept", "application/json") 59 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 60 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 61 if err != nil { 62 return nil, err 63 } 64 httpRequest.Header.Set("Authorization", authorization) 65 66 client := &http.Client{} 67 httpResponse, err := client.Do(httpRequest) 68 if err != nil { 69 return nil, err 70 } 71 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 72 if err != nil { 73 return nil, err 74 } 75 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 76 // 2XX 成功,验证应答签名 77 err = wxpay_utility.ValidateResponse( 78 config.WechatPayPublicKeyId(), 79 config.WechatPayPublicKey(), 80 &httpResponse.Header, 81 respBody, 82 ) 83 if err != nil { 84 return nil, err 85 } 86 response := &AbnormalFundReceipt{} 87 if err := json.Unmarshal(respBody, response); err != nil { 88 return nil, err 89 } 90 91 return response, nil 92 } else { 93 return nil, wxpay_utility.NewApiException( 94 httpResponse.StatusCode, 95 httpResponse.Header, 96 respBody, 97 ) 98 } 99} 100 101type GetReceiptRequest struct { 102 ReceiptId *string `json:"receipt_id,omitempty"` 103} 104 105func (o *GetReceiptRequest) MarshalJSON() ([]byte, error) { 106 type Alias GetReceiptRequest 107 a := &struct { 108 ReceiptId *string `json:"receipt_id,omitempty"` 109 *Alias 110 }{ 111 // 序列化时移除非 Body 字段 112 ReceiptId: nil, 113 Alias: (*Alias)(o), 114 } 115 return json.Marshal(a) 116} 117 118type AbnormalFundReceipt struct { 119 ProductName *string `json:"product_name,omitempty"` 120 ReceiptId *string `json:"receipt_id,omitempty"` 121 TransferAmount *Amount `json:"transfer_amount,omitempty"` 122 ReceiptState *ReceiptState `json:"receipt_state,omitempty"` 123 CreateTime *time.Time `json:"create_time,omitempty"` 124 LastUpdateTime *time.Time `json:"last_update_time,omitempty"` 125 Instruction *Instruction `json:"instruction,omitempty"` 126} 127 128type Amount struct { 129 Total *int64 `json:"total,omitempty"` 130 Currency *Currency `json:"currency,omitempty"` 131} 132 133type ReceiptState string 134 135func (e ReceiptState) Ptr() *ReceiptState { 136 return &e 137} 138 139const ( 140 RECEIPTSTATE_RECEIPT_STATE_PENDING ReceiptState = "RECEIPT_STATE_PENDING" 141 RECEIPTSTATE_RECEIPT_STATE_PROGRESS ReceiptState = "RECEIPT_STATE_PROGRESS" 142 RECEIPTSTATE_RECEIPT_STATE_COMPLETED ReceiptState = "RECEIPT_STATE_COMPLETED" 143) 144 145type Instruction struct { 146 OutInstructionNo *string `json:"out_instruction_no,omitempty"` 147 Commander *Commander `json:"commander,omitempty"` 148 TransferMode *TransferModeType `json:"transfer_mode,omitempty"` 149 Receiver *Receiver `json:"receiver,omitempty"` 150 InstructionState *InstructionState `json:"instruction_state,omitempty"` 151 CreateTime *time.Time `json:"create_time,omitempty"` 152 SuccessTime *time.Time `json:"success_time,omitempty"` 153 NotifyUrl *string `json:"notify_url,omitempty"` 154} 155 156type Currency string 157 158func (e Currency) Ptr() *Currency { 159 return &e 160} 161 162const ( 163 CURRENCY_CNY Currency = "CNY" 164) 165 166type Commander struct { 167 Operator *Operator `json:"operator,omitempty"` 168 Mchid *string `json:"mchid,omitempty"` 169} 170 171type TransferModeType string 172 173func (e TransferModeType) Ptr() *TransferModeType { 174 return &e 175} 176 177const ( 178 TRANSFERMODETYPE_TRANSFER_TO_ORIGINAL_RECEIVE_USER TransferModeType = "TRANSFER_TO_ORIGINAL_RECEIVE_USER" 179 TRANSFERMODETYPE_TRANSFER_TO_ORIGINAL_RECEIVE_MERCHANT TransferModeType = "TRANSFER_TO_ORIGINAL_RECEIVE_MERCHANT" 180 TRANSFERMODETYPE_TRANSFER_TO_SPECIFIED_RECEIVE_MERCHANT TransferModeType = "TRANSFER_TO_SPECIFIED_RECEIVE_MERCHANT" 181) 182 183type Receiver struct { 184 AccountType *string `json:"account_type,omitempty"` 185 Openid *string `json:"openid,omitempty"` 186 Appid *string `json:"appid,omitempty"` 187 Mchid *string `json:"mchid,omitempty"` 188} 189 190type InstructionState string 191 192func (e InstructionState) Ptr() *InstructionState { 193 return &e 194} 195 196const ( 197 INSTRUCTIONSTATE_INSTRUCTION_STATE_PENDING InstructionState = "INSTRUCTION_STATE_PENDING" 198 INSTRUCTIONSTATE_INSTRUCTION_STATE_IN_PROGRESS InstructionState = "INSTRUCTION_STATE_IN_PROGRESS" 199 INSTRUCTIONSTATE_INSTRUCTION_STATE_CLOSED InstructionState = "INSTRUCTION_STATE_CLOSED" 200 INSTRUCTIONSTATE_INSTRUCTION_STATE_SUCCESS InstructionState = "INSTRUCTION_STATE_SUCCESS" 201) 202 203type Operator string 204 205func (e Operator) Ptr() *Operator { 206 return &e 207} 208 209const ( 210 OPERATOR_MERCHANT Operator = "MERCHANT" 211) 212
应答参数
200 OK
product_name 必填 string(64)
【产品名称】 发起在途异常资金付款的业务产品名称
receipt_id 必填 string(64)
【微信支付在途异常资金付款单号】 微信支付在途异常资金付款单号
transfer_amount 必填 object
【金额】 付款金额信息
| 属性 | |
total 必填 integer 【总金额】 在途异常资金付款总金额,单位为分,整型。 currency 必填 string 【货币类型】 固定返回:CNY,代表人民币。 可选取值
|
receipt_state 必填 string
【在途异常资金付款状态】 当前单据处理进度
可选取值
RECEIPT_STATE_PENDING: 待处理RECEIPT_STATE_PROGRESS: 处理中RECEIPT_STATE_COMPLETED: 处理成功
create_time 选填 string(64)
【在途异常资金付款单据创建时间】 微信支付在途异常资金付款单据的创建时间,遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。
last_update_time 选填 string(64)
【在途异常资金付款单据更新时间】 微信支付在途异常资金付款单据的最新更新时间,遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。
instruction 选填 object
【在途异常资金付款指令信息】 在途异常资金付款指令信息,仅当 receipt_state = RECEIPT_STATE_PROGRESS 或 receipt_state = RECEIPT_STATE_COMPLETED 且当前付款操作由商户发起时才返回。
| 属性 | |||||||||
out_instruction_no 必填 string(64) 【商户侧指令编号】 商户侧指令编号 commander 必填 object 【在途异常资金付款指令的发起方】 在途异常资金付款指令的发起方
transfer_mode 必填 string 【付款方式】 资金处理规则 可选取值
receiver 选填 object 【收款方】 收款方帐号信息仅在以下情况下返回:
instruction_state 必填 string 【在途异常资金付款指令状态】 在途异常资金付款指令状态 可选取值
create_time 选填 string(64) 【在途异常资金付款指令创建时间】 在途异常资金付款指令的创建时间,遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。 success_time 选填 string(64) 【入账成功时间】 在途异常资金付款指令的入账时间,遵循rfc3339标准格式:yyyy-MM-DDTHH:mm:ss+TIMEZONE。仅当 instruction_state = INSTRUCTION_STATE_SUCCESS 时返回。 notify_url 必填 string(255) 【回调通知地址】 回调通知地址,只支持HTTPS协议,需为外网可访问的URL,不能携带查询参数。设置后,在途异常资金的付款结果会通过该URL通知商户。 |
应答示例
200 OK
查询在途异常资金付款结果
1{ 2 "product_name" : "C2C", 3 "receipt_id" : "0100011742874700562078230000", 4 "transfer_amount" : { 5 "total" : 100, 6 "currency" : "CNY" 7 }, 8 "receipt_state" : "RECEIPT_STATE_PENDING", 9 "create_time" : "2023-10-01T12:34:56+08:00", 10 "last_update_time" : "2023-10-01T12:34:56+08:00", 11 "instruction" : { 12 "out_instruction_no" : "1200002", 13 "commander" : { 14 "operator" : "MERCHANT", 15 "mchid" : "990055040" 16 }, 17 "transfer_mode" : "TRANSFER_TO_ORIGINAL_RECEIVE_USER", 18 "receiver" : { 19 "account_type" : "OTHERS", 20 "openid" : "eoCuiA7RW33Tc3jtz_5CNLegC9kN0", 21 "appid" : "wxf636efh567hg4356" 22 }, 23 "instruction_state" : "INSTRUCTION_STATE_PENDING", 24 "create_time" : "2023-10-01T12:34:56+08:00", 25 "success_time" : "2023-10-01T12:34:56+08:00", 26 "notify_url" : "https://weixin.qq.com" 27 } 28} 29
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示

