Contents
1. Invoicing with Official Accounts
2. Invoicing by Scanning QR Code
3. Invoicing with Apps
4. Invoicing with Mini Programs
5. Post-Payment Invoicing

# Introduction

This document describes how merchants issue e-invoices to users in different scenarios in the Self-deployed Platform mode, including the scenario description, interaction process on user side and API workflow. You can proceed with the development by following the steps described for your scenario, and access the API document for each step via the link provided.

# 1. Invoicing with Official Accounts

# 1.1 Scenario Description

Invoicing with Official Accounts refers to a scenario where an invoice is issued after a purchase is initiated in an Official Account and the payment is made on an H5 page in Weixin. The Invoicing button is provided on the merchant's H5 page. After tapping this button, the user goes to the Weixin invoicing authorization page to complete the authorization, and then returns to the original page or is redirected to the merchant's another page (such as the order page). The issued invoice is synced to the user's Weixin Cards & Offers. The overall process is asynchronous, without users having to stay on the page to wait for the invoice.

# 1.2 Interaction Process on User Side

The interactions for invoicing with Official Accounts are shown below: Invoicing with Official Accounts

# 1.3 API Workflow

The workflow of invoicing with Official Accounts is shown below: 公众号开票 The steps of invoicing with Official Accounts are as follows:

  1. Obtain the invoicing platform s_pappid. An invoice platform has only one s_pappid, so you only need to obtain it once. The method for obtaining s_pappid varies with different business modes:

If the merchant activates the Self-Deployed Platform mode, s_pappid can be obtained by calling the relevant API in the API List for Invoicing Platforms.

  1. Obtain the access_token by calling the API. For more information, see Obtaining access_token.
  2. Set the merchant contact information. For more information, see the API List for Merchants. Be sure not to forget this step. Otherwise, an error will occur when you try to get the authorization page.
  3. Obtain the authorization page ticket. For more information, see the API List for Merchants.
  4. Obtain the authorization page URL. The authorization page ticket obtained in the previous step is used as an input parameter. In addition, please keep the input parameter order_id in this step properly, which will be used by the invoicing platform to issue the e-invoice. For more information, see the API List for Merchants.
  5. Add the authorization page URL to the Invoicing button, so that the user can be redirected to the page after tapping the button.
  6. Receive the user authorization completion event at backend. For more information, see the API List for Merchants.
  7. Create an invoice card template. The template must uniquely match the invoicing entity for easy modification in case the invoicing entity changes. For more information, see the API List for Invoicing Platforms.
  8. Issue the e-invoice on the self-deployed invoice platform.
  9. Upload the invoice PDF file. The s_media_id from this step is used to link the PDF file and the invoice card and serves as a parameter for calling the "Add Cards" API. For more information, see the API List for the Invoicing Platforms.
  10. Add the e-invoice to the user's Cards & Offers. For more information, see Adding E-Invoice Cards to the User's Cards & Offer. #2. Invoicing by Scanning QR Code

# 2.1 Scenario Description

The "Invoicing by Scanning Code" scenario is common in the offline industries where receipts need to be provided to users, such as retailers, restaurants, convenience stores, and gas stations. A merchant converts the order information into an invoicing QR code, which is printed on the receipt provided to the user. After scanning the QR code, the user goes to the Weixin authorization page and quickly inputs the required information using the invoice title information saved in Weixin. After tapping the Invoicing button, the user closes the current page or is redirected to another page of the merchant (such as the order page). The issued invoice is synced to the user's Weixin Cards & Offers, so that the user can collect the invoice themselves, without having to involving additional personnel. This greatly improves the working efficiency of checkout counters. The overall process is asynchronous, without users having to stay on the page to wait for the invoice.

# 2.2 Interaction Process on User Side

The interactions for invoicing by scanning QR code are shown below:
Invoicing by scanning QR code

# 2.3 API Workflow

The workflow of invoicing by scanning QR code is shown below:
Invoicing by scanning QR code
The steps of invoicing by scanning code are as follows:

  1. Obtain the invoicing platform s_pappid. An invoice platform has only one s_pappid, so you only need to obtain it once. The method for obtaining s_pappid varies with different business modes:

