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 URL of API 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 calling process 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 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 are different only 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.alipay.com |
Asia | https://open-sea.alipay.com |
Europe | 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: 2020-04-29T17:18:47+08:00
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
- API fundamentals Before you make any payments, it is important to understand how Alipay APIs work and how requests and responses are structured. This section presents general information of online messages, such as request message and response message between your system and Alipay.
- Digital signature To guarantee that data has not been altered in transmission, digital signatures and encryption mechanisms can be adopted. For all messages, a digital signature is mandatory.
- Encryption The encryption algorithm RSA or PGP can be used for data transmission. Data encryption is required if sensitive information is enclosed in the message.
- 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 successful final state.
Online payments
Note: Notification for online payment products: notifyPayment
In-store payments
Note: Notification for in-store payment products: notifyPayment