查询预约还款记录
更新时间:2026.01.14商户可调用该接口来查询之前发起的预约还款记录
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/credit-repayment/partner/schedule-records/{out_record_id}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
out_record_id 必填 string(32)
【商户侧预约还款记录ID】 预约还款时传入的商户侧预约还款记录ID
query 查询参数
contract_id 必填 string(64)
【还款协议ID】 商户与用户签约成功后得到的还款协议ID
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/credit-repayment/partner/schedule-records/DeductOrder123456?contract_id=20251105000000123456789 \ 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 PartnerQueryScheduleRecord { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/credit-repayment/partner/schedule-records/{out_record_id}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 PartnerQueryScheduleRecord client = new PartnerQueryScheduleRecord( 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 PartnerQueryScheduleRecordRequest request = new PartnerQueryScheduleRecordRequest(); 41 request.outRecordId = "DeductOrder123456"; 42 request.contractId = "20251105000000123456789"; 43 try { 44 ScheduleRecord response = client.run(request); 45 // TODO: 请求成功,继续业务逻辑 46 System.out.println(response); 47 } catch (WXPayUtility.ApiException e) { 48 // TODO: 请求失败,根据状态码执行不同的逻辑 49 e.printStackTrace(); 50 } 51 } 52 53 public ScheduleRecord run(PartnerQueryScheduleRecordRequest request) { 54 String uri = PATH; 55 uri = uri.replace("{out_record_id}", WXPayUtility.urlEncode(request.outRecordId)); 56 Map<String, Object> args = new HashMap<>(); 57 args.put("contract_id", request.contractId); 58 String queryString = WXPayUtility.urlEncode(args); 59 if (!queryString.isEmpty()) { 60 uri = uri + "?" + queryString; 61 } 62 63 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 64 reqBuilder.addHeader("Accept", "application/json"); 65 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 66 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 67 reqBuilder.method(METHOD, null); 68 Request httpRequest = reqBuilder.build(); 69 70 // 发送HTTP请求 71 OkHttpClient client = new OkHttpClient.Builder().build(); 72 try (Response httpResponse = client.newCall(httpRequest).execute()) { 73 String respBody = WXPayUtility.extractBody(httpResponse); 74 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 75 // 2XX 成功,验证应答签名 76 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 77 httpResponse.headers(), respBody); 78 79 // 从HTTP应答报文构建返回数据 80 return WXPayUtility.fromJson(respBody, ScheduleRecord.class); 81 } else { 82 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 83 } 84 } catch (IOException e) { 85 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 86 } 87 } 88 89 private final String mchid; 90 private final String certificateSerialNo; 91 private final PrivateKey privateKey; 92 private final String wechatPayPublicKeyId; 93 private final PublicKey wechatPayPublicKey; 94 95 public PartnerQueryScheduleRecord(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 96 this.mchid = mchid; 97 this.certificateSerialNo = certificateSerialNo; 98 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 99 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 100 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 101 } 102 103 public static class PartnerQueryScheduleRecordRequest { 104 @SerializedName("out_record_id") 105 @Expose(serialize = false) 106 public String outRecordId; 107 108 @SerializedName("contract_id") 109 @Expose(serialize = false) 110 public String contractId; 111 } 112 113 public static class ScheduleRecord { 114 @SerializedName("out_record_id") 115 public String outRecordId; 116 117 @SerializedName("appid") 118 public String appid; 119 120 @SerializedName("sub_appid") 121 public String subAppid; 122 123 @SerializedName("contract_id") 124 public String contractId; 125 126 @SerializedName("repayment_amount") 127 public String repaymentAmount; 128 129 @SerializedName("min_repayment_amount") 130 public String minRepaymentAmount; 131 132 @SerializedName("repayment_date") 133 public String repaymentDate; 134 135 @SerializedName("openid") 136 public String openid; 137 } 138 139} 140
需配合微信支付工具库 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) 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 := &PartnerQueryScheduleRecordRequest{ 27 OutRecordId: wxpay_utility.String("DeductOrder123456"), 28 ContractId: wxpay_utility.String("20251105000000123456789"), 29 } 30 31 response, err := PartnerQueryScheduleRecord(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 PartnerQueryScheduleRecord(config *wxpay_utility.MchConfig, request *PartnerQueryScheduleRecordRequest) (response *ScheduleRecord, err error) { 43 const ( 44 host = "https://api.mch.weixin.qq.com" 45 method = "GET" 46 path = "/v3/credit-repayment/partner/schedule-records/{out_record_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, "{out_record_id}", url.PathEscape(*request.OutRecordId), -1) 54 query := reqUrl.Query() 55 if request.ContractId != nil { 56 query.Add("contract_id", *request.ContractId) 57 } 58 reqUrl.RawQuery = query.Encode() 59 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 60 if err != nil { 61 return nil, err 62 } 63 httpRequest.Header.Set("Accept", "application/json") 64 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 65 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 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 := &ScheduleRecord{} 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 PartnerQueryScheduleRecordRequest struct { 107 OutRecordId *string `json:"out_record_id,omitempty"` 108 ContractId *string `json:"contract_id,omitempty"` 109} 110 111func (o *PartnerQueryScheduleRecordRequest) MarshalJSON() ([]byte, error) { 112 type Alias PartnerQueryScheduleRecordRequest 113 a := &struct { 114 OutRecordId *string `json:"out_record_id,omitempty"` 115 ContractId *string `json:"contract_id,omitempty"` 116 *Alias 117 }{ 118 // 序列化时移除非 Body 字段 119 OutRecordId: nil, 120 ContractId: nil, 121 Alias: (*Alias)(o), 122 } 123 return json.Marshal(a) 124} 125 126type ScheduleRecord struct { 127 OutRecordId *string `json:"out_record_id,omitempty"` 128 Appid *string `json:"appid,omitempty"` 129 SubAppid *string `json:"sub_appid,omitempty"` 130 ContractId *string `json:"contract_id,omitempty"` 131 RepaymentAmount *string `json:"repayment_amount,omitempty"` 132 MinRepaymentAmount *string `json:"min_repayment_amount,omitempty"` 133 RepaymentDate *string `json:"repayment_date,omitempty"` 134 Openid *string `json:"openid,omitempty"` 135} 136
应答参数
200 OK
out_record_id 必填 string(32)
【商户侧预约还款记录ID】 预约还款时传入的商户侧预约还款记录ID
appid 必填 string(32)
【商户AppID】 商户在微信申请的公众号或移动应用AppID,与服务商商户号绑定。可参考服务商模式开发必要参数说明
sub_appid 选填 string(32)
【子商户AppID】 与子商户号绑定的AppID。可参考服务商模式开发必要参数说明
contract_id 必填 string(64)
【还款协议ID】 商户与用户签约的还款协议ID
repayment_amount 必填 string
【应还款金额】 单位分
min_repayment_amount 必填 string
【最低还款金额】 单位分
repayment_date 必填 string
【还款日期】 本次还款的日期
openid 必填 string(128)
【用户标识】 用户在商户AppID下的唯一标识
应答示例
200 OK
1{ 2 "out_record_id" : "1234567abcde", 3 "appid" : "wxcbda96de0b165486", 4 "sub_appid" : "wxcbda96de0b165489", 5 "contract_id" : "20251105000000123456789", 6 "repayment_amount" : "10000", 7 "min_repayment_amount" : "10000", 8 "repayment_date" : "2025-11-08", 9 "openid" : "oUpF8uMuAJO_M2pxb1Q9zNjWeS6o" 10} 11
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示

