# Plug an electronic invoice voucher into a user card package

Debugging Tools

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 NametypeRequired to fill inIntroductions
access_tokenstringyesInterface invocation credentials, using access_token , authorizer_access_token

# Request BodyRequest Payload

Parameter NametypeRequired to fill inIntroductions
order_idstringyesInvoice order_id, which is the order number authorized by the merchant to the user
card_idstringyesInvoice card_id
appidstringyesAppID used when the order number is authorized, usually merchant appid
card_extobjectyesDetails of the invoice

# Body.card_extObject Payload

Details of the invoice

Parameter NametypeRequired to fill inIntroductions
nonce_strstringyesRandom character strings to prevent duplication
user_cardobjectyesUser Information Structures

# Body.card_ext.user_cardObject Payload

User Information Structures

Parameter NametypeRequired to fill inIntroductions
invoice_user_dataobjectyesUser Information

# Body.card_ext.user_card.invoice_user_dataObject Payload

User Information

Parameter NametypeRequired to fill inIntroductions
feenumberyesThe amount of the invoice divided into units
titlestringyesThe rise of invoices
billing_timenumberyesInvoice time, 10-digit time stamp (UTC + 8)
billing_nostringyesThe invoice number of the invoice; Numerical invoice transmits 20 digit invoice number
billing_codestringyesThe invoice code of the invoice; Electrical invoice The invoice code is empty
infoobjarraynoDetails of product structure
fee_without_taxnumberyesExcluding the amount of tax, divided into units
taxnumberyesThe amount of tax, divided into units
s_pdf_media_idstringyesWhen 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_idstringnoPDF of other consumption attachments, such as train tickets, water bills, etc.
check_codestringyesCheck code, invoice pdf upper right corner, invoice date under the check code; Electrical invoice verification code is empty
buyer_numberstringnoBuyer's Taxpayer Identification Number
buyer_address_and_phonestringnoBuyer's address, phone number
buyer_bank_accountstringnoBuyer's bank account and account number
seller_numberstringnoSeller Taxpayer Identification Number
seller_address_and_phonestringnoThe seller's address and phone number
seller_bank_accountstringnoThe seller's account and account number
remarksstringnoNote, the beginning of the bottom right corner of the invoice
cashierstringnoRecipient, bottom left corner of the invoice
makerstringnoThe invoicer, at the bottom of the invoice

# Body.card_ext.user_card.invoice_user_data.info(Array)Object Payload

Details of product structure

Parameter NametypeRequired to fill inIntroductions
namestringyesName of the project
numnumbernoNumber of projects
unitstringnoUnit of the project, such as a
pricenumberyesUnit price of the project

# 3. Return Parameters

# Response Payload

Parameter NametypeIntroductions
errcodenumberError code
errmsgstringError message
codestringInvoice code
openidstringGet the openid of the invoice user
unionidstringThis 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 codeError DescriptionSolutions
40001invalid credential  access_token isinvalid or not latestaccess_token Invalid or not recently acquired access_token, please confirm the validity of the access_token

# 7. Scope of application

How this interface can be invoked under different account types:
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;