# Plug an electronic invoice voucher into a user card package
Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide
Interface name: insertinvoice
This interface is invoked by billing platforms or self-built platform merchants. For the invoice request that the user has authorized, the invoice platform can use this interface to make the invoice card voucher into the user's WeChat card package.
It is worth noting that if the authorization page is pulled up by the merchant and the card delivery invoice is completed by the invoicing platform, the merchant needs to send the identifier and order_id of the card package that needs to be deposited in WeChat to the invoicing app in the invoicing request.
Note: You need to use the invoicing platform Official Account appid before calling the s_p AppID interface to call this interface, otherwise it will cause an error, card insertion failure.
# 1. How to call
# HTTPS calls
POST https://api.weixin.qq.com/card/invoice/insert?access_token=ACCESS_TOKEN
# Cloud Calls
- This interface does not support cloud calls
# Third party invocation
This interface supports Third Party Platform generation business call.
This interface belongs to the permission set id: 8, 26
When a service provider is authorized by one of the permissions set, it can call on behalf of the merchant by using authorizer_access_token , which can be viewed in the third-party call documentation.
# 2. Request parameters
# Query parametersQuery String parameters
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
access_token | string | yes | Interface invocation credentials, using access_token , authorizer_access_token |
# Request BodyRequest Payload
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
order_id | string | yes | Invoice order_id, which is the order number authorized by the merchant to the user |
card_id | string | yes | Invoice card_id |
appid | string | yes | AppID used when the order number is authorized, usually merchant appid |
card_ext | object | yes | Details of the invoice |
# Body.card_extObject Payload
Details of the invoice
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
nonce_str | string | yes | Random character strings to prevent duplication |
user_card | object | yes | User Information Structures |
# Body.card_ext.user_cardObject Payload
User Information Structures
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
invoice_user_data | object | yes | User Information |
# Body.card_ext.user_card.invoice_user_dataObject Payload
User Information
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
fee | number | yes | The amount of the invoice divided into units |
title | string | yes | The rise of invoices |
billing_time | number | yes | Invoice time, 10-digit time stamp (UTC + 8) |
billing_no | string | yes | The invoice number of the invoice; Numerical invoice transmits 20 digit invoice number |
billing_code | string | yes | The invoice code of the invoice; Electrical invoice The invoice code is empty |
info | objarray | no | Details of product structure |
fee_without_tax | number | yes | Excluding the amount of tax, divided into units |
tax | number | yes | The amount of tax, divided into units |
s_pdf_media_id | string | yes | When the invoice pdf file is uploaded to the WeChat invoice platform, an invoice s_media_id is generated, which can be directly used to associate the invoice PDF and invoice vouchers. |
s_trip_pdf_media_id | string | no | PDF of other consumption attachments, such as train tickets, water bills, etc. |
check_code | string | yes | Check code, invoice pdf upper right corner, invoice date under the check code; Electrical invoice verification code is empty |
buyer_number | string | no | Buyer's Taxpayer Identification Number |
buyer_address_and_phone | string | no | Buyer's address, phone number |
buyer_bank_account | string | no | Buyer's bank account and account number |
seller_number | string | no | Seller Taxpayer Identification Number |
seller_address_and_phone | string | no | The seller's address and phone number |
seller_bank_account | string | no | The seller's account and account number |
remarks | string | no | Note, the beginning of the bottom right corner of the invoice |
cashier | string | no | Recipient, bottom left corner of the invoice |
maker | string | no | The invoicer, at the bottom of the invoice |
# Body.card_ext.user_card.invoice_user_data.info(Array)Object Payload
Details of product structure
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
name | string | yes | Name of the project |
num | number | no | Number of projects |
unit | string | no | Unit of the project, such as a |
price | number | yes | Unit price of the project |
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
errcode | number | Error code |
errmsg | string | Error message |
code | string | Invoice code |
openid | string | Get the openid of the invoice user |
unionid | string | This field appears only after the user has bound Official Account to WeChat open platform account |
# 4. Note
There are no special considerations for this interface
# 5. Code examples
Example Requests
{
"order_id": "111163",
"card_ext": {
"nonce_str": "j!Re1WxaHv",
"user_card": {
"invoice_user_data": {
"info": [
{
"price": 10000,
"num": 3,
"name": "牙膏",
"unit": "个"
}
],
"billing_no": "4545145712",
"billing_code": "4541212454512",
"billing_time": "1468306058",
"tax": 123,
"s_pdf_media_id": "s_pdf_media_id_abc123",
"fee": 123,
"title": "灌哥发票",
"fee_without_tax": 2345
"buyer_number":"123456789012345678"
}
}
},
"card_id": "pjZ8Yt9WoOePThU0NfUKz5-tBEWU",
"appid": "wxc0b84a53ed8e8d29"
}
Return an example
{
"errcode": 0,
"errmsg": "ok",
"code": "682xxxx661927",
"openid": "ojZ8Ytz4lESxxxx_R1TvB2Kds"
}
# 6. Error code
The following is a list of error codes for this interface, other error codes can refer to General error codes
Error code | Error Description | Solutions |
---|---|---|
40001 | invalid credential access_token isinvalid or not latest | access_token Invalid or not recently acquired access_token, please confirm the validity of the access_token |
# 7. Scope of application
Official Account | Service Account |
---|---|
✔ | ✔ |
- ✔: The account can call this interface
- Other account types that are not expressly stated may not be called on this interface without special instructions;