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

create

POST /v1/subscriptions/create

Use the create API to initiate a subscription creation request. After this API is called successfully, you can get the authorization URL and redirect the user to the URL to authorize the subscription. After the user authorizes the subscription successfully, Alipay initiates an automatic deduction in each subscription period and notifies you of the payment result.  

Structure

A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:

Note: Set the data type of each field (except array) as String. This means that you must use double quotation marks (" ") to enclose the field value. Examples:

  • If the data type of a field is Integer and its value is 20, set it as "20".
  • If the data type of a field is Boolean and its value is true, set it as "true".  

Request parameters

subscriptionRequestId String  REQUIRED

The unique ID assigned by a merchant to identify a subscription request. Alipay uses this field for idempotency control.  

More information about this field

  • This field is an API idempotency field.For subscription requests that are initiated with the same value of subscriptionRequestId and reach a final status of S or F, the same result is to be returned for the request.
  • Maximum length: 64 characters

subscriptionDescription String  REQUIRED

The description of the subscription, used for displaying user consumption records and other actions. 

More information about this field

  • Maximum length: 256 characters

subscriptionRedirectUrl URL  REQUIRED

The merchant page URL that the user is redirected to after authorizing the subscription. 

More information about this field

  • Maximum length: 2048 characters

subscriptionStartTime Datetime  REQUIRED

The date and time when the subscription becomes active.  

More information about this field

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".

subscriptionEndTime Datetime  

The date and time when the subscription ends.

Specify this parameter when you want to designate the subscription end time.  

More information about this field

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".

periodRule PeriodRule object REQUIRED

The subscription period rule, used to define a subscription's billing period. 

Show child parameters

subscriptionExpiryTime Datetime  

A specific date and time after which the created subscription expires. When the subscription expires, the order must be terminated. The default value of this parameter is 30 minutes after the subscription creation request is sent.

Specify this parameter if you want to designate the subscription creation expiration time. The specified payment expiration time must be less than 48 hours after the subscription request is sent.  

More information about this field

  • The value follows the ISO 8601 standard format. For example, "2019-11-27T12:01:01+08:00".

paymentMethod PaymentMethod object REQUIRED

The payment method that is used to collect the payment by the merchant or acquirer.

Show child parameters

subscriptionNotificationUrl URL  

The URL that is used to receive the subscription result notification. 

You can also configure the subscription notification URL in Antom Dashboard. If you specify this URL in both this API and Antom Dashboard, the URL configured in the API takes precedence.  

Only one subscription notification URL can be configured in Antom Dashboard.

More information about this field

  • Maximum length: 2048 characters

paymentNotificationUrl URL  

The URL that is used to receive the payment result notification for each subscription period.

You can also configure the subscription notification URL in Antom Dashboard. If you specify this URL in both this API and Antom Dashboard, the URL configured in the API takes precedence.  

You can only configure one subscription notification URL in Antom Dashboard.

More information about this field

  • Maximum length: 2048 characters

orderInfo OrderInfo object REQUIRED

The order information for the subscription. This field is used for different purposes:

  • During the payment process, this field is mainly used by Alipay for risk control or anti-money laundering.
  • After the payment is completed, this field is used for recording and reporting purposes such as purchase tracking and regulatory reporting. 
Show child parameters

paymentAmount Amount object REQUIRED

The payment amount charged to the user per subscription period.  

Show child parameters

settlementStrategy SettlementStrategy object REQUIRED

The settlement strategy for the payment request. 

Show child parameters

env Env object REQUIRED

Information about the environment where the order is placed, such as the device information.  

Show child parameters

trials Array<Trial> object 

The list of trial information of a subscription.

Specify this parameter if the subscription includes any trial periods.  

More information about this field

  • Maximum size: Unlimited
Show child parameters

Response parameters

result Result object REQUIRED

Indicates whether this API is called successfully. If this API is successfully called, the subscription authorization URL is returned. 

Show child parameters

schemeUrl URL  

The URL scheme that redirects users to open an app in an Android or iOS system when the target app is installed.

When the value of result.resultCode is S, at least one of schemeUrl, applinkUrl, and normalUrl is to be returned. 

More information about this field

  • Maximum length: 2048 characters

applinkUrl URL  

