Alipay CN
Topics covered on this page
AlipayCN lets you accept online payments from Alipay users on your website or in your mobile app. Customers can pay in the Alipay app on a smartphone, by scanning a QR code with the Alipay app, or by logging in to Alipay on a computer. You do not need an Alipay merchant account or a Chinese bank account to accept AlipayCN payments through Omise.
The following guide explains how AlipayCN payments work, how to enable AlipayCN, how to accept AlipayCN payments with the Omise API, and how to refund and void AlipayCN charges.
Note: AlipayCN (source type alipay_cn) replaces the legacy Alipay (Online) integration (source type alipay), which will be deprecated. For the legacy integration, see Alipay (Online).
AlipayCN at a glance
| Item | Value |
|---|---|
| Supported countries | Thailand, Singapore |
| Currencies | THB (Thailand), SGD (Singapore) |
Source type |
alipay_cn |
| Payment flow | app_redirect |
| Customer platforms | Mobile app and website (platform_type: IOS, ANDROID, or WEB) |
| Charge amount limits (Thailand) | THB 20.00 to THB 150,000.00 |
| Charge amount limits (Singapore) | SGD 1.00 to SGD 20,000.00 |
| Void cutoff | The first 00:15 GMT+8 (23:15 Thailand time) after the charge is created |
| Minimum API version | 2017-11-02 |
| How to enable | Email support@omise.co |
How AlipayCN payments work
AlipayCN sources use the app_redirect flow. Your website or mobile app redirects the customer to the Alipay checkout page, where the customer authorizes and confirms the payment. The customer then returns to your website or app.
The customer can pay with AlipayCN in the following ways:
| Customer device | How the customer pays |
|---|---|
| Smartphone | In the Alipay app |
| Computer | By scanning a QR code with the Alipay app on a smartphone |
| Computer | By logging in to their Alipay account |
The following screenshots show the AlipayCN payment flow on a smartphone and on a computer. The numbers in each step match the numbers in the screenshot.
AlipayCN payment flow on a smartphone

- The customer selects the wallet to pay with (1).
- The customer is redirected to the wallet app to confirm the payment (2).
- The wallet app shows the payment details (3).
- The customer taps Back to merchant to return to the confirmation page on your website or app (4).
AlipayCN payment flow on a computer

