Create a Subscription
POST /subscriptionsplans/v1/subscriptions
Create a Subscription requests allow you to create customer subscriptions/ recurring payment schedules with Paysafe using active product plans.
Before sending an API request to create a subscription for a customer, you must convert the single-use payment handle token (SUT) provided by Paysafe on the initial verification/ authorization to a multi-use payment token (MUT). You must send the MUT as the paymentHandleToken of this API request.
Request Parameters
The request contains the following parameters:
Element | Child Element | Type | Required | Description |
---|---|---|---|---|
planId | string<uuid> | Yes | The Plan ID returned in the response of the Create a Plan request. | |
Authorization | string | Yes | Your Base64 encoded API Key Default: Basic BASE64-ENCODED-API-KEY | |
startDate | string<date> | No | Start date of the subscription and the date of the first billing. Date format = YYYY-MM-DD, ISO 8601 expected. UTC Date Format. Note: The start date CANNOT be in the past. Example: | |
additionalNumberOfCycles | number >= 0 <= 99 | No | The additional number of times this billing cycle is executed after the plan's number of cycles are executed. Note: The additional number of cycles can only be increased. | |
paymentHandleToken | string >= 0 chars <= 50 chars | Yes | The payment token generated by Paysafe Payments API that will be used for the Payment request. Example: | |
discountPercent | number >= 0 <= 100 | No | A discount that is applied on the subscription's payments. Example: | |
itemQuantity | number >= 1 | No | Indicates the quantity of goods and services provided in the subscription. When this field is specified, it will be used along with the plan.quantifiableAmount for the billing. Example: | |
merchantDescriptor | object | No | The merchant descriptor that will be displayed on the customer's card or bank statement. | |
dynamicDescriptor | string | No | A merchant descriptor that will be displayed on a customer’s card statement. | |
phone | string | No | Your merchant phone number that is appended to the merchant descriptor on a customer’s card statement. | |
statusReason | object | Yes | Status Reason. | |
initiator | string | Yes | Initiator of the status change reason. Allowed values:
| |
message | string | No | Description for the status change reason. | |
accountId | string >= 0 chars <= 36 chars | Yes | This is the account with which all of the payments will be processed. Note: The account currency should be the same with plan currency. | |
merchantRefNum | string >= 0 chars <= 255 chars | Yes | This is a unique ID that you can use for subscription look-up. Note: This ID is unique for this accountId. The payments will use other merchantRefNums that are internally generated. | |
status | string | No | Allowed value: | |
billingCycleHandling | string | No | Allowed values:
| |
initialTransactionId | string <= 36 chars | Id of the initial Recurring Payment transaction.
Note: This reference must meet PSD 2 authentication process requirements for merchant initiated transactions successfully. Example: | ||
externalInitialTransactionId | string <= 256 chars | Id of the initial Recurring Payment transaction in case this transaction was processed through external PSP. Note: This reference cannot be provided along with initialTransactionId. |
Response Parameters
The response parameters that are not included in the request are described below:
Element | Child Element | Type | Description | |||
---|---|---|---|---|---|---|
creationTime | string<date-time> | yyyy-MM-dd'T'HH:mm:ss'Z' | ||||
lastdUpdatedTime | string<date-time> | yyyy-MM-dd'T'HH:mm:ss'Z' | ||||
id | string<uuid> | An internally generated ID. | ||||
paymentType | string | The payment type associated with the Payment Handle used for this request. Example: | ||||
plan | object | |||||
name | string | The name of the plan. | ||||
description | string | The description of the plan. | ||||
amount | number | The amount of the plan, in minor units. Note: If your merchant account is set up for a currency that has 3 decimal units, our system will half round up the least significant digit. Example: | ||||
quantifiableAmount | number | If the subscription quantity is specified then this amount is multiplied by it. This is the quantifiableAmount of the plan, in minor units. Note: The same restriction applies as in the amount field. Example: | ||||
retryPolicy | object | Retry policy in case of failed payment. If this object is not present, a retry policy with default values will be used. Note: This setting will apply to all subscriptions. Disabling an active retryPolicy will CANCEL all pending retries. Example: | ||||
enabled | boolean | If this field is true, then the frequency and numberOfRetries must be provided. Default = true | ||||
frequency | string | The frequency of the retry attempts for the failed payment. Default = DAILY | ||||
numberOfRetries | number | Maximum number of retries that will be attempted for the failed payment. Default = 5 | ||||
setupFee | number | The fee which is used to set up a plan and it is charged only once at the beginning. This is the amount of the plan, in minor units. Note: If the merchant account is set up for a currency that has 3 decimal units, our system will half round up the least significant digit. Example: | ||||
billingCycle | object | This is the setup for the billing cycle. Example: | ||||
frequency | string | Frequency shows how often the payment for the plan will be executed. Example: | ||||
interval | number | The number of intervals after which a subscriber is billed. This field is required when a plan is created. Maximum interval count:
| ||||
numberOfCycles | number | The number of times this billing cycle gets executed. Billing cycles can be executed infinite times (value of 0 for numberOfCycles) or a finite number of times (value between 1 and 99 for numberOfCycles). This field is required when a plan is created. | ||||
startTime | string<date-time> | Start date and time of the plan. The ISO 8601 date format is expected, i.e., YYYY-MM-DD-THH:MM:SSZ. You cannot create subscriptions for this plan before this date. Example: | ||||
endTime | string<date-time> | End date and time of the plan. The ISO 8601 date format is expected, i.e., YYYY-MM-DD-THH:MM:SSZ. You cannot create subscriptions for this plan after this date. Not providing an end date means that the plan can be used indefinitely. Example: | ||||
subscriptionBehaviourOnDeactivation | string | This property controls what will happen with the plan's subscriptions when it is deactivated. The property must be provided either on plan creation or when its status is set to INACTIVE.
Example: | ||||
creationTime | string | yyyy-MM-dd'T'HH:mm:ss'Z' | ||||
lastUpdatedTime | string | yyyy-MM-dd'T'HH:mm:ss'Z' | ||||
id | string<uuid> | |||||
currencyCode | any | The currency code, for example, USD or CAD. See Currency Codes. Note: When creating a subscription, the currencyCode specified in the plan must match the processing currency of the account. Example: | ||||
trialPeriod | object | Trial period will be applied only at the beginning of the subscription. Example: | ||||
numberOfCycles | number | How many cycles the trial period will last. | ||||
frequency | string | Frequency shows how often the trial payment for the plan will be executed. | ||||
amount | number | The amount of the trial period, in minor units. Note: If your merchant account is set up for a currency that has 3 decimal units, our system will half round up the least significant digit. Example: | ||||
status | string |
| ||||
customerProfile | object | |||||
id | string<uuid> | The Customer ID in the system. | ||||
merchantCustomerId | string | The reference number for the customer that you create and submit as part of the request. It must be unique for each customer. | ||||
locale | string | Indicates the customer's locale preference. | ||||
firstName | string | The customer’s first name. | ||||
lastName | string | The customer’s last name. | ||||
dateOfBirth | object | |||||
year | number | The year of birth. | ||||
month | number | The month of birth. | ||||
day | number | The day of birth. | ||||
gender | string | Indicates the Customer's gender. | ||||
nationality | string | Indicates the Customer's nationality. | ||||
phone | string | The customer's phone number. | ||||
mobile | string | The customer's mobile number. | ||||
string | The customer's email address. | |||||
status | string | The status of customer in the system. | ||||
paymentsInformation | object | |||||
previousPayment | object | The last processed payment. | ||||
id | string | An internally generated ID from subscriptions API that is used as a merchantRefNum for the payment. | ||||
amount | number | The amount of the payment. | ||||
accountId | string | The account with which the payment will be processed. Note: This account is set on subscription creation. | ||||
paymentHandleToken | string | The payment token generated by Paysafe Payments API that will be used for the Payment request. | ||||
paymentType | string | The payment type associated with the Payment Handle used for this request. | ||||
scheduledTime | string<date-time> | The time when the payment is scheduled to be executed. | ||||
executionStage | string | The execution stage of the subscription. Example: | ||||
previousPaymentId | string<uuid> | A reference to the previous processed payment. | ||||
originalPaymentId | string<uuid> | A reference to the payment for which this retry is initiated. NOTE: This field is present only for retries. | ||||
numberOfRetriesLeft | number | The number of retries left initiated for a failed payment. NOTE: This field is present only for retries. | ||||
processedPaymentDetails | object | |||||
id | string | The ID that is returned from Payments API. | ||||
txnTime | string<date-time> | The date and time the request was processed. Example: | ||||
status | string | The status of the transaction request. Possible values are:
| ||||
error | object | |||||
code | string | The error code. Example: | ||||
message | string | A description of the error. Example: | ||||
merchantRefNum | string | |||||
nextPayment | object | The next payment of the billing cycle. | ||||
id | string | An internally generated ID from subscriptions API that is used as a merchantRefNum for the payment. | ||||
amount | number | The amount of the payment. | ||||
accountId | string | The account with which the payment will be processed. Note: This account is set on subscription creation. | ||||
paymentHandleToken | string | The payment token generated by Paysafe Payments API that will be used for the Payment request. | ||||
paymentType | string | The payment type associated with the Payment Handle used for this request. | ||||
scheduledTime | string<date-time> | The time when the payment is scheduled to be executed. | ||||
executionStage | string | The execution stage of the subscription. Example: | ||||
previousPaymentId | string<uuid> | A reference to the previously processed payment. | ||||
originalPaymentId | string<uuid> | A reference to the payment for which this retry is initiated. Note: This field is present only for retries. | ||||
numberOfRetriesLeft | number | The number of retries left initiated for a failed payment. Note: This field is present only for retries. | ||||
startTime | string<date-time> | Start date and time of the subscription and the first billing. The ISO 8601 date format is expected, i.e., YYYY-MM-DD-THH:MM:SSZ. Note: The start date CANNOT be in the past. Example: |