Alipay, China's leading third-party online payment solutionAlipay, China's leading third-party online payment solutionDOCS

      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.

      #Calling 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.

      CLIENT LIBRARIES

      For different payment scenarios, specific SDKs for Java, Python, and PHP are provided. Use the right SDK according to your need. Refer to the README.md section to learn more about how to use SDKs.

      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/<endpoint> (Online payments)
      https://<domain_name>/ams/<endpoint> (In-store payments)
      Production https://<domain_name>/ams/<endpoint> (Online payments)
      https://<domain_name>/ams/<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.

      REQUEST
      copy
      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"}
      RESPONSE
      copy
      {
          "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

      #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.

      Note: Notification for online payment products: Payment Result Notification

      In-store payments

      Consumer-presented mode payment
      Order code payment
      Entry code payment

      Note: Notification for in-store payment products: Payment Result Notification