If the merchant activates the Self-Deployed Platform mode, s_pappid can be obtained by calling the relevant API in the API List for Invoicing Platforms.

  1. Generate the QR code based on your own business logic and prints it on the receipt for the user to scan. This step does not involve calling a Weixin API.
  2. Obtain the access_token by calling the API. For more information, see Obtaining access_token.
  3. Set the merchant contact information. For more information, see the API List for Merchants. Be sure not to forget this step. Otherwise, an error will occur when you try to get the authorization page.
  4. Obtain the authorization page ticket. For more information, see the API List for Merchants.
  5. Obtain the authorization page URL. The authorization page ticket obtained in the previous step is used as an input parameter. In addition, please keep the input parameter order_id in this step properly, which will be used by the invoicing platform to issue the e-invoice. For more information, see the API List for Merchants.
  6. Receive the user authorization completion event at backend. For more information, see the API List for Merchants.
  7. Create an invoice card template. The template must uniquely match the invoicing entity for easy modification in case the invoicing entity changes. For more information, see the API List for Invoicing Platforms.
  8. Issue the e-invoice on the self-deployed invoice platform.
  9. Upload the invoice PDF file. The s_media_id from this step is used to link the PDF file and the invoice card and serves as a parameter for calling the "Add Cards" API. For more information, see the API List for the Invoicing Platforms.
  10. Add the e-invoice to the user's Cards & Offers. For more information, see the API List for Invoicing Platforms. #3. Invoicing with Apps

# 3.1 Scenario Description

The "Invoicing with Apps" scenario is mainly used for the merchants that conduct business through an App, such as e-commerce merchants and online service platforms. The Invoicing button is provided on a merchant's App interface. After tapping the button, the user goes to the authorization page in Weixin. After the authorization is completed, the user returns to the original App. The issued invoice is synced to the user's Weixin Cards & Offers. The overall process is asynchronous, without users having to stay in Weixin to wait for the invoice. This ensures a consistent and smooth user experience in the App.

# 3.2 Interaction Process on User Side

The interactions for invoicing with Apps are shown below:
Invoicing with Apps

# 3.3 API Workflow

The workflow of invoicing with Apps is shown below:
App开票时序图
The steps of invoicing with Apps are as follows:

  1. Ensure that the latest version of Weixin SDK is installed in the App.
  2. Obtain the invoicing platform s_pappid. An invoice platform has only one s_pappid, so you only need to obtain it once. The method for obtaining s_pappid varies with different business modes:

If the merchant activates the Self-Deployed Platform mode, s_pappid can be obtained by calling the relevant API in the API List for Invoicing Platforms.

  1. Obtain the access_token using the appid of the Open Platform. For more information, see Obtaining access_token.
  2. Set the merchant contact information. For more information, see the API List for Merchants. Be sure not to forget this step. Otherwise, an error will occur when you try to get the authorization page.
  3. Obtain the authorization page ticket. For more information, see the API List for Invoicing Platforms.
  4. Obtain the authorization page URL. The authorization page ticket obtained in the previous step is used as an input parameter. In addition, please keep the input parameter order_id in this step properly, which will be used by the invoicing platform to issue the e-invoice. For more information, see the API List for Merchants.
  5. Use the authorization page URL (auth_url) obtained in Step 5 as an input parameter to open the authorization page in Weixin. For more information on the process on iOS devices, see Opening Authorization Page on iOS devices; for Android devices, see Opening Authorization Page on Android devices.
  6. Receive the user authorization completion event at backend. Please note that the event is received using the Official Account appid, instead of the Open Platform account appid. For more information, see the API List for Merchants.
  7. Create an invoice card template. The template must uniquely match the invoicing entity for easy modification in case the invoicing entity changes. For more information, see the API List for Invoicing Platforms.
  8. Issue the e-invoice on the self-deployed invoice platform.
  9. Upload the invoice PDF file. The s_media_id from this step is used to link the PDF file and the invoice card and serves as a parameter for calling the "Add Cards" API. For more information, see the API List for the Invoicing Platforms.
  10. Add the e-invoice to the user's Cards & Offers. For more information, see the API List for Invoicing Platforms.

# 4. Invoicing with Mini Programs

# 4.1 Scenario Description

Invoicing with Mini Programs refers to a scenario where an invoice is issued after a purchase is initiated in a Mini Program. The Invoicing button is provided on the merchant's Mini Program page. After tapping this button, the user goes to the Mini Program invoicing authorization page to complete the authorization, and then returns to the original page or is redirected to the merchant's another page (such as the order page). The issued invoice is synced to the user's Weixin Cards & Offers. The overall process is asynchronous, without users having to stay on the page to wait for the invoice.

# 4.2 Interaction Process on User Side

The interactions for invoicing with Mini Programs are shown below:
小程序开票

# 4.3 API Workflow

The workflow of invoicing with Mini Programs is shown below:
Invoicing with Mini Programs
The steps of invoicing with Mini Programs are as follows:

  1. Obtain the invoicing platform s_pappid. An invoice platform has only one s_pappid, so you only need to obtain it once. The method for obtaining s_pappid varies with different business modes:

