catalog
3. Pull up invoice list (inside WeChat)
4. Pull up invoice list (external app)
5 Check invoice information and get PDF documents
7 Methods of signature of invoices
# 1. Development Preparation
Before starting development, please confirm that the following preparations have been made in advance:
(1) have WeChat Service Account and have completed certification;
(2) Have a printer that can be connected to the Internet;
(3) Having a cloud background, you can issue instructions to the printer.
# 2. Time series diagram
# 3. Pull up invoice list (inside WeChat)
# 3.1 Interface Dxplaination
This interface functions to pull up the list of invoices vouchers within WeChat (as shown in the following figure), and after the user checks the invoices that need to be submitted for print, the developer gets the identification information for the selected invoices.
Calls to this interface must follow the JS-SDK call method. Please read the JS-DK documentation before you develop to familiarize yourself with development terminology and basic interface calls.
# 3.2 How to request
Referring to the example code, you can successfully pull up the invoice list page by entering the parameters in the following table.
parameter | type | Is it compulsory? | describe |
---|---|---|---|
timestamp | string(32) | yes | Signature generated timestamps, using unix ten - digit timestamps |
nonceStr | string(32) | yes | The random character string used to generate the signature, see 6.3 |
signType | string(32) | yes | Types of signatures, and methods of signing generation, see cf. 6.3 |
cardSign | string(64) | yes | Invoice signature, follow the documentation to enter the signature as a parameter after generating it, see 6.3 |
# 3.3 Return results
When a user clicks confirm or cancel, the results are returned by pressing the format and meaning of the fields listed in the table below.
Return fields | type | value | meaning |
---|---|---|---|
err_msg choose_invoice | string | ok | Successful selection of invoices |
fail | The selection of invoices failed | ||
cancel | Selection of invoices cancelled | ||
choose_invoice_info | object | List of objects | List of invoices selected by users |
The object structure of choose_invoice_info is as follows
{ card_id = @"", encrypt_code = @"" app_id=@"" }
The fields mean as follows:
field | type | describe |
---|---|---|
card_id | string | Card_id of the selected invoice card voucher |
encrypt_code | string | The encryption code of the selected invoice card voucher, the printing service provider can obtain the invoice information and PDF document that the user applies for printing through card_id and encrypt_code |
app_id | string | AppID |
After obtaining the card_id and encrypt_code, the developer can obtain the structured information of each invoice and the PDF file as described in the section "Query Invoice Information and Get PDF Documents."
# 3.4 sample code
wx.config({
beta: true,
debug: false,
appId: "wx00000000000000",
timestamp: 1489030247,
nonceStr: "(9J4YRV[#@",
signature: "f027317f8910000000000000000000",
jsApiList: ['chooseInvoice']
});
wx.ready(function () {
wx.invoke('chooseInvoice', {
'timestamp': 1489030247, // 卡券签名时间戳
'nonceStr': "p(6N&7WOAF", // 卡券签名随机串
'signType': 'SHA1', // 签名方式,默认'SHA1'
'cardSign': "a72043eed36c74300000000000000000" // 卡券签名
}, function(res) {
alert(JSON.stringify(res));
}
});
});
# 4. Pull up invoice list (external app)
# 4.1 Interface Dxplaination
WeChat also supports an interface for external apps to pull up the invoice list.Similar to the pull-up invoice list interface in WeChat, the identification data of the invoice can be obtained after the user checks and clicks on confirmation.
The interface must follow the JS-SDK invocation method and must meet certain conditions to be invoked. Please check before developing that you have met the following criteria :
Obtain a certified WeChat Open Platform account;
Create an application on the WeChat open platform and submit it for review.Developers who have not registered their apps can register on the Developer App Registration page;
Download WeChat electronic invoice reimbursement SDK, iOS and Android download address see the electronic invoice document resources download section;
4 ) Read the basic methods for using the SDK in WeChat Open Platform Resource Center and correctly import them into your own application.
# 4.2 How to request
IOS app
Refer to the OpenSDK1. 7. 7 file in the compression package, and call the WXChooseInvoice class when used. For the part that needs to be signed, refer to the way JS-SDK is called.
Android apps
Refer to the compact package, go into the jar file, call the WXChooseCard class when used, and pass in the CardType as "INVOICE." For the part that needs to be signed, refer to the way JS-SDK is called.
# 4.3 Return results
Please return the same result as the pull up invoice list in WeChat, see 3.3.
# 5 Check invoice information and get PDF documents
# 6 Get api_ticket
# 7 Methods of signature of invoices
When applying JS-SDK and App SDK, it is necessary to sign in order to verify that the data transfer process has not been tampered with, and the method of signing is as follows:
Participating signature parameters
Signature method
Convert api_ticket, AppID, timestamp, nonceStr, cardTypeTo lexicographically sort character strings using the value of. Then all the parameters of the string stitching into a character string for sha1 encryption, get cardSign.
For example: api_ticket = aaa, AppID = aab, timestamp = abc, nonceStr = bbc, cardType = cde,So first spell the string aaaaaabcbcde, and then this string for sha1 encryption, get cardSign.