- The customer selects the wallet to pay with (1).
- A QR code is displayed (2).
- The customer opens the wallet app on their smartphone and opens its QR code scanner (3).
- The customer scans the QR code (4).
- The wallet app shows a payment summary, and the customer confirms the payment (5).
- The wallet app shows the payment confirmation slip, and the customer can return to the payment confirmation page on your website (6).
After you receive the charge.complete webhook event, confirm the payment result with the customer.
Enable AlipayCN
AlipayCN is available to Omise merchants in Thailand and Singapore and requires API version 2017-11-02 or later.
To enable AlipayCN, email support@omise.co and request AlipayCN for your Omise account.
Accept AlipayCN payments with the Omise API
Your public key and secret key are on the keys page of your dashboard.
An AlipayCN integration has four steps:
- Create an AlipayCN source.
- Create an AlipayCN charge with the source.
- Redirect the customer to Alipay to authorize the charge.
- Confirm the result of the AlipayCN charge.
Choose how to create the source and charge:
| Method | Keys used | When to use |
|---|---|---|
| Create the source and charge separately | Public key for the source, secret key for the charge | You create the source on the client (the customer's browser or mobile app) with Omise.js or an Omise mobile SDK, and create the charge on your server. |
| Create the source and charge in one request | Secret key only | Your server creates both the source and the charge. |
The following sequence diagram shows the full AlipayCN integration flow when you create the source and charge separately.
Step 1: Create an AlipayCN source
When the customer chooses to pay with AlipayCN, create a source with type set to alipay_cn. You can create the source with Omise.js, the Omise mobile SDK for iOS or Android, or the Sources API.
If your server creates the source and charge in one request, skip to Create an AlipayCN source and charge in one request.
AlipayCN source parameters:
| Parameter | Type | Description |
|---|---|---|
amount |
integer | (required) Charge amount in the smallest currency unit. For example, 150000 is SGD 1,500.00. For minimum and maximum amounts, see AlipayCN charge amount limits. |
currency |
string | (required) Three-letter ISO 4217 currency code: SGD for Singapore or THB for Thailand. |
type |
string | (required) alipay_cn |
platform_type |
string | (optional) Platform the customer pays on: IOS, ANDROID, or WEB. |
The following examples create an AlipayCN source for SGD 1,500.00 on the web platform. Replace omise_public_key and $OMISE_PUBLIC_KEY with your test public key.
Note: In Omise.js, pass the source type as the first argument of Omise.createSource, not inside the options object.
Create an AlipayCN source with Omise.js:
Omise.setPublicKey(omise_public_key);
Omise.createSource('alipay_cn', {
"amount": 150000,
"currency": "SGD",
"platform_type": "WEB"
}, function(statusCode, response) {
console.log(response);
});
Create an AlipayCN source with curl:
curl https://api.omise.co/sources \
-u $OMISE_PUBLIC_KEY: \
-d "amount=150000" \
-d "currency=SGD" \
-d "type=alipay_cn" \
-d "platform_type=WEB"
Example AlipayCN source response:
{
"object": "source",
"id": "src_test_62dumpling8tea3buns",
"livemode": false,
"location": "/sources/src_test_62dumpling8tea3buns",
"amount": 150000,
"barcode": null,
"bank": null,
"created_at": "2024-10-31T02:05:49Z",
"currency": "SGD",
"email": null,
"flow": "app_redirect",
"installment_term": null,
"ip": "203.0.113.42",
"absorption_type": null,
"name": null,
"mobile_number": null,
"phone_number": null,
"platform_type": "WEB",
"scannable_code": null,
"billing": null,
"shipping": null,
"items": [],
"references": null,
"provider_references": null,
"store_id": null,
"store_name": null,
"terminal_id": null,
"type": "alipay_cn",
"zero_interest_installments": null,
"charge_status": "unknown",
"receipt_amount": null,
"discounts": [],
"promotion_code": null
}
The id attribute is the source ID. Source IDs begin with src_. Send the source ID to your server to create the charge.
Step 2: Create an AlipayCN charge
Create a charge with your secret key and the following parameters:
| Parameter | Description |
|---|---|
amount |
(required) Must match the amount of the source. |
currency |
(required) Must match the currency of the source. |
source |
(required) The source ID from step 1. |
return_uri |
(required) The page on your website where the customer is redirected after authorizing the payment. Must be an HTTPS URL. |
Create an AlipayCN charge from a source ID
Replace $OMISE_SECRET_KEY with your test secret key and $SOURCE_ID with the source ID.
curl https://api.omise.co/charges \
-u $OMISE_SECRET_KEY: \
-d "amount=150000" \
-d "currency=SGD" \
-d "return_uri=https://example.com/orders/345678/complete" \
-d "source=$SOURCE_ID"
Example AlipayCN charge response:
{
"object": "charge",
"id": "chrg_test_62lantern5noodles77",
"location": "/charges/chrg_test_62lantern5noodles77",
"amount": 150000,
"acquirer_reference_number": null,
"net": 145650,
"fee": 4350,
"fee_vat": 0,
"interest": 0,
"interest_vat": 0,
"funding_amount": 150000,
"refunded_amount": 0,
"transaction_fees": {
"fee_flat": "0.0",
"fee_rate": "2.9",
"vat_rate": "0.0"
},
"platform_fee": {
"fixed": null,
"amount": null,
"percentage": null
},
"currency": "SGD",
"funding_currency": "SGD",
"ip": null,
"refunds": {
"object": "list",
"data": [],
"limit": 20,
"offset": 0,
"total": 0,
"location": "/charges/chrg_test_62lantern5noodles77/refunds",
"order": "chronological",
"from": "1970-01-01T00:00:00Z",
"to": "2024-10-31T02:05:50Z"
},
"link": null,
"description": null,
"metadata": {},
"card": null,
"source": {
"object": "source",
"id": "src_test_62dumpling8tea3buns",
"livemode": false,
"location": "/sources/src_test_62dumpling8tea3buns",
"amount": 150000,
"barcode": null,
"bank": null,
"created_at": "2024-10-31T02:05:49Z",
"currency": "SGD",
"email": null,
"flow": "app_redirect",
"installment_term": null,
"ip": "203.0.113.42",
"absorption_type": null,
"name": null,
"mobile_number": null,
"phone_number": null,
"platform_type": "WEB",
"scannable_code": null,
"billing": null,
"shipping": null,
"items": [],
"references": null,
"provider_references": null,
"store_id": null,
"store_name": null,
"terminal_id": null,
"type": "alipay_cn",
"zero_interest_installments": null,
"charge_status": "pending",
"receipt_amount": null,
"discounts": [],
"promotion_code": null
},
"schedule": null,
"linked_account": null,
"customer": null,
"dispute": null,
"transaction": null,
"failure_code": null,
"failure_message": null,
"status": "pending",
"authorize_uri": "https://pay.omise.co/payments/pay2_test_62teapot4mooncakes8/authorize?acs=false",
"return_uri": "https://example.com/orders/345678/complete",
"created_at": "2024-10-31T02:05:50Z",
"paid_at": null,
"authorized_at": null,
"expires_at": "2024-11-07T02:05:49Z",
"expired_at": null,
"reversed_at": null,
"multi_capture": false,
"zero_interest_installments": false,
"branch": null,
"terminal": null,
"device": null,
"authorized": false,
"capturable": false,
"capture": true,
"disputable": false,
"livemode": false,
"refundable": false,
"partially_refundable": false,
"reversed": false,
"reversible": false,
"voided": false,
"paid": false,
"expired": false,
"can_perform_void": false,
"approval_code": null
}
A new AlipayCN charge has a status of pending and an authorize_uri. Step 3 uses the authorize_uri.
Create an AlipayCN source and charge in one request
To create the source and charge in a single server-side request, use your secret key and pass the source parameters as source[...] fields instead of a source ID.
curl https://api.omise.co/charges \
-u $OMISE_SECRET_KEY: \
-d "amount=150000" \
-d "currency=SGD" \
-d "return_uri=https://example.com/orders/345678/complete" \
-d "source[type]=alipay_cn" \
-d "source[platform_type]=WEB"
The response is a charge object in the same format as the preceding example response.
Step 3: Redirect the customer to authorize the AlipayCN charge
Redirect the customer to the URL in the charge's authorize_uri. The customer authorizes the payment with Alipay, as described in How AlipayCN payments work.
After the customer completes authorization, the customer is redirected to the URL in return_uri.
Step 4: Confirm the result of the AlipayCN charge
Use a webhook to learn when an AlipayCN charge is complete:
- Set up an endpoint on your server to receive webhook events.
- Add the endpoint URL on the webhooks page of your dashboard.
- When you receive the
charge.completeevent, retrieve the charge by itsidand confirm that itsstatusmatches thestatusin the event. Retrieving the charge is optional but recommended.
AlipayCN charge statuses:
status |
Meaning |
|---|---|
pending |
The payment is not complete yet. |
successful |
The payment is complete. |
failed |
The payment failed. Check the charge's failure_code and failure_message attributes for the reason. |
expired |
The charge expired before the customer paid. |
AlipayCN failure codes:
failure_code |
Description |
|---|---|
payment_expired |
Payment expired. |
payment_rejected |
Payment rejected by the issuer. |
failed_processing |
General payment processing failure. |
invalid_account |
No valid account was found for the payment method. |
insufficient_fund |
The account has insufficient funds, or the payment method has reached its limit. |
For all charge attributes, see the Charges API.
Test AlipayCN payments
In test mode, open the charge's authorize_uri to use the web simulator, and mark the charge as Successful or Failed.
Refund and void AlipayCN charges
Request AlipayCN refunds through the Refunds API.
A refund requested before the first 00:15 GMT+8 after the charge is created is processed as a void. A refund requested at or after the cutoff is processed as a refund. In Thailand time (GMT+7), the void cutoff is 23:15.
For example, an AlipayCN charge is created at 15:00 GMT+8 (14:00 Thailand time) on 20 January. A refund requested before 00:15 GMT+8 on 21 January (23:15 Thailand time on 20 January) is processed as a void. A refund requested at or after that time is processed as a refund.
AlipayCN charge amount limits
Amounts are in the smallest currency unit.
| Country | Currency | Minimum amount | Maximum amount |
|---|---|---|---|
| Thailand | THB |
2000 (THB 20.00) |
15000000 (THB 150,000.00) |
| Singapore | SGD |
100 (SGD 1.00) |
2000000 (SGD 20,000.00) |
FAQ
What is the difference between AlipayCN and Alipay (Online)?
AlipayCN uses source type alipay_cn and replaces the legacy Alipay (Online) integration, which uses source type alipay. The alipay source type will be deprecated, so use alipay_cn for new integrations.
Which countries and currencies does AlipayCN support?
AlipayCN supports Omise merchants in Thailand (THB) and Singapore (SGD).
How do I enable AlipayCN?
Email support@omise.co and request AlipayCN for your Omise account.
Do I need an Alipay account or a Chinese bank account?
No. Omise lets you accept AlipayCN payments without an Alipay merchant account or a Chinese bank account.
What are the minimum and maximum AlipayCN charge amounts?
In Thailand, the minimum is THB 20.00 and the maximum is THB 150,000.00. In Singapore, the minimum is SGD 1.00 and the maximum is SGD 20,000.00.
What values does platform_type accept?
The platform_type parameter accepts IOS, ANDROID, or WEB. The parameter is optional.
What is the AlipayCN void cutoff time?
A refund requested before the first 00:15 GMT+8 after the charge is created is processed as a void, and a refund requested at or after the cutoff is processed as a refund. In Thailand time (GMT+7), the cutoff is 23:15. For details, see Refund and void AlipayCN charges.
How do I refund an AlipayCN charge?
Request the refund through the Refunds API. Omise processes the request as a void or as a refund, depending on whether the request is made before the void cutoff.
How do I test AlipayCN payments?
In test mode, open the charge's authorize_uri and mark the charge as Successful or Failed in the web simulator.