Skip to main content
Version: Lastest

API Create plan

Endpoint: /api/v1/subs/plans

Method: POST

Header Params

ParamRequiredTypeDescriptionNote
X-APPOTAPAY-AUTHrequiredString How to generate JWT_TOKEN
Content-TyperequiredStringValue: application/json
X-Request-IDoptionalStringUUIDv4 format. Request ID to check when a problem occursmax:42
LanguageoptionalStringThe value vi or en corresponding to the payment link will be Vietnamese or English, (default: vi)

in:vi,en

{
"X-APPOTAPAY-AUTH": "JWT_TOKEN",
"Content-Type": "application/json",
"X-Request-ID": "Your_Unique_id",
"Language": "vi"
}

Request params

ParamRequiredTypeDescriptionNote
partnerRefIdRequiredStringUnique reference code of partnermin:1, max: 50, format: alphanumeric
customerIdRequiredStringCustomer ID
currencyRequiredStringCurrency unitin: VND
amountRequiredIntegerPayment amount
paymentMethodsRequiredArrayPayment method list
paymentMethods.*.paymentMethodIdRequiredStringPayment method ID
paymentMethods.*.rankRequiredIntegerIndicate the order which payments methods will be attempted for a payment cycle instance. Available values - 1 to 5min: 1
immediateActionTypeOptionalString

Charge immediately when successfully creating the plan, null: charge at anchorDate time

- FULL_AMOUNT: charge when successfully initializing the plan

in: FULL_AMOUNT
failedCycleActionRequiredString

Action of plan when the payment cycle fails

- STOP: Stop the plan

- RESUME: Skip the failed cycle and proceed to the next cycle

in: STOP, RESUME
scheduleRequiredObjectObject containing the configurations of how Subscriptions cycles will be scheduled
schedule.intervalRequiredStringThe type of interval between consecutive Subscriptions cycles.in: DAY, WEEK, MONTH
schedule.intervalCountRequiredIntegerThe number of units of interval between consecutive Subscriptions cyclesmin: 1
schedule.totalRecurrenceOptionalInteger

The total number of times the end user will be charged

If the parameter is not used, Subscriptions plan will run on indefinitely

min: 1
schedule.anchorDateOptionalString

Time to make recurring payments

Default: the date of schedule creation

Supported values: Timestamps between 1st to 28th of a month

Note: if anchorDate is null or date of schedule creation falls on 29/30/31, anchor date will be defaulted to 1st of next month

format: ISO-8601
schedule.retryIntervalOptionalStringThe type of interval between failed attempt and retries.in: DAY
schedule.retryIntervalCountOptionalIntegerThe number of times you will retry a failed Subscriptions cycle. If no value is passed intomin:1
schedule.totalRetryOptionalInteger

The number of times you will retry a failed Subscriptions cycle.

If no value is passed into total_retry, it will be null by default and no retries will be triggered

min:1, max: 10

Example Request

{
"partnerRefId": "ASKJLKALK299",
"customerId": "01HRVGAJSP7SX83X7AQ9QQYMBE",
"currency": "VND",
"amount": 85000,
"paymentMethods": [
{
"paymentMethodId": "01HRVJY8ZMZFHRHE3KG2S24KKW",
"rank": 1
}
],
"immediateActionType": "FULL_AMOUNT",
"failedCycleAction": "STOP",
"schedule": {
"interval": "DAY",
"intervalCount": 1,
"totalRecurrence": 3,
"anchorDate": "2024-01-13T15:23:40+07:00",
"retryInterval": "DAY",
"retryIntervalCount": 1,
"totalRetry": 1
}
}

Response data

Success

Http Status Code 200 - OK

Success responses will contain a single Plan object

Failure

HTTP Status Code != 200

Error response params

ParamRequiredTypeDescription
errorCoderequiredIntegerError code
messagerequiredStringError message
errorsoptionalArrayDetailed error description
errors.*.fieldoptionalStringField data is corrupted
errors.*.reasonoptionalStringDescription of the data field in error
{
"errorCode": 1,
"message": "Missing or Invalid Params",
"errors": [
{
"field": "partnerRefId",
"reason": "The partner ref id field is required."
}
]
}

Common error code table

Full error code, please check this error code list

Error codeDescription
0Success
1Missing or Invalid Params
11Partner is not found
13Partner has been blocked
14API Key is invalid
15API Key is not activated or blocked
92IP is not allowed to access
99Undefined error, please contact AppotaPay for more detailed information
401Unauthorized
500Server error
3002Duplicate partnerRefId, please try again
3003Customer not exist
3004Payment method not exist
3012Payment method is invalid