Preview a subscription

Changed on

Integrators can use this API Endpoint to generate a preview to ensure the subscription created is correct before calling the "Create Subscription API".

post/billing/subscriptions/preview

Request

  • Base URL
    https://api-sandbox.ezypay.com/v2
  • URL
    https://api-sandbox.ezypay.com/v2/billing/subscriptions/preview
  • Auth
    OAuth 2
    Client credentials
    Token URL: https://identity-sandbox.ezypay.com/token

Headers

merchantstring required

Merchant ID

Request body

customerIdstring required

Auto-generated identifier of the customer.

planIdstring required

Auto-generated identifier of the plan.

paymentMethodTokenstring

The payment method token generated by the vault.

markAsPendingboolean

Default value is false. If set to true, creates a subscription with a Pending status. A pending subscription will ignore the subscription's startDate and no schedules will be created. The status can be changed to Active using the Activate a subscription API.

startDatestring

The preferred start date of the subscription. The subscription start date cannot be back-dated. The default value follows the plan's start date. Supported format is YYYY-MM-DD.

namestring

The name of the plan to subscribe the customer to. Max of 50 characters.

accountingCodestring

Specify an accounting code to categorise revenue collected from the subscription's payment. Max of 50 characters.

intervalstring

Number to be specified as interval to manipulate billing frequency. For example interval=2 and intervalUnit=week would means billing every 2 weeks. If no value is provided, the default value is 1.

intervalUnitstring

Specifies frequency of billing. Valid values are day, week or month. If no value is provided, the default value is week.

billingStartstring

Specifies the default day the billing schedule starts for customers subscribed to the plan. Supported values are:

  • immediate - Default value. Subscriptions will start on the same day.
  • day_of_week - Subscriptions will start on a specific day as defined in billingStartValue. Only supported if intervalUnit = week OR intervalUnit = day
  • day_of_month - Subscriptions will start on specific day in the month as defined in billingStartValue. Only supported if interval = month
billingStartValuestring nullable

Value for billingStart.

  • immediate: not required (default null).
  • day_of_week: monday, tuesday, wednesday, thursday, friday, saturday or sunday (case-insensitive). Default monday: the schedule starts on the next Monday. Requires intervalUnit = week.
  • day_of_month: a whole number 1–31 (digits only). Default 1: the schedule starts on the next 1st of the month. 29, 30 or 31 are moved to the last day of shorter months. Requires intervalUnit = month.
billingEndstring

Specifies the rules to automate when a subscription ends. Supported values are:

  • ongoing - Default value. Subscriptions created from this plan will have no end date and continue billing on an ongoing basis (until instructions are given to stop billing).
  • amount_collected - Subscriptions will end when a specified amount is collected as defined in billingEndValue.
  • billing_cycles - Subscriptions will end after a specified number of billing cycles as defined in billingEndValue.
  • end_date - Subscriptions will end on date defined in billingEndValue.
billingEndValuestring nullable

Value for billingEnd. Required when billingEnd is set to anything other than ongoing.

  • ongoing: not required (default null).
  • amount_collected: total amount to collect before the subscription ends, e.g. "500.00".
  • billing_cycles: number of billing cycles before the subscription ends, e.g. "12". For a one-off subscription use "1".
  • end_date: last billing date in YYYY-MM-DD format.
firstBillingstring

Specifies the rules to auto-calculate the billing charges for the first scheduled billing. The default value follows the plan's firstBilling. Supported values are: full_amount - The first billing will charge the full amount on the subscription as defined in the plan's amount. prorate - Prorate will be auto-calculated for the first billing in the subscription for the pro-rated period, with full recurring billing amount starting from the next billing cycle.

metadataobject

Store additional data about the subscription object using key/value pairs format. Max of 40 characters for key name and 255 characters for key value

autoPaymentboolean

Specify if auto payment processing occurs for invoices generated from the subscription. Supported value are: true - Default value. Invoices generated will automatically proceed to payment processing. false - Invoices are generated but will not automatically proceed to payment processing.

customerEmailNotificationboolean

Specify if an email notification is sent to the customer informing them that the subscription was created or activated. Supported values are: true - An email notification will be sent to the customer to inform them that this subscription was created or activated no matter what was specified under the merchant notification settings. false - No email notification is sent to the customer to inform them that this subscription was created or activated no matter what was specified under the merchant notification settings. If not specified, follows what was defined in the merchant notification settings.

Example request

{
  "billingStartValue": "15",
  "billingEndValue": "12"
}

Response

200

Example response

{
  "data": [
    {
      "id": "fef9bef0-2081-445d-8a4e-b50a5d9eb2b7",
      "customerId": "4c999653-9473-472e-b478-d56d2a7572a9",
      "planId": "d35f6384-e5af-4eaf-b4c9-d08511a21921",
      "name": "high_st_monthly_plan",
      "status": "ACTIVE",
      "startDate": "2019-04-01",
      "paymentMethodToken": "d178cea3-fdf9-4743-90d8-856af429ab18",
      "accountingCode": "customer_plan",
      "amount": {
        "currency": "NZD",
        "value": 200
      },
      "nextBillingDate": "2019-06-01",
      "interval": 1,
      "intervalUnit": "MONTH",
      "totalPaid": {
        "currency": "NZD",
        "value": 400
      },
      "totalBillingCycles": 2,
      "totalPastDue": {
        "currency": "NZD"
      },
      "totalDiscounted": {
        "currency": "NZD"
      },
      "createdOn": "2019-03-31T23:55:11.708",
      "autoPayment": true
    }
  ],
  "paging": {
    "totalCount": 1
  }
}

Changes