Skip to main content

WeChat Pay

Step 1. Preparation

First, you need to have a merchant account at WeChat Merchant Platform.

Before accessing the WeChat Pay, there are some preparations that need to be done.

You can refer to the documentation preparation before access for more information.

1.1 Get API Key v3

Log in to WeChat Merchant Platform, select Account Settings > API Security >Set APIv3 Secret, and click Set APIv3 secret to get the API Key v3.

wechat api key v3

How to get API Key v3 : APIv3 Key Settings

1.2 Get Merchant Certificate

You can log in to WeChat Merchant Platform, and select Account Settings > API Security > API Certificate to download the certificate.

wechat merchant certificate

After download the certificate, get the Certificate Serial Number according to How to view the Certificate Serial Number and Private Key according to How to get Private Key of Certificate.

Then, create a Cert at Casdoor and fill the necessary information.

wechat_cert

1.3 Get Merchant ID and App ID

How to get Merchant ID : WeChat Pay Merchant ID Query Guide

How to get App ID : WeChat Pay APPID Query Guide

Step 2. Create a WeChat Pay Payment provider

Next, create a WeChat Pay Payment provider in Casdoor by filling in the necessary information.

NameName in WeChat Pay
Categorychoose Payment
Typechoose WeChat Pay
Client IDMerchant ID obtained from Step 1.3
Client secretAPI Key v3 obtained from Step 1.1
App IDApp ID obtained from Step 1.3
CertCert configured at Step 1.2

wechat pay provider

Step 3. Add the WeChat Pay Payment provider for your product

Finally, add the WeChat Pay Payment provider for your product so that users can purchase the product using WeChat Pay.

add wechat pay payment provider for product

Support for JSAPI payment

Currently, Casdoor supports JSAPI payment and Native payment in WeChat Pay.

To support JSAPI payment, you should configure a WeChat OAuth Provider which support WeChat Media Platform. The Client ID 2 of WeChat OAuth Provider and the App ID of WeChat Pay Payment Provider need to be same.

relation between wechat pay payment provider and wechat oauth provider

After log in via WeChat(in the mobile scenario: e.g. the WeChat built-in browser inside the WeChat mobile app), users can purchase product using WeChat Pay based on JSAPI payment.