Alipay APIs
Alipay APIs
Designed to be clear, concise, and easy to integrate, Alipay APIs aim to reduce the complexity of high-availability applications and shorten development time. Alipay APIs are based on the HTTP protocol and are POST APIs, which use SHA256 and RSA algorithms to create digital signatures, accept JSON-encoded request bodies, and return JSON-encoded responses. The API request includes the API URL in the path, identity and signature information in the request header, and request parameters in the request body.
Call an API
To integrate with Alipay, you need to first make preparations in the Alipay Developer Center and get your client ID. You can then improve the integration by using Alipay APIs in a test mode, which does not affect your live data. We encourage testing the API call in the sandbox environment before launching your project and going live.
You can use Alipay-provided open SDKs to integrate with Alipay. If the programming language you use is Java, PHP, or Python, you can complete the process of assembling, signing, calling and checking the result of the HTTP request through the SDK provided by Alipay. Alipay SDKs encapsulate the process of integration, including adding and validating signatures for calling Alipay APIs.
The request address for the production and sandbox environments is only different in the path part of the request. You can first test Alipay APIs in the sandbox environment, which does not affect your data in the production environment. Once you have finished testing, migrate to the production environment by changing the request URL and other configurations.
Environment | Request URL |
---|---|
Sandbox | https://<domain_name>/ams/sandbox/api/<endpoint> (Online payments) https://<domain_name>/ams/api/<endpoint> (In-store payments) |
Production | https://<domain_name>/ams/api/<endpoint> (Online payments) https://<domain_name>/ams/api/<endpoint> (In-store payments) |
The domain name can be obtained from Alipay, and you can select one of the supported domain names listed below according to your region. If you are not sure which domain to use, contact Technical Support at overseas_support@service.alibaba.com for help.
Location | Domain Name |
---|---|
North America | https://open-na-global.alipay.com |
Asia | https://open-sea-global.alipay.com |
Europe | https://open-de-global.alipay.com or https://open-eu.alipay.com (Only for in-store payments) |
The following section shows samples of a typical Alipay API request and response:
POST /ams/api/v1/payments/inquiryPayment HTTP/1.1
Accept: application/json, text/plain, */*
Content-Type: application/json; charset=UTF-8
Request-Time: 1685599933871
client-id: 5J5XSU7Y2Y182W01981
Signature: algorithm=RSA256,keyVersion=1,signature=***
{"paymentId":"20200429114010800100188850266791455"}
{
"actualPaymentAmount": {
"currency": "PHP",
"value": "1314"
},
"paymentAmount": {
"currency": "PHP",
"value": "1314"
},
"paymentId": "20200513114010800100188770269589293",
"paymentRequestId": "REQUEST_20200513161204",
"paymentResultCode": "SUCCESS",
"paymentResultMessage": "success",
"paymentStatus": "SUCCESS",
"paymentTime": "2020-05-13T01:12:52-07:00",
"result": {
"resultCode": "SUCCESS",
"resultMessage": "success.",
"resultStatus": "S"
}
}
Alipay provides developer tools and resources to help you integrate quickly and efficiently. Make use of these tools to streamline your development process.
Explore more about Alipay APIs
- Overview Before you make any payments, it is important to understand how Alipay APIs works and how requests and responses are structured. This section presents general information (such as message structure and message transmission workflow) of online messages between your system and Alipay.
- Sign a request and validate the signature To guarantee that data has not been altered in transmission, digital signatures can be adopted. A digital signature is mandatory for all messages.
- Message encoding To prevent errors or ambiguity caused by special characters enclosed in a message, encode the message properly before transmitting it.
- API change history Release notes about Alipay APIs.
APIs and notifications for Alipay payment products
Different APIs are designed for different payment scenarios. Use the specific API for your payment collection case. Alipay also provides notifications to send the payment result to the merchant when the payment processing reaches a final state of success or failure.
Online payments
Note: Notification for online payment products: notifyPayment, notifyAuthorization, notifyRefund, notifyCapture, and notifyDispute.
In-store payments
Note: Notification for in-store payment products: notifyPayment, notifyRegistrationStatus