Skip to main content

Advanced Subscriptions

Advanced subscriptions are recurrent payments that can:

  1. Recur with any interval, e.g. every 3 months
  2. Start at a certain time, not immediately
  3. Change payment amount over time
  4. Continue for a finite number of payments, not indefinitely

You can set the subscription rules with by passing the subscription field to the widget or the API when creating a payment. The subscription parameter is an array of type SubscriptionItem.

Code Example

Let's create a subscription that has an "introductory rate" of $10.00 for the first 3 months, then changes to $50.00 per month in perpetuity. In addition, starting after 6 months, the user should be billed $100.00 every 6 months in perpetuity.

<button onclick="atlos.Pay({
merchantId: '8XOZ64KC9X',
orderId: '123456',
orderCurrency: 'USD',
userName: 'John Smith',
userEmail: 'name@email.com',
subscription: [
{
amount: 10.00,
unit: atlos.RECURRENCE_MONTH,
interval: 1,
paymentCount: 3,
},
{
amount: 50.00,
unit: atlos.RECURRENCE_MONTH,
interval: 1,
startInterval: 3,
},
{
amount: 100.00,
unit: atlos.RECURRENCE_MONTH,
interval: 6,
startInterval: 1,
},
]})">
Pay & Subscribe
</button>

SubscriptionItem Type

export type SubscriptionItem = {
amount: number,
unit: number,
interval?: number,
startInterval?: number,
startDate?: string,
paymentCount?: number,
}

Field Description

FieldTypeRequiredDescriptionDefault
amountnumberyesamount to bill in orderCurrency
unitnumberyesthe time unit for the recurrence interval, e.g. atlos.RECURRENCE_MONTH
intervalnumbernorecurrence interval, e.g. 3 months1
startIntervalnumbernostart date measured in intervals from now, e.g. start in 2 months0
startDatestringnostart date; the date format must be YYYY-MM-DDnull
paymentCountnumbernototal number of payments for this entry; if omitted, then bills until cancelednull

If both, the recurrence and the subscription are specified, the subscription value will be used.

If both, the startInterval and the startDate are specified, the startDate will be used.

When using the subscription parameter, you do not need to specify the orderAmount, as it will be computed automatically. However, if you do specify the orderAmount, it will override the computed subscription amount and your payment will be for the orderAmount.