How to set up WeChat Pay in a WeChat Mini Program
Published: 2018-05-24
微信支付
1. Apply for 微信支付
If you use mall-type or other Mini Programs involving online payment, you need to apply for entity verification. After approval, you can apply for 微信支付. Personal Mini Programs do not currently support applying for 微信支付.
For the detailed activation process, please refer to: https://www.west.cn/faq/list.asp?unid=2159
2. Obtain 微信支付 parameters
After successfully applying for Mini Program 微信支付, log in to 微信支付 Merchant Platform via the link https://pay.weixin.qq.com to obtain the merchant ID, merchant key, and download the API payment certificate. The instructions for obtaining each parameter are as follows:
2.1. Obtain merchant ID
Click the "Account Center" -> "Merchant Information" menu to obtain the 微信支付 merchant ID, as shown in the figure below;

2.2 Merchant Key
Click the "Account Center" -> "API Security" menu, set a 32-bit key and record/back it up, as shown in the figure below;
Note: Incorrect key entry will cause payment exceptions. If it is modified during this period, please log in to the mall backend again and synchronously modify the parameters.

2.3 Obtain API Certificate
Note: Please be sure to follow the operation process to download the certificate. During this period, do not close the tool and other related programs. If the certificate is generated and the tool is closed, the certificate cannot be downloaded, and you can only wait 48 hours to regenerate it. (A certificate can only be generated 3 times per year. Please save it properly after downloading.)
I. How to determine whether the certificate type is 【API certificate issued by an authoritative CA】
Log in to 微信支付 Merchant Platform and click APT Security. If the following appears, it is an API certificate issued by an authoritative CA.

II. How to obtain an API certificate
Note: Obtaining an API certificate requires the super administrator of the merchant ID to perform the operation.
1. Click the 【Apply for Certificate】 button in API Security, and click Download to download the Certificate Tool.
Note: You can also directly visit the link https://wx.gtimg.com/mch/files/WXCertUtil-1.0.zip to download the Certificate Tool.

2. After downloading the certificate, open the Certificate Tool and click 【Apply for Certificate】.

3. After opening the Certificate Tool, return to 微信支付 Merchant Platform and click 【Copy Here】 to copy the merchant ID and merchant name.
Note: So that the product and merchant name can be copied to the system clipboard.

4. After copying the merchant ID and merchant name, click to switch to 【Certificate Tool】, click the 【Paste】 button in the upper right corner, paste the previously copied merchant ID and merchant name into the Certificate Tool, and then click 【Next】.

5. After clicking Next, a certificate string will be generated on the page. Click the 【Copy】 button in the upper right corner to copy the certificate string. After copying, click Next.

6. After copying the certificate string in the Certificate Tool, return to 【微信支付 Merchant Platform】, paste the copied certificate request string into the page for generating the aid certificate, enter the SMS verification code and operation password, and click Next.

7. After clicking Next, a certificate string will be generated 【at this point the system will consider the certificate application successful】. Click 【Copy Certificate Content】.

8. After copying the certificate content, switch to the 【Certificate Tool】 page, click the Paste button to paste the 【certificate string】 into the Certificate Tool page, and click Next to generate the certificate file and private key file.

9. After clicking Next, a dialog will pop up asking you to save the document. Select the folder where you want to save it to complete the certificate download. You can view your certificate in the document.
Note: Be sure to create a new document first, then you can place the downloaded certificate in the folder to avoid loss.

After downloading the certificate file, decompress it. You will later need to upload the materials shown in the figure, "apiclient_cert.p12", to the mall backend.

Save 微信支付 configuration in the management platform

