Skip to main content

Take payments with WeChat Pay

This guide explains how to let users pay for your Casdoor products with WeChat Pay. Casdoor supports Native payment, with a QR code, and JSAPI payment, inside the WeChat app.


Learning outcomes​

  • Get the API key, the certificate, and the IDs from WeChat Pay.
  • Add WeChat Pay as a payment provider and add it to a product.
  • Turn on payment inside the WeChat app.

What you need​


Get the credentials​

  1. On the WeChat Pay merchant platform, go to Account Settings > API Security > Set APIv3 Secret and copy the API key v3. See APIv3 key settings.

    API key v3 setting

  2. Go to Account Settings > API Security > API Certificate and download the merchant certificate. Note its serial number and its private key.

    Merchant certificate download

  3. Store the certificate on the Certs page of Casdoor.

    Merchant certificate in Casdoor

  4. Note your merchant ID and your App ID.

Add the provider in Casdoor​

  1. In the Casdoor admin console, go to Identity > Providers and add a provider.

  2. Set Category to Payment and Type to WeChat Pay.

  3. Fill in the fields:

    Casdoor fieldValue
    Client IDMerchant ID
    Client secretAPI Key v3
    App IDApp ID
    CertThe Cert above

    WeChat Pay provider in Casdoor

  4. Save the provider.

Add the provider to a product​

Add the provider to the Payment providers of the product and save it.

WeChat Pay in the payment providers of a product

Pay inside the WeChat app​

For JSAPI payment, users sign in with WeChat in the built-in browser of the WeChat app and then pay there. Configure a WeChat OAuth provider for the same official account as the payment provider, and add both to the application.

Relation between the WeChat Pay provider and the WeChat OAuth provider

See also​