The URL that redirects users to open an app when the target app is installed, or to open a WAP page when the target app is not installed. For Android, the URL is a Native App Link. For iOS, the URL is a Universal Link.

When the value of result.resultCode is S, at least one of schemeUrl, applinkUrl, and normalUrl is to be returned.  

More information about this field

  • Maximum length: 2048 characters

normalUrl URL  

The URL that redirects users to a WAP or Web page in the default browser or the embedded WebView.

When the value of result.resultCode is S, at least one of schemeUrl, applinkUrl, and normalUrl is to be returned. 

More information about this field

  • Maximum length: 2048 characters

appIdentifier URL  

An Android package name, which is used for Android app to open a cashier page.

This field is returned when result.resultCode is S and terminalType is APP or WAP. 

More information about this field

  • Maximum length: 128 characters
API Explorer
Sample CodesRun in Sandbox

Request

URL
Case
Subscription creation
Request Body

Response

Response Body

Result process logic

For different request results, different actions are to be performed. See the following list for details:

  • If the value of result.resultStatus is S, the authorization URL is successfully returned by the schemeUrl, applinkUrl, or normalUrl field in the response. You can redirect the user to this URL to authorize the subscription payment.
  • If the value of result.resultStatus is U, the API call status is unknown. You can call this API again to retry the process.
  • If the value of result.resultStatus is F, the authorization URL failed to be returned. Generally, this case is caused by system defects or system failure. Check the error codes and take the corresponding actions or contact Alipay technical support. 

Result/Error codes

CodeValueMessageFurther action
SUCCESSSSuccess

The interface is called successfully. Obtain schemeUrl, applinkUrl, or normalUrl from the response. 

ACCESS_DENIEDFAccess is denied.

Contact Alipay Technical Support for detailed reasons.  

CLIENT_FORBIDDEN_ACCESS_APIFAccess is denied.

Contact Alipay Technical Support for detailed reasons.  

INVALID_APIFThe called API is invalid or not active.

Contact Alipay Technical Support to resolve the issue.   

INVALID_CLIENT_STATUSFThe client status is invalid.

Contact Alipay Technical Support for detailed reasons.  

INVALID_SIGNATUREFThe signature is not validated. The private key used to sign a request does not match the public key of Antom Dashboard.

Check whether the private key used to sign a request matches the public key of Antom Dashboard. The following signature references are useful:

KEY_NOT_FOUNDFThe private key or public key of Alipay or the merchant is not found.

Check whether the private key or public key exists. If not, upload the private key in Antom Dashboard.  

MERCHANT_NOT_REGISTEREDFThe merchant is not registered.

Please register the merchant by using the registration interface. Contact Alipay Technical Support if failed to call the registration interface.  

OAUTH_FAILEDFOAuth process failed.

Contact Alipay Technical Support for detailed reasons.  

PARAM_ILLEGALFThe required parameters are not passed, or illegal parameters exist. For example, a non-numeric input, an invalid date, or the length and type of the parameter are wrong.

Check and verify whether the required request fields (including the header fields and body fields) of the current API are correctly passed and valid.  

PAYMENT_NOT_QUALIFIEDFThe merchant is not qualified to pay because the merchant is not registered, does not have a contract for Auto Debit payment, or is forbidden to make a payment.

Contact Alipay Technical Support for detailed reasons. 

PROCESS_FAILFA general business failure occurred.

Do not retry. Human intervention is usually needed. It is recommended that you contact Alipay Technical Support to troubleshoot the issue.  

RISK_REJECTFThe transaction cannot be further processed because of risk control. If the user has already paid for the transaction, the transaction will be refunded.

If the user does not receive the refund within two weeks, contact Alipay Technical Support.  

UNKNOWN_CLIENTFThe client is unknown.

Contact Alipay Technical Support for detailed reasons.  

REQUEST_TRAFFIC_EXCEED_LIMITUThe request traffic exceeds the limit.

Call the interface again to resolve the issue. If not resolved, contact Alipay Technical Support.  

UNKNOWN_EXCEPTIONUAn API call has failed, which is caused by unknown reasons.

Call the interface again to resolve the issue. If not resolved, contact Alipay Technical Support.  

REPEAT_REQ_INCONSISTENTFThe amount or currency is different from the previous request.

Ensure all the fields in the requests are the same or use a new subscriptionRequestId to initiate the payment again.