If the merchant activates the Self-Deployed Platform mode, s_pappid can be obtained by calling the relevant API in the API List for Invoicing Platforms.

  1. Obtain the access_token by calling the API. For more information, see Obtaining access_token.
  2. Set the merchant contact information. For more information, see the API List for Merchants. Be sure not to forget this step. Otherwise, an error will occur when you try to get the authorization page.
  3. Obtain the authorization page ticket. For more information, see the API List for Merchants.
  4. Obtain the authorization page URL. The authorization page ticket obtained in the previous step is used as an input parameter. In addition, please keep the input parameter order_id in this step properly, which will be used by the invoicing platform to issue the e-invoice. For more information, see the API List for Merchants.
  5. Deploy the logic to redirect to the Mini Program authorization page on the Tap event of the Mini Program's Invocing button. The auth_url and the invoicing Mini Program appid obtained in the previous step are passed as input parameters. For more information, see the API List for Merchants.
  6. Receive the user authorization completion event at backend. For more information, see the API List for Merchants.
  7. Create an invoice card template. The template must uniquely match the invoicing entity for easy modification in case the invoicing entity changes. For more information, see the API List for Invoicing Platforms.
  8. Issue the e-invoice on the self-deployed invoice platform.
  9. Upload the invoice PDF file. The s_media_id from this step is used to link the PDF file and the invoice card and serves as a parameter for calling the "Add Cards" API. For more information, see the API List for the Invoicing Platforms.
  10. Add the e-invoice to the user's Cards & Offers. For more information, see the API List for Invoicing Platforms.

# 5. Post-Payment Invoicing

# 5.1 Scenario Description

Post-payment invoicing provides a new approach to invoicing by leveraging WeChat Pay. Users can find the entry to the Invoicing feature in WeChat Pay Receipts. For some offline scenarios where it is inconvenient for the merchants to printing receipts (such as parking lot gates), this method is recommended. For the scenarios where printed receipts are prone to be lost or damaged, this method can be used as an alternative. After a user makes a payment with WeChat Pay, the entry button to the Invoicing feature appears on the payment receipt. After tapping the button, the user submits the invoice title information and authorizes the invoicing. The issued invoice is synced to the user's Weixin Cards & Offers, without users having to stay on the page to wait for the invoice.

# 5.2 Interaction Process on User Side

The interactions for post-payment invoicing are shown below:
Post-Payment Invoicing

# 5.3 API Workflow

The workflow of post-payment invoicing is shown below:
Workflow of post-payment invoicing
The steps of post-payment invoicing is shown below:

  1. Obtain the invoicing platform s_pappid. An invoice platform has only one s_pappid, so you only need to obtain it once. The method for obtaining s_pappid varies with different business modes:

If the merchant activates the Self-Deployed Platform mode, s_pappid can be obtained by calling the relevant API in the API List for Invoicing Platforms.

  1. Obtain the access_token by calling the API. For more information, see Obtaining access_token.
  2. Set the merchant contact information. For more information, see the API List for Merchants. Be sure not to forget this step. Otherwise, an error will occur when you try to get the authorization page.
  3. Link the merchant ID to the invoicing platform. This operation only needs to be performed once. Only when the invoicing platform ID is changed, or you change the invoicing platform, you need to call this API to reset the linkage relationship. For more information, see the API List for Merchants.
  4. Query the linkage status to verify that the merchant ID has been linked to the invoicing platform successfully. For more information, see the API List for Merchants.
  5. Specify post-payment invoicing for the transaction when the user initiates a payment request for the transaction. Linking the merchant ID to the invoicing platform in Step 3 does not mean the Invoicing entry button appears for each payment. You must call this API to specify that the Invoicing button entry is displayed on the payment receipt. For more information, see the API List for Merchants.
  6. Receive the user authorization completion event at backend. The appid used to receive the event is the appid linked with the merchant ID. For more information on how to receive the authorization event, see the API List for Merchants.
  7. Query the user invoicing information based on the order_id and s_pappid obtained in the user authorization completion event. For more information, see the API List for Merchants.
  8. Create an invoice card template. The template must uniquely match the invoicing entity for easy modification in case the invoicing entity changes. For more information, see the API List for Invoicing Platforms.
  9. Issue the e-invoice on the self-deployed invoice platform.
  10. Upload the invoice PDF file. The s_media_id from this step is used to link the PDF file and the invoice card and serves as a parameter for calling the "Add Cards" API. For more information, see the API List for the Invoicing Platforms.
  11. Add the e-invoice to the user's Cards & Offers. For more information, see Adding E-Invoice Cards to the User's Cards & Offer.