查询电子发票
更新时间:2025.09.03商户调用【开具电子发票】接口或【冲红电子发票】接口或【将电子发票插入微信用户卡包】接口成功后,应调用本接口查询电子发票开具/冲红/插卡结果,并获取已开具/冲红/插卡的电子发票信息。
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/new-tax-control-fapiao/fapiao-applications/{fapiao_apply_id}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
fapiao_apply_id 必填 string(32)
【发票申请单号】 开票时指定的发票申请单号
query 查询参数
sub_mchid 必填 string(32)
【子商户号】 微信支付分配的子商户号,具体请参考服务商模式开发必要参数说明
fapiao_id 选填 string(32)
【商户发票单号】 开票时指定的商户发票单号,唯一标识一张电子发票,若指定了该字段,则只会返回其对应的电子发票信息
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/new-tax-control-fapiao/fapiao-applications/4200000444201910177461284488?sub_mchid=1900000109&fapiao_id=20200701123456 \ 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 GetFapiaoApplications { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/new-tax-control-fapiao/fapiao-applications/{fapiao_apply_id}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 GetFapiaoApplications client = new GetFapiaoApplications( 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 GetFapiaoApplicationsRequest request = new GetFapiaoApplicationsRequest(); 41 request.fapiaoApplyId = "4200000444201910177461284488"; 42 request.subMchid = "1900000109"; 43 request.fapiaoId = "20200701123456"; 44 try { 45 FapiaoApplicationsEntity 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 FapiaoApplicationsEntity run(GetFapiaoApplicationsRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{fapiao_apply_id}", WXPayUtility.urlEncode(request.fapiaoApplyId)); 57 Map<String, Object> args = new HashMap<>(); 58 args.put("sub_mchid", request.subMchid); 59 args.put("fapiao_id", request.fapiaoId); 60 String queryString = WXPayUtility.urlEncode(args); 61 if (!queryString.isEmpty()) { 62 uri = uri + "?" + queryString; 63 } 64 65 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 66 reqBuilder.addHeader("Accept", "application/json"); 67 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 68 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 69 reqBuilder.method(METHOD, null); 70 Request httpRequest = reqBuilder.build(); 71 72 // 发送HTTP请求 73 OkHttpClient client = new OkHttpClient.Builder().build(); 74 try (Response httpResponse = client.newCall(httpRequest).execute()) { 75 String respBody = WXPayUtility.extractBody(httpResponse); 76 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 77 // 2XX 成功,验证应答签名 78 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 79 httpResponse.headers(), respBody); 80 81 // 从HTTP应答报文构建返回数据 82 return WXPayUtility.fromJson(respBody, FapiaoApplicationsEntity.class); 83 } else { 84 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 85 } 86 } catch (IOException e) { 87 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 88 } 89 } 90 91 private final String mchid; 92 private final String certificateSerialNo; 93 private final PrivateKey privateKey; 94 private final String wechatPayPublicKeyId; 95 private final PublicKey wechatPayPublicKey; 96 97 public GetFapiaoApplications(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 98 this.mchid = mchid; 99 this.certificateSerialNo = certificateSerialNo; 100 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 101 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 102 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 103 } 104 105 public static class GetFapiaoApplicationsRequest { 106 @SerializedName("sub_mchid") 107 @Expose(serialize = false) 108 public String subMchid; 109 110 @SerializedName("fapiao_apply_id") 111 @Expose(serialize = false) 112 public String fapiaoApplyId; 113 114 @SerializedName("fapiao_id") 115 @Expose(serialize = false) 116 public String fapiaoId; 117 } 118 119 public static class FapiaoApplicationsEntity { 120 @SerializedName("total_count") 121 public Long totalCount; 122 123 @SerializedName("fapiao_information") 124 public List<FapiaoEntity> fapiaoInformation; 125 } 126 127 public static class FapiaoEntity { 128 @SerializedName("fapiao_id") 129 public String fapiaoId; 130 131 @SerializedName("status") 132 public Status status; 133 134 @SerializedName("blue_fapiao") 135 public FapiaoInfo blueFapiao; 136 137 @SerializedName("red_fapiao") 138 public FapiaoInfo redFapiao; 139 140 @SerializedName("card_information") 141 public CardInfo cardInformation; 142 143 @SerializedName("total_amount") 144 public Long totalAmount; 145 146 @SerializedName("tax_amount") 147 public Long taxAmount; 148 149 @SerializedName("amount") 150 public Long amount; 151 152 @SerializedName("seller_information") 153 public SellerInfo sellerInformation; 154 155 @SerializedName("buyer_information") 156 public UserTitleEntity buyerInformation; 157 158 @SerializedName("extra_information") 159 public ExtraInfo extraInformation; 160 161 @SerializedName("items") 162 public List<FapiaoItem> items; 163 164 @SerializedName("remark") 165 public String remark; 166 167 @SerializedName("fapiao_error_code") 168 public String fapiaoErrorCode; 169 170 @SerializedName("fapiao_error_message") 171 public String fapiaoErrorMessage; 172 } 173 174 public enum Status { 175 @SerializedName("ISSUE_ACCEPTED") 176 ISSUE_ACCEPTED, 177 @SerializedName("ISSUED") 178 ISSUED, 179 @SerializedName("REVERSE_ACCEPTED") 180 REVERSE_ACCEPTED, 181 @SerializedName("REVERSED") 182 REVERSED, 183 @SerializedName("ISSUE_FAILED") 184 ISSUE_FAILED, 185 @SerializedName("REVERSE_FAILED") 186 REVERSE_FAILED 187 } 188 189 public static class FapiaoInfo { 190 @SerializedName("fapiao_code") 191 public String fapiaoCode; 192 193 @SerializedName("fapiao_number") 194 public String fapiaoNumber; 195 196 @SerializedName("check_code") 197 public String checkCode; 198 199 @SerializedName("password") 200 public String password; 201 202 @SerializedName("fapiao_time") 203 public String fapiaoTime; 204 } 205 206 public static class CardInfo { 207 @SerializedName("card_appid") 208 public String cardAppid; 209 210 @SerializedName("card_openid") 211 public String cardOpenid; 212 213 @SerializedName("card_id") 214 public String cardId; 215 216 @SerializedName("card_code") 217 public String cardCode; 218 219 @SerializedName("card_status") 220 public CardStatus cardStatus; 221 } 222 223 public static class SellerInfo { 224 @SerializedName("name") 225 public String name; 226 227 @SerializedName("taxpayer_id") 228 public String taxpayerId; 229 230 @SerializedName("address") 231 public String address; 232 233 @SerializedName("telephone") 234 public String telephone; 235 236 @SerializedName("bank_name") 237 public String bankName; 238 239 @SerializedName("bank_account") 240 public String bankAccount; 241 } 242 243 public static class UserTitleEntity { 244 @SerializedName("type") 245 public BuyerType type; 246 247 @SerializedName("name") 248 public String name; 249 250 @SerializedName("taxpayer_id") 251 public String taxpayerId; 252 253 @SerializedName("address") 254 public String address; 255 256 @SerializedName("telephone") 257 public String telephone; 258 259 @SerializedName("bank_name") 260 public String bankName; 261 262 @SerializedName("bank_account") 263 public String bankAccount; 264 265 @SerializedName("phone") 266 public String phone; 267 268 @SerializedName("email") 269 public String email; 270 271 @SerializedName("amount") 272 public Long amount; 273 274 @SerializedName("out_trade_no") 275 public String outTradeNo; 276 277 @SerializedName("fapiao_bill_type") 278 public FapiaoBillType fapiaoBillType; 279 280 @SerializedName("user_apply_message") 281 public String userApplyMessage; 282 } 283 284 public static class ExtraInfo { 285 @SerializedName("payee") 286 public String payee; 287 288 @SerializedName("reviewer") 289 public String reviewer; 290 291 @SerializedName("drawer") 292 public String drawer; 293 } 294 295 public static class FapiaoItem { 296 @SerializedName("tax_code") 297 public String taxCode; 298 299 @SerializedName("goods_name") 300 public String goodsName; 301 302 @SerializedName("specification") 303 public String specification; 304 305 @SerializedName("unit") 306 public String unit; 307 308 @SerializedName("quantity") 309 public Long quantity; 310 311 @SerializedName("unit_price") 312 public Long unitPrice; 313 314 @SerializedName("amount") 315 public Long amount; 316 317 @SerializedName("tax_amount") 318 public Long taxAmount; 319 320 @SerializedName("total_amount") 321 public Long totalAmount; 322 323 @SerializedName("tax_rate") 324 public Long taxRate; 325 326 @SerializedName("tax_prefer_mark") 327 public TaxPreferMark taxPreferMark; 328 329 @SerializedName("discount") 330 public Boolean discount; 331 } 332 333 public enum CardStatus { 334 @SerializedName("INSERT_ACCEPTED") 335 INSERT_ACCEPTED, 336 @SerializedName("INSERTED") 337 INSERTED, 338 @SerializedName("DISCARD_ACCEPTED") 339 DISCARD_ACCEPTED, 340 @SerializedName("DISCARDED") 341 DISCARDED 342 } 343 344 public enum BuyerType { 345 @SerializedName("INDIVIDUAL") 346 INDIVIDUAL, 347 @SerializedName("ORGANIZATION") 348 ORGANIZATION 349 } 350 351 public enum FapiaoBillType { 352 @SerializedName("COMM_FAPIAO") 353 COMM_FAPIAO, 354 @SerializedName("VAT_FAPIAO") 355 VAT_FAPIAO 356 } 357 358 public enum TaxPreferMark { 359 @SerializedName("NO_FAVORABLE") 360 NO_FAVORABLE, 361 @SerializedName("OUTSIDE_VAT") 362 OUTSIDE_VAT, 363 @SerializedName("VAT_EXEMPT") 364 VAT_EXEMPT, 365 @SerializedName("NORMAL_ZERO_RATED") 366 NORMAL_ZERO_RATED, 367 @SerializedName("EXPORT_ZERO_RATED") 368 EXPORT_ZERO_RATED 369 } 370 371} 372
需配合微信支付工具库 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 := &GetFapiaoApplicationsRequest{ 27 SubMchid: wxpay_utility.String("1900000109"), 28 FapiaoApplyId: wxpay_utility.String("4200000444201910177461284488"), 29 FapiaoId: wxpay_utility.String("20200701123456"), 30 } 31 32 response, err := GetFapiaoApplications(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 GetFapiaoApplications(config *wxpay_utility.MchConfig, request *GetFapiaoApplicationsRequest) (response *FapiaoApplicationsEntity, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/new-tax-control-fapiao/fapiao-applications/{fapiao_apply_id}" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 reqUrl.Path = strings.Replace(reqUrl.Path, "{fapiao_apply_id}", url.PathEscape(*request.FapiaoApplyId), -1) 55 query := reqUrl.Query() 56 if request.SubMchid != nil { 57 query.Add("sub_mchid", *request.SubMchid) 58 } 59 if request.FapiaoId != nil { 60 query.Add("fapiao_id", *request.FapiaoId) 61 } 62 reqUrl.RawQuery = query.Encode() 63 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 64 if err != nil { 65 return nil, err 66 } 67 httpRequest.Header.Set("Accept", "application/json") 68 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 69 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 70 if err != nil { 71 return nil, err 72 } 73 httpRequest.Header.Set("Authorization", authorization) 74 75 client := &http.Client{} 76 httpResponse, err := client.Do(httpRequest) 77 if err != nil { 78 return nil, err 79 } 80 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 81 if err != nil { 82 return nil, err 83 } 84 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 85 // 2XX 成功,验证应答签名 86 err = wxpay_utility.ValidateResponse( 87 config.WechatPayPublicKeyId(), 88 config.WechatPayPublicKey(), 89 &httpResponse.Header, 90 respBody, 91 ) 92 if err != nil { 93 return nil, err 94 } 95 response := &FapiaoApplicationsEntity{} 96 if err := json.Unmarshal(respBody, response); err != nil { 97 return nil, err 98 } 99 100 return response, nil 101 } else { 102 return nil, wxpay_utility.NewApiException( 103 httpResponse.StatusCode, 104 httpResponse.Header, 105 respBody, 106 ) 107 } 108} 109 110type GetFapiaoApplicationsRequest struct { 111 SubMchid *string `json:"sub_mchid,omitempty"` 112 FapiaoApplyId *string `json:"fapiao_apply_id,omitempty"` 113 FapiaoId *string `json:"fapiao_id,omitempty"` 114} 115 116func (o *GetFapiaoApplicationsRequest) MarshalJSON() ([]byte, error) { 117 type Alias GetFapiaoApplicationsRequest 118 a := &struct { 119 SubMchid *string `json:"sub_mchid,omitempty"` 120 FapiaoApplyId *string `json:"fapiao_apply_id,omitempty"` 121 FapiaoId *string `json:"fapiao_id,omitempty"` 122 *Alias 123 }{ 124 // 序列化时移除非 Body 字段 125 SubMchid: nil, 126 FapiaoApplyId: nil, 127 FapiaoId: nil, 128 Alias: (*Alias)(o), 129 } 130 return json.Marshal(a) 131} 132 133type FapiaoApplicationsEntity struct { 134 TotalCount *int64 `json:"total_count,omitempty"` 135 FapiaoInformation []FapiaoEntity `json:"fapiao_information,omitempty"` 136} 137 138type FapiaoEntity struct { 139 FapiaoId *string `json:"fapiao_id,omitempty"` 140 Status *Status `json:"status,omitempty"` 141 BlueFapiao *FapiaoInfo `json:"blue_fapiao,omitempty"` 142 RedFapiao *FapiaoInfo `json:"red_fapiao,omitempty"` 143 CardInformation *CardInfo `json:"card_information,omitempty"` 144 TotalAmount *int64 `json:"total_amount,omitempty"` 145 TaxAmount *int64 `json:"tax_amount,omitempty"` 146 Amount *int64 `json:"amount,omitempty"` 147 SellerInformation *SellerInfo `json:"seller_information,omitempty"` 148 BuyerInformation *UserTitleEntity `json:"buyer_information,omitempty"` 149 ExtraInformation *ExtraInfo `json:"extra_information,omitempty"` 150 Items []FapiaoItem `json:"items,omitempty"` 151 Remark *string `json:"remark,omitempty"` 152 FapiaoErrorCode *string `json:"fapiao_error_code,omitempty"` 153 FapiaoErrorMessage *string `json:"fapiao_error_message,omitempty"` 154} 155 156type Status string 157 158func (e Status) Ptr() *Status { 159 return &e 160} 161 162const ( 163 STATUS_ISSUE_ACCEPTED Status = "ISSUE_ACCEPTED" 164 STATUS_ISSUED Status = "ISSUED" 165 STATUS_REVERSE_ACCEPTED Status = "REVERSE_ACCEPTED" 166 STATUS_REVERSED Status = "REVERSED" 167 STATUS_ISSUE_FAILED Status = "ISSUE_FAILED" 168 STATUS_REVERSE_FAILED Status = "REVERSE_FAILED" 169) 170 171type FapiaoInfo struct { 172 FapiaoCode *string `json:"fapiao_code,omitempty"` 173 FapiaoNumber *string `json:"fapiao_number,omitempty"` 174 CheckCode *string `json:"check_code,omitempty"` 175 Password *string `json:"password,omitempty"` 176 FapiaoTime *string `json:"fapiao_time,omitempty"` 177} 178 179type CardInfo struct { 180 CardAppid *string `json:"card_appid,omitempty"` 181 CardOpenid *string `json:"card_openid,omitempty"` 182 CardId *string `json:"card_id,omitempty"` 183 CardCode *string `json:"card_code,omitempty"` 184 CardStatus *CardStatus `json:"card_status,omitempty"` 185} 186 187type SellerInfo struct { 188 Name *string `json:"name,omitempty"` 189 TaxpayerId *string `json:"taxpayer_id,omitempty"` 190 Address *string `json:"address,omitempty"` 191 Telephone *string `json:"telephone,omitempty"` 192 BankName *string `json:"bank_name,omitempty"` 193 BankAccount *string `json:"bank_account,omitempty"` 194} 195 196type UserTitleEntity struct { 197 Type *BuyerType `json:"type,omitempty"` 198 Name *string `json:"name,omitempty"` 199 TaxpayerId *string `json:"taxpayer_id,omitempty"` 200 Address *string `json:"address,omitempty"` 201 Telephone *string `json:"telephone,omitempty"` 202 BankName *string `json:"bank_name,omitempty"` 203 BankAccount *string `json:"bank_account,omitempty"` 204 Phone *string `json:"phone,omitempty"` 205 Email *string `json:"email,omitempty"` 206 Amount *int64 `json:"amount,omitempty"` 207 OutTradeNo *string `json:"out_trade_no,omitempty"` 208 FapiaoBillType *FapiaoBillType `json:"fapiao_bill_type,omitempty"` 209 UserApplyMessage *string `json:"user_apply_message,omitempty"` 210} 211 212type ExtraInfo struct { 213 Payee *string `json:"payee,omitempty"` 214 Reviewer *string `json:"reviewer,omitempty"` 215 Drawer *string `json:"drawer,omitempty"` 216} 217 218type FapiaoItem struct { 219 TaxCode *string `json:"tax_code,omitempty"` 220 GoodsName *string `json:"goods_name,omitempty"` 221 Specification *string `json:"specification,omitempty"` 222 Unit *string `json:"unit,omitempty"` 223 Quantity *int64 `json:"quantity,omitempty"` 224 UnitPrice *int64 `json:"unit_price,omitempty"` 225 Amount *int64 `json:"amount,omitempty"` 226 TaxAmount *int64 `json:"tax_amount,omitempty"` 227 TotalAmount *int64 `json:"total_amount,omitempty"` 228 TaxRate *int64 `json:"tax_rate,omitempty"` 229 TaxPreferMark *TaxPreferMark `json:"tax_prefer_mark,omitempty"` 230 Discount *bool `json:"discount,omitempty"` 231} 232 233type CardStatus string 234 235func (e CardStatus) Ptr() *CardStatus { 236 return &e 237} 238 239const ( 240 CARDSTATUS_INSERT_ACCEPTED CardStatus = "INSERT_ACCEPTED" 241 CARDSTATUS_INSERTED CardStatus = "INSERTED" 242 CARDSTATUS_DISCARD_ACCEPTED CardStatus = "DISCARD_ACCEPTED" 243 CARDSTATUS_DISCARDED CardStatus = "DISCARDED" 244) 245 246type BuyerType string 247 248func (e BuyerType) Ptr() *BuyerType { 249 return &e 250} 251 252const ( 253 BUYERTYPE_INDIVIDUAL BuyerType = "INDIVIDUAL" 254 BUYERTYPE_ORGANIZATION BuyerType = "ORGANIZATION" 255) 256 257type FapiaoBillType string 258 259func (e FapiaoBillType) Ptr() *FapiaoBillType { 260 return &e 261} 262 263const ( 264 FAPIAOBILLTYPE_COMM_FAPIAO FapiaoBillType = "COMM_FAPIAO" 265 FAPIAOBILLTYPE_VAT_FAPIAO FapiaoBillType = "VAT_FAPIAO" 266) 267 268type TaxPreferMark string 269 270func (e TaxPreferMark) Ptr() *TaxPreferMark { 271 return &e 272} 273 274const ( 275 TAXPREFERMARK_NO_FAVORABLE TaxPreferMark = "NO_FAVORABLE" 276 TAXPREFERMARK_OUTSIDE_VAT TaxPreferMark = "OUTSIDE_VAT" 277 TAXPREFERMARK_VAT_EXEMPT TaxPreferMark = "VAT_EXEMPT" 278 TAXPREFERMARK_NORMAL_ZERO_RATED TaxPreferMark = "NORMAL_ZERO_RATED" 279 TAXPREFERMARK_EXPORT_ZERO_RATED TaxPreferMark = "EXPORT_ZERO_RATED" 280) 281
应答参数
200 OK
total_count 必填 integer
【发票数量】 发票数量
fapiao_information 选填 array[object]
【发票信息】 发票信息
属性 | |||||||||||||||||||||||||||||
fapiao_id 必填 string(32) 【商户发票单号】 商户发票单号,唯一标识一张发票 status 必填 string 【发票状态】 发票状态 可选取值
blue_fapiao 选填 object 【蓝字发票信息】 蓝字发票信息,当发票状态不为ISSUE_ACCEPTED时存在
red_fapiao 选填 object 【红字发票信息】 红字发票信息,当发票状态为REVERSED时存在
card_information 选填 object 【电子发票卡券信息】 电子发票卡券信息,蓝字发票插入用户卡包成功时返回
total_amount 必填 integer 【总价税合计】 总价税合计,所有发票行单行金额合计的累加,单位:分 tax_amount 必填 integer 【总税额】 总税额,所有发票行单行税额的累加,单位:分 amount 必填 integer 【总金额】 总金额,所有发票行单行金额的累加,单位:分 seller_information 必填 object 【销售方信息】 销售方信息
buyer_information 必填 object 【购买方信息】 购买方信息
extra_information 必填 object 【附加信息】 附加信息
items 选填 array[object] 【发票行信息】 发票行信息
remark 选填 string(200) 【备注信息】 备注信息 fapiao_error_code 选填 string(32) 【开票失败错误码】 开票失败时存在 fapiao_error_message 选填 string(256) 【开票失败原因】 开票失败时存在 |
应答示例
200 OK
1{ 2 "total_count" : 5, 3 "fapiao_information" : [ 4 { 5 "fapiao_id" : "20200701123456", 6 "status" : "ISSUE_ACCEPTED", 7 "blue_fapiao" : { 8 "fapiao_code" : "044001911211", 9 "fapiao_number" : "12897794", 10 "check_code" : "69001808340631374774", 11 "password" : "006>299-375/326>2+7/*0-+<351059<80<4*/5>+<11631+*3030/5*37+/-243159658+013>3409*044>4-/1+/9->*>69501*6++1997--21", 12 "fapiao_time" : "2020-07-01T12:00:00+08:00" 13 }, 14 "red_fapiao" : { 15 "fapiao_code" : "044001911211", 16 "fapiao_number" : "12897794", 17 "check_code" : "69001808340631374774", 18 "password" : "006>299-375/326>2+7/*0-+<351059<80<4*/5>+<11631+*3030/5*37+/-243159658+013>3409*044>4-/1+/9->*>69501*6++1997--21", 19 "fapiao_time" : "2020-07-01T12:00:00+08:00" 20 }, 21 "card_information" : { 22 "card_appid" : "wxb1170446a4c0a5a2", 23 "card_openid" : "plN5twRbHym_j-QcqCzstl0HmwEs", 24 "card_id" : "p4gLgvlAYSEOpeXGFVJRFxgop6iY", 25 "card_code" : "379550244162", 26 "card_status" : "INSERT_ACCEPTED" 27 }, 28 "total_amount" : 382895, 29 "tax_amount" : 44050, 30 "amount" : 338845, 31 "seller_information" : { 32 "name" : "深圳市南山区测试公司", 33 "taxpayer_id" : "202003261233701778", 34 "address" : "深圳市南山区深南大道10000号", 35 "telephone" : "075512345678", 36 "bank_name" : "测试银行", 37 "bank_account" : "62001234567890" 38 }, 39 "buyer_information" : { 40 "type" : "INDIVIDUAL", 41 "name" : "深圳市南山区测试企业", 42 "taxpayer_id" : "202003261233701778", 43 "address" : "深圳市南山区深南大道10000号", 44 "telephone" : "075512345678", 45 "bank_name" : "测试银行", 46 "bank_account" : "62001234567890", 47 "phone" : "mI7HGEJ4Q2B91IGjHrl7FNN9QuFPDfzeXoaJM4B8ZghZPzXK+vNotEZu/Gthm87Szv0MK2AoC0/3ZMDgltMtdoY6O0qZ4F1iXiwCuqkkBe+9M4ggvdzpPGM+fyed2QU1seUGbii5RVVVB9s+zLEQ8nv74vsgl77MZx14nd5obtCcfAvPfDJob3oG7FqlThmYKJqjiOwBvvQse7p9R8onj/POzSrbM8re8ZYGp4LcehXopTLdk2ZVWRv8bnJgKZWArAcqMdahq4jY2UVYeY4vpMmq4xuRTYk6xNXvowBBKK2SX8SqM+jm1USyoBIazLu4oaNFNdBO3fip1a1rFW0vRw==", 48 "email" : "NzJy3r0Z2u2Vs5l+WSH0A3CZ1oGlCZ66aa2wUlMXNmACbd4wU8LqqYCuTG4cYWxrVUSmviV59/Uy9vLdIwuHZVrMalYAZGtb8inWGhDj3wUqQnPkmBKBVGIWG5Y6XJmMvpXW6rIKsdzxs8NwWj30cRNfjanLxiWc0aIgl8Knwo0JcxlcYLo38T9ntsrRkQZMQEWHaMYnzjp7ysLbp6yW83OZb/NwEufERBdPnIbDbVE7DUd5MGhvO+tlr2YC1b4VCsrDmjryuTD5nvYYCGHyfXW2CM23hZdBm9tPc+mU18Z9d4XkasnfsecGWd2ISkpPmnk3DtapnD64Nw8JyLtkgw==", 49 "amount" : 1000, 50 "out_trade_no" : "order_20200701_123456", 51 "fapiao_bill_type" : "COMM_FAPIAO", 52 "user_apply_message" : "用户留言" 53 }, 54 "extra_information" : { 55 "payee" : "张三", 56 "reviewer" : "李四", 57 "drawer" : "王五" 58 }, 59 "items" : [ 60 { 61 "tax_code" : "3010101020203000000", 62 "goods_name" : "出租汽车客运服务", 63 "specification" : "A4", 64 "unit" : "次", 65 "quantity" : 100000000, 66 "unit_price" : 380442000000, 67 "amount" : 380442, 68 "tax_amount" : 49458, 69 "total_amount" : 429900, 70 "tax_rate" : 1300, 71 "tax_prefer_mark" : "NO_FAVORABLE", 72 "discount" : false 73 } 74 ], 75 "remark" : "备注", 76 "fapiao_error_code" : "BIZ_ERROR", 77 "fapiao_error_message" : "开票失败。授信额度不足,请联系主管税务机关或者登录电子税务局提额/申报。" 78 } 79 ] 80} 81
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | INVALID_REQUEST | 请求参数符合参数格式,但不符合业务规则 | 请使用正确的参数重新调用 |
403 | NO_AUTH | 商户无权限 | 请检查是否已经开通电子发票产品相关功能权限,并检查子商户是否接受了服务商的邀请 |
403 | NO_AUTH | 服务商无权限 | 请检查发票申请单是否属于服务商 |
404 | RESOURCE_NOT_EXISTS | 发票申请单不存在 | 请检查发票申请单号是否正确 |
404 | RESOURCE_NOT_EXISTS | 商户发票单号对应的发票不存在 | 请检查商户发票单号是否正确 |
429 | FREQUENCY_LIMITED | 频率超限 | 请降低请求接口频率 |