WeChat Pay in-app payments

Learn how to initiate WeChat Pay payments from your iOS or Android app.

Payment Type
Payment flow
Recurring
Refunds
Partial Refunds
Captures
Partial Captures
Chargebacks
Wallet

Direct

No Yes Yes No No No

When initiating a WeChat Pay payment from your app, the shopper is switched to the WeChat app to verify the payment. When the payment is completed, they are switched back to your app and presented with the payment result.

 

The WeChat Pay desktop payment flow is supported by our:

Prerequisites

Before you can accept WeChat Pay payments in-app, you'll need to:

  1. Create a developer account on the WeChat Open Platform.
  2. Register your mobile app with WeChat.

Create developer account

To register a WeChat Developer Account:

  1. Go to https://open.weixin.qq.com/ and select Sign Up.
  2. Fill in your information and complete your developer profile.

WeChat will contact you to verify that the details you provided are correct. Once approved, you can register your mobile app.

Register mobile app

To register your iOS or Android app with WeChat:

  1. Go to https://open.weixin.qq.com/ and click Log In .
  2. Navigate to Admin Center > Mobile Application > Create Mobile Application, and enter the following for your app:
    1. Name.
    2. Short introduction.
    3. The official website.

    4. iOS only: The App Store download link and Bundle ID. The Bundle ID is usually in the format com.your-company.app-name

    When your app is successfully registered, you'll receive an AppID and AppSecret from WeChat.
  3. Contact our Support Team, and provide them your AppID and AppSecret. This will ensure that payments made with your app are settled to your Adyen account.

Integrate with Checkout SDKs

The WeChat Pay in-app flow is supported by our Checkout SDKs for iOS and Android.  To accept in-app payments using our Checkout SDKs, integrate Adyen's WeChat Pay module into your:

Integrate Adyen Checkout SDK module for iOS

To  add Adyen's WeChat module into your iOS app:

  1. Add the WeChat Pay framework into your project:
    CocoaPods
    1. Add pod 'Adyen/WeChatPay' to your Podfile.
    2. Run pod install.
    Carthage
    1. Run carthage update.
    2. Link AdyenWeChatPay.framework to your target.
  2. Add your AppID to your URL scheme.
    1. Select  Targets > Info > URL type > URL Scheme .
    2. Add a new URL Scheme:

      1. For the Identifier, use  weixin .

      2. For the URL Scheme, use your AppID .

  3. In your Info.plist, add weixin to LSApplicationQueriesSchemes.

For more information on integrating our iOS SDK into your app, refer to our Checkout SDK for iOS documentation.

Integrate Adyen Checkout SDK module for Android

To add Adyen's WeChat module into your app:

  • Add the following to your build.gradle file.

    ...
    implementation "com.adyen.checkout:wechatpay:${checkoutVersion}"

For more information on integrating our Android SDK into your app, refer to our Checkout SDK for Android documentation.

Integrate with API

In this section, we show the integration steps for accepting in-app payments using our API integration.

Before you begin this section, make sure you read and understand our API Integration guide.

Prerequisites

Integrate WeChat's mobile SDKs

  1. Follow the steps for registering with WeChat for in-app payments.
  2. Integrate the WeChat Pay SDK into your app:
    1. Go to https://open.weixin.qq.com/ and navigate to Resource Center.
    2. Open Downloads, and select either:
      • iOS Resource Download iOS Development Kit (version x.x.x with payment functionality).
      • Android Resource Download > Development Kit (SDK).
    3. Follow the instructions provided in the downloaded file to integrate the SDK.

Step 1: Make a payment

When a shopper chooses to pay with WeChat Pay:

  1. Make a /payments API call, providing:
    • reference: Your unique reference for this payment.

    • amount.
    • paymentMethod.typewechatpaySdk
    {
      "merchantAccount":"YourMerchantAccount",
      "reference":"wechat pay in-app test",
      "amount":{
        "currency":"CNY",
        "value":"1000"
      },
      "paymentMethod":{
        "type":"wechatpaySdk"
      }
    }

    This returns a /payments response containing a:

    • resultCode of Pending
    • paymentData value.
    • redirect object containing data values.

    {
      "resultCode":"Pending",
      "details":[
        {
          "key":"resultCode",
          "type":"text"
        }
      ],
      "paymentData":"Ab02b4c0...",
      "redirect":{
        "data":{
          "package":"Sign=WXPay",
          "appid":"wx33ed...",
          "sign":"B3581C35...",
          "partnerid":"2052...",
          "prepayid":"wx1518041...",
          "noncestr":"pfuxu9d...",
          "timestamp":"154..."
        }
      }
    }
  2. Pass the values in the redirect.data object to the SDK.

Step 2: Present payment result 

  1. Make a /payments/details call, providing:

    • paymentData: Value you received from the /payments response.

    • resultCode: Value you received from the SDK.
    {
      "paymentData":"Ab02b4c0...",
      "details":{
        "resultCode":"0"
      }
    }

    The response will contain: 

    • pspReference: Our unique identifier for the transaction.

    • resultCode
  2. Use the resultCode from the /payments/details endpoint to present the payment result to the shopper in your app.

    You can track the status of the payment using notifications.

WeChat Pay result codes

The resultCode you will receive for WeChat Pay is:

  • Pending: The shopper has completed the payment but the final result is not yet known. It may take minutes or hours WeChat to confirm this. Inform the shopper that you've received their order, and are waiting for the payment to be completed.   You receive a  notification when the status of the payment has been updated. If successful, you will receive the funds in 2 days.

To find out more about result codes, see Result codes.

WeChat Pay notifications

If you're accepting WeChat Pay payments you will need to set up notifications to know whether a payment is successful. Each WeChat Pay notification has a:

  • pspReference: identifies which payment is being referred to.
  • eventCode: indicates the status of the payment.

If you haven't already set up notifications, refer to our notifications documentation for instructions.

Successful payments

You'll know a WeChat Pay payment has been successful when you receive a notification with:

  • eventCodeAUTHORISATION.
  • successtrue.

Testing in-app payments

Before accepting payments from your shoppers, test your setup. There is currently no test platform for WeChat Pay. If you have a personal WeChat account you can test your integration by either:

  • Making live WeChat Pay payments with a low value.
  • Cancelling the transaction when you are asked to verify the payment.

You can check the status of a WeChat Pay payment in your Customer Area > Transactions > Payments.

See also