AliPay integration guide
AliPay through NihaoPay is a payment provider allowing customers to pay using payment methods saved to their AliPay account. This section is intended to help you implement AliPay based on your preferred integration workflow.
Services and compatibility
Payment method gateway name | NihaoPay |
Supported transaction types | |
Supported integration methods |
|
Supported processing currencies | CAD, CNY, EUR, GBP, HKD, JPY, USD |
Webhook event types |
|
Gateway-specific information
The following are not supported with AliPay:
- Kount
- Recurring billing
- Automatic payments
Configuration
Apart from working with Integrations to add AliPay as a payment method, you do not need to do any other configuration steps.
Required fields
The following table shows the required and optional fields for AliPay transactions in the Create APM one-time-use token request.
Field | Required? | Description |
---|---|---|
data.amount | Yes | The transaction amount. |
data.currency | Yes | The three-character ISO currency code for the transaction. For AliPay, supported currencies are CAD, CNY, EUR, GBP, HKD, JPY, and USD. |
data.customer.orderNumber | Yes | The order number. This must be less than 30 characters for AliPay. |
data.customer.firstName | Yes | The customer's first name, as it is set for the payment method. |
data.customer.lastName | Yes | The customer's last name, as it is set for the payment method. |
data.customer.email | Yes | The customer's email address. |
customerRedirectUrl | Conditional | The URL to which the customer will be redirected after completing their payment. The customer will be sent here upon successful or failed payment. This URL must use the HTTPS protocol. This field is required if you intend to use Nexio’s redirectUrls with your own buttons. |
data.cart.items[n].item | No | Item number or code. |
data.cart.items[n].description | No | A description of the item. |
data.cart.items[n].quantity | No | The quantity sold. |
data.cart.items[n].price | No | The price per item. |
data.customer.billToAddressOne | No | The street address for the customer. |
data.customer.billToCity | No | The city for the address record. |
data.customer.billToState | No | The state or province on file with the payment provider. (If in the US, this must be the two-character state abbreviation). |
data.customer.billToPostal | No | The postal code on file. |
data.customer.billToCountry | No | The two-character (Alpha-2) ISO country code. |
data.customer.billToPhone | No | The billing phone number. |
data.customer.billToAddressTwo | No | Additional street address information, if required. |
data.customer.customerRef | No | Customer identifier. You can use this field to pass a customer ID to the APM or to manage user subscriptions. |
data.customer.invoice | No | The invoice number. |
data.customer.shipToAddressOne | No | The shipping address, if different from the billing address. |
data.customer.shipToAddressTwo | No | Additional shipping address information, if required. |
data.customer.shipToCity | No | The shipping city. |
data.customer.shipToState | No | The shipping state or province. (If in the US, this must be the two-character state abbreviation). |
data.customer.shipToPostal | No | The shipping postal code. |
data.customer.shipToCountry | No | The two-character (Alpha-2) ISO shipping country code. |
data.customer.shipToPhone | No | The shipping phone number. |
data.customer.orderDate | No | The date of the customer's order. For specific details related to this parameter, see the Create APM one-time-use token endpoint. |
data.description | No | A description of the transaction. |
data.descriptor | No | Include this parameter to dynamically change the descriptor on the customer's statement. |
data.paymentMethod | No | The identifier for the alternative payment method. Use this parameter when you want to only return the AliPay iframe button URL (rather than data for all payment methods associated with the account). The value to use is nihaoPayAliPay . |
data.totalTaxAmount | No | Total tax amount. |
processingOptions.merchantId | No | The Nexio merchant ID (MID). |
processingOptions.paymentOptionTag | No | A custom value used to route transactions to a specific gateway or merchant account. |
uiOptions.displaySubmitButton | No | Set to true to include a submit button in the iframe. |
uiOptions.css | No | The URL where your custom CSS file is hosted. |
Example requests
The following are example one-time-use token requests for AliPay.
curl -X POST https://api.nexiopaysandbox.com/apm/v3/token \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Basic [Base64_encoded_login]'
-d '{
"data": {
"amount": 4.00,
"currency": "USD",
"paymentMethod": "nihaoPayAliPay",
"customer": {
"orderNumber": "12345678",
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]"
}
}
}'
A successful request returns a response similar to the following:
{
"expiration": "2018-09-18T15:43:05.664Z",
"token": "830d36f6-a5e3-4455-9600-3a55b63e2fc2",
"scriptUrl": "https://api.nexiopaysandbox.com/apm/v3/script?token=b61ca2a9-b804-4a28-a00e-b794c8975dee",
"expressIFrameUrl": "https://www.api.nexiopaysandbox.com/v3?token=79001ef6-fb40-4917-b8ae-2294fdfe1cf2",
"redirectUrls": [
{
"paymentMethod": "nihaoPayAliPay",
"url": "https://www.api.nexiopaysandbox.com/v3/popup?token=79001ef6-fb40-4917-b8ae-2294fdfe1cf2&paymentMethod=nihaoPayAliPay"
},
{
"paymentMethod": "nihaoPayUnionPay",
"url": "https://www.api.nexiopaysandbox.com/v3/popup?token=79001ef6-fb40-4917-b8ae-2294fdfe1cf2&paymentMethod=nihaoPayUnionPay"
},
{
"paymentMethod": "nihaoPayWechatPay",
"url": "https://www.api.nexiopaysandbox.com/v3/popup?token=79001ef6-fb40-4917-b8ae-2294fdfe1cf2&paymentMethod=nihaoPayWechatPay"
}
],
"buttonIFrameUrls": [
{
"paymentMethod": "nihaoPayAliPay",
"url": "https://api.nexiopaysandbox.com/apm/v3?token=b61ca2a9-b804-4a28-a00e-b794c8975dee&paymentMethod=nihaoPayAliPay"
},
{
"paymentMethod": "nihaoPayUnionPay",
"url": "https://api.nexiopaysandbox.com/apm/v3?token=b61ca2a9-b804-4a28-a00e-b794c8975dee&paymentMethod=nihaoPayUnionPay"
},
{
"paymentMethod": "nihaoPayWechatPay",
"url": "https://api.nexiopaysandbox.com/apm/v3?token=b61ca2a9-b804-4a28-a00e-b794c8975dee&paymentMethod=nihaoPayWechatPay"
}
]
}
For the multi iframe integration method: You use the expressIFrameUrl
value in the steps for the transaction.
For the individual iframe option: You use the buttonIFrameUrls.url
of the nihaoPayAliPay
APM for the transaction.
For the custom redirect option: You use the redirectUrls.url
of the nihaoPayAliPay
APM for the transaction.
Transaction types and integration methods
Regardless of the integration method workflow you implement, consumers are redirected to AliPay to complete their transactions.
Nexio supports the following transaction types for AliPay:
- Sale
- In an iframe that displays all payment methods available to the customer (based on the customer’s location and the merchant’s configured payment methods)
- In an individual iframe
- Refund
Testing data
For testing data, see AliPay Test Accounts on NihaoPay's website.
Response handling
In the one-time-use token request, AliPay gets returned in the paymentMethod
parameter as nihaoPayAliPay
.
Nexio responds with transaction results in one of the following ways, depending on your integration workflow:
- Event messages: This applies to integrations that do not pass a
customerRedirectUrl
in the request. - Response fields in the URL: This applies to integrations that do provide a
customerRedirectUrl
in the request.
In addition to one of the above, if your merchant account is configured to receive webhooks, Nexio provides responses to the webhook URLs that have been registered. For further explanation of the webhook event types, see the webhook Event types table.
For AliPay, these are the possible webhook event types:
- TRANSACTION_AUTHORIZED
- TRANSACTION_REFUNDED
- TRANSACTION_SETTLED
For information about how to run each of the integration workflows, see Transaction types and integration methods above.
Status workflows
The status of a successful transaction with AliPay varies, depending on the options you choose.
Sale | Successful sale transactions have the following statuses:
|
Refund | Successful refund transactions have the following status:
|
*Pending status displays as "authorized" or "AUTHORIZED" in the Nexio Dashboard; it displays as 10
, meaning "authorized", in the response when querying transactions (for more information about transactionStatus
, see the table).
Next steps
Now, you are ready to get started with running transactions:
If you have any additional questions or feedback, see Contact us.
Updated 2 months ago