No momento, esta página não está disponível em português
Payment-method icon

Mini Program for API-only

How to offer WeChat Pay through WeChat Mini Program with an API-only integration.

Make WeChat Pay available to your shopper on WeChat Mini Program with an API only integration.

Before you begin

Before you can accept WeChat Pay payments in your Mini Program:

  1. Make sure that you have set up your back-end implementation for making API requests.

  2. Create a Mini Program account with WeChat.

  3. Contact our Support Team or your implementation manager and provide your:

    • Mini Program AppID
    • Entity name
    • Currency

    These details are required to ensure that payments made with your Mini Program are settled to your Adyen account.

  4. Add WeChat Pay in your live Customer Area.

Overview of payment flow

The diagram shows the flow of a Mini Program payment.


Follow the steps below to enable Mini Program payments.

Make all calls to Adyen from your server, not from your Mini Program.

Step 1: Allow Adyen domains

Allow-list the following domains in your Mini Program settings:


Find your merchant prefix in the Customer Area, by selecting Developers > API URLs. Select the data center closest to your server.

Step 2: Get the user's openid

  1. Use wx.login() to get jsCode in the success callback.
  2. Use wx.request() to make the following call that returns the user's openid in the response:${appId}&secret=${secret}&js_code=${jsCode}&grant_type=authorization_code

    Parameter Description
    appID Available in your Mini Program Account.
    secret Available in your Mini Program Account.
    jsCode Obtained during the wx.login() call.
    grant_type Set to authorization_code.

Refer to the WeChat Mini Program Login documentation for a detailed flow.

Step 3: Make a payment request

  1. Use the WeChat function wx.request() to make a request to your server.

  2. Make a /payments request.

    When the /payments request is received by Adyen, a POST request is automatically sent from Adyen to the WeChat Server to place the order and to get the prepay_id, which is required to execute wx.requestPayment() and to trigger the payment on WeChat.

    The value for prepay_id is returned as part of the /payments response, and is contained in

  1. Use the WeChat function wx.requestPayment() to handle the redirect received in the /payments response.

Step 4: Check the payment result

When the shopper completes the payment:

  1. Use wx.request() (also used in step 3) to check the payment result.

  2. Make a /payments/details request.

    The value for paymentStatus is returned in res.errMsg and is one of these:

    • requestPayment:ok
    • requestPayment:fail cancel
    • requestPayment:fail (detail message)

    Receive the /payments/details response.

Step 5: Show the payment result

Use the resultCode that you received in the /payments/details response to present the payment result to your shopper.

The resultCode values you can receive for WeChat Pay are:

resultCode Description Action to take
Authorised The payment was successful. Inform the shopper that the payment has been successful.
You will receive the funds in 2-3 days.
Error There was an error when the payment was being processed. Inform the shopper that there was an error processing their payment. The response contains a refusalReason, indicating the cause of the error.
Pending or
The payment order was successfully received. Inform the shopper that you've received their order, and are waiting for the payment to clear.
You will receive the final result of the payment in an AUTHORISATION webhook. If successful, you will receive the funds in 2 days.
Refused The payment was refused by the shopper's bank. Ask the shopper to try the payment again using a different payment method.

Test and go live

WeChat Pay does not have a test platform. If you have a personal WeChat account, test the following scenarios:

  • Cancel the transaction when you are asked to verify the payment (recommended).
  • Make a live WeChat Pay payment with a low value.

Check the status of a WeChat Pay payment in your Customer Area > Transactions > Payments.

See also