Skip to main content
Capabilities

E-invoices

Issue electronic invoices through WeChat Pay for paid orders under your app. The seller is the platform company, and the invoice amount is the amount actually paid as recorded by the platform. Signing works the same as for payments.

Availability

E-invoicing must be enabled by the platform. Contact us before integrating.

Flow​

  1. Your server calls Apply for an invoice.
  2. The user fills in the invoice title in WeChat.
  3. WeChat issues the invoice into the user's WeChat card wallet.
  4. The platform sends the result to your server as a callback.

Because the user must enter the title in WeChat, the whole flow is asynchronous.

Apply for an invoice​

POST/client/open/invoice/v1/apply
FieldRequiredDescription
Common signing parametersYesappId / timestamp / nonce / sign
outTradeNoYesPlatform order number of a paid order
merchantFapiaoNoNoYour invoice request number, used as the idempotency key. Defaults to outTradeNo
openidYesThe user's openid under the Official Account or mini-program
sourceNoMINIPROGRAM (default) or WEB
sellerNameNoSeller name; defaults to the platform configuration
extraNoPass-through field

On success, data contains fapiaoApplyId, merchantFapiaoNo, outTradeNo, totalAmount (in fen, 1/100 CNY), miniprogramAppid, miniprogramPath, miniprogramUserName, expireIn (1800 seconds) and status (待填写抬头, awaiting title).

Use the miniprogram* values to open WeChat's invoicing mini-program so the user can enter the title. The link is valid for 30 minutes; call again with the same merchantFapiaoNo to get a new one.

Common errors: 订单不存在 (order not found), 订单未支付,不能开票 (order unpaid), openid不能为空 (openid required), source非法,仅支持WEB或MINIPROGRAM (invalid source).

Query an invoice​

GET/client/open/invoice/v1/query

Parameters: the common signing parameters plus either fapiaoApplyId or merchantFapiaoNo. Only these are used for verification.

Returns invoice details including fapiaoApplyId, merchantFapiaoNo, outTradeNo, totalAmount (fen), status, statusCode, buyerType, buyerName, buyerTaxpayerId, fapiaoNumber, fapiaoCode, checkCode, fapiaoTime, fapiaoMediaUrl, failReason and extra.

statusCodeCallback statusMeaning
0CREATEDAwaiting invoice title
1TITLE_SUBMITTEDTitle submitted
2ISSUE_ACCEPTEDIssuance accepted
3ISSUEDIssued
4FAILEDFailed
5REVERSE_ACCEPTEDReversal accepted
6REVERSEDReversed

Reverse an invoice​

POST/client/open/invoice/v1/reverse
FieldRequiredDescription
Common signing parametersYes
fapiaoApplyIdYesInvoice request ID
reverseReasonYesReason for reversal

Only ISSUED invoices can be reversed; otherwise the response is 仅已开票成功的发票可以冲红. Success returns {"fapiaoApplyId": "...", "status": "冲红已受理"} (reversal accepted); the final result arrives by callback.

Invoice callback​

When an invoice becomes ISSUED, FAILED or REVERSED, the platform sends a JSON POST to your app's notifyUrl (the same URL as payment callbacks). Signing, retries and the 2xx requirement are identical to the payment callback.

FieldDescription
appId, merchantFapiaoNo, fapiaoApplyId, outTradeNoIdentifiers
statusStatus enum, see the table above
statusCodeNumeric status
fapiaoNumber, fapiaoCode, checkCode, fapiaoTimePresent when issued
failReasonPresent when failed
timestamp, nonce, signSame as payment callbacks

Tell invoice callbacks from payment callbacks by the presence of fapiaoApplyId.