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-Account-Ref-IDoptionalString

Iidentifier of the sub account provided by AppotaPay.

Mandatory be passed over when processing payment for transactions of owner-type sub account

{
"X-APPOTAPAY-AUTH": "JWT_TOKEN",
"Content-Type": "application/json",
"X-Request-ID": "Your_Unique_id",
"Language": "vi",
"X-Account-Ref-ID": "9723f73b-9295-4acb-884b-ab6310c2e653"
}

Request params

ParamRequiredTypeDescriptionNote
planRefIdRequiredString

Unique reference code of partner.

Partner-provided identifier for the plan. Requests with a duplicate planRefId will return an error.

min:1, max: 50, format: alphanumeric
customerIdRequiredStringCustomer ID
currencyRequiredStringCurrency unitin: VND
amountRequiredIntegerPayment amountmin: 5000, max: 100000000
countryConditional, if paymentMethods doesn't have informationString

Country code of transaction

Accepted value

- ID: Indonesia

- PH: Philippines

- VN: Vietnam

- TH: Thailand

- MY: Malaysia

Format ISO 3166-2 Country Code
returnUrlConditional, if paymentMethods doesn't have informationString

URL where the end-customer is redirected

AppotaPay will send the result via the URL with some parameters like this: LINK

paymentMethodsOptionalArray

Payment method list

(Only show if the integration model is Merchant hosted)

paymentMethods.*.paymentMethodIdOptionalStringPayment method ID
paymentMethods.*.rankOptionalIntegerIndicate the order which payments methods will be attempted for a payment cycle instance. Available values - 1 to 5min: 1
paymentLinkForFailedAttemptOptionalString

Receive payment link in the webhook if payment cycle fails

- YES: receive payment link

- NO: do not receive payment links

default: NO, in: YES,NO
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
serviceNameOptionalString

Service name of subscription plan

(Only show if the integration model is Checkout Page)

max:30
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.retryIntervalConditional, required if paymentLinkForFailedAttempt = 'YES'StringThe type of interval between failed attempt and retries.in: DAY
schedule.retryIntervalCountConditional, required if paymentLinkForFailedAttempt = 'YES'IntegerThe number of times you will retry a failed Subscriptions cycle. If no value is passed intomin:1
schedule.totalRetryConditional, required if paymentLinkForFailedAttempt = 'YES'Integer

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
notificationConfig.[subscription.cycle.retrying]OptionalArray

Specify which channel you want to notify your customer through when the cycle is unsuccessful, so it's necessary to attempt the next time

Accepted value ["EMAIL"]

notificationConfig.[subscription.cycle.succeeded]OptionalArray

Specify which channel you want to notify your customer through when the cycle is successfully completed

Accepted value ["EMAIL"]

notificationConfig.[subscription.cycle.failed]OptionalArray

Specify which channel you want to notify your customer through when the cycle failed

Accepted value ["EMAIL"]

notificationConfig.[subscription.plan.activated]OptionalArray

Specify which channel you want to notify your customer through when the subscription plan is activated

Accepted value ["EMAIL"]

notificationConfig.[subscription.plan.inactivated]OptionalArray

Specify which channel you want to notify your customer through when the subscription plan is inactivated

Accepted value ["EMAIL"]

currencyExchangeOptionalObject
currencyExchange.amountOptionalNumber

Exchange amount

Supports 2 decimals, eg: 12.02

min: 0.10, max: 9999999999
currencyExchange.currencyOptionalString

Currency unit

Support: USD

Example Request

{
"planRefId": "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": "planRefId",
"reason": "The plan 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 reference code of partner, please try again
3003Customer not exist
3004Payment method not exist
3012Payment method is invalid