Search

Are you looking for test card numbers?

Would you like to contact support?

Alipay

Learn how to accept Alipay payments using our Checkout SDKs or our API.

Alipay is the most widely used third-party online payment service provider in China. With over 100 million daily transactions and over 520 million active users. 

The shopper can either initiate a transaction and pay directly on their mobile device using a PIN, or scan a QR code from a desktop using their mobile device.

Once a transaction is initiated with Alipay, the offer stays open for 12 hours. This means the shopper can complete their payment up to 12 hours after it was initiated.

Payment Type Payment flow Recurring Refunds Partial Refunds Captures Partial Captures Chargebacks
Wallet Yes No Yes Yes - Yes No  

You can accept Alipay payments with:

Integrate with Checkout SDKs

Our Checkout SDKs support Alipay without any additional configuration. You can verify payment results from the payment response, or set up notifications.

Integrate with API

In this section, we show the API integration steps for Alipay.

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

Step 1: Get payment methods

Call /paymentMethods , specifying:

  • amount - The value of the transaction.
  • countryCode - The shopper's country code.
  • channel - The shopper's channel, iOS, Android, or Web.
{
  "merchantAccount":"YourMerchantAccount",
  "countryCode":"CN",
  "amount":{
    "currency":"CNY",
    "value":1000
  },
  "channel":"Web"
}

Response

{
    "name": "AliPay",
    "type": "alipay"
},

Step 2: Redirect shopper

Make a /payments API call, providing:

  • amount - The value of the transaction.
  • paymentMethod.type set to:

    • alipay to use the desktop flow (i.e. QR code displayed on the website)
    • alipay_wap to redirect to the mobile app.
    • alipay_hk - For payments in Hong Kong. Alipay HK uses smart routing to determine whether the shopper is on desktop or mobile.
  • returnUrl - A URL the shopper will be redirected to after they complete the payment.
{
  "merchantAccount": "YourMerchantAccount",
  "amount": {
    "currency": "CNY",
    "value": 1000
  },
  "reference": "Your order number",
  "paymentMethod": {
    "type": "alipay"
  },
  "returnUrl": "https://your-company.com/..."
}

This returns a /payments response with a redirect object containing:

  • paymentData - the result of the payment containing the payload.
  • redirect object containing a url. Redirect the shopper here so that they can complete the payment.
{
  "resultCode":"RedirectShopper",
  "details":[
    {
      "key":"payload",
      "type":"text"
    }
  ],
  "paymentData":"sdfsdf...",
  "redirect":{
    "method":"GET",
    "url":"https://test.adyen.com/hpp/skipDetails.shtml?brandCode=alipay&sdfsdf..."
  }
}

Step 3: Handle redirect

After the shopper has completed the payment, they are redirected back to the returnUrl you specified in the Step 2. The redirect contains multiple parameters, you only need the payload query parameter to complete the payment.

https://your-company.com/?payload=sdfsdf...&type=complete&resultCode=authorised

Step 4: Present payment result

Submit the the payload returned in the query parameters to the /payments/details/ endpoint.

{
  "details":{
    "payload":"sdfsdfsdf..."
  }
}

This will return a resultCode that is generally the same as the resultCode in the redirect parameters. You'll also receive a pspReference, which is our unique identifier for this payment, and your merchantReference.

Use the resultCode returned in the redirect to immediately display a result page to the shopper or call /payments/details/ first. You should handle the resultCode as specified in Result Codes.

Alipay result codes

The resultCode values you can receive for Alipay are:

  • authorised: The payment was successful. You will receive the funds in 3 days.
  • cancelled: The shopper canceled the payment while on the Alipay website. Ask them to select a new payment method.
  • refused: The payment was refused by the shopper's bank.

Alipay notifications

Our notifications are webhooks informing you of important events related to your account. Although accepting notifications is not required for Alipay payments, we strongly recommend that you do.

To inform you of the outcome of a payment, we send you a notification with:

  • pspReference: Adyen's unique reference associated with the payment request.
  • eventCode: AUTHORISATION.
  • success: Indicates the outcome of the payment. Possible values:

    • true: The payment was authorised.
    • false: The payment failed.

AUTHORISATION is just one of the events that trigger a notification. Refer to Notification webhooks to accept notifications and learn about their structure and content.

Test your integration

Test Alipay payments using the details we provide on our test card numbers page.
You can check the status of an Alipay test payment in your Customer Area > Transactions > Payments.