Simplify Node.js API Docs

API Docs for:
Show:

Subscription Class

Defined in: simplify.js:2097

This is a Simplify domain object. In order to get access to a domain object, a client needs to be created. The client is then used to invoke the different methods e.g.

var client = Simplify.getClient({
                            publicKey: 'YOUR_PUBLIC_API_KEY',
                            privateKey: 'YOUR_PRIVATE_API_KEY'
                        });
                        
                        client.subscription.METHOD_NAME(params, function(error, data){
                            if(error){
                                // handle the error
                            }
                        
                            // Awesome...no error, handle the data
                        });
                        

Constructor

Subscription

(
  • appKeys
)

Defined in simplify.js:2097

Parameters:

  • appKeys Object

    Object containing the public & private API keys

Item Index

Methods

create

(
  • params
  • callback
)

Defined in simplify.js:2123

Function to create a Subscription object.

Parameters:

  • params Object

    A map of parameters in which to create the Subscription from.

    Valid parameters include:

    • amount : Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00
    • billingCycle : How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
    • billingCycleLimit : The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
    • coupon : Coupon ID associated with the subscription
    • currency : Currency code (ISO-4217). Must match the currency associated with your account.
    • currentPeriodEnd : End date of subscription's current period
    • currentPeriodStart : Start date of subscription's current period
    • customer : Customer that is enrolling in the subscription.
    • frequency : Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
    • frequencyPeriod : Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly.
    • name : Name describing subscription [max length: 50]
    • plan : The ID of the plan that should be used for the subscription.
    • quantity : Quantity of the plan for the subscription. [min value: 1]
    • renewalReminderLeadDays : If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null, then no emails are sent. Minimum value is 7 if set.
    • source : Source of where subscription was created

    NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.

    {
                                                        param: {
                                                        subParam1: 'value', 
                                                        subParam2: 'value'
                                                    }
                                                }
  • callback Function

    A function to handle success/error responses from the API.
    The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.

delete

(
  • A
  • callback
)

Defined in simplify.js:2163

Function to delete a Subscription object.

Parameters:

  • A Object

    string ID of the Subscription to delete.

  • callback Function

    A function to handle success/error responses from the API.
    The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.

find

(
  • id
  • callback
)

Defined in simplify.js:2209

Function to retrieve a Subscription object from the API.

Parameters:

  • id String

    The ID of the Subscription to retrieve

  • callback Function

    A function to handle success/error responses from the API.
    The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.

list

(
  • params
  • callback
)

Defined in simplify.js:2180

Function to retrieve a list Subscription objects.

Parameters:

  • params Object

    A map of parameters in which to define the Subscription list from.

    Valid parameters include:

    • filter :
      filter.customerFilter by the Id of the customer with the subscription
      filter.planFilter by the Id of the plan linked to the subscription
      filter.dateCreatedMinFilter by the minimum created date you are searching for - Date in UTC millis
      filter.dateCreatedMaxFilter by the maximum created date you are searching for - Date in UTC millis
      filter.qYou can use this to filter by the Id, the name or the amount of the subscription

      *Use dateCreatedMin with dateCreatedMax in the same filter if you want to search between two created dates
    • max : Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20]
    • offset : Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0]
    • sorting : Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either 'asc' for ascending or 'desc' for descending).
      Sortable properties are:
      • dateCreated
      • id
      • plan

    NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.

    {
                                                        param: {
                                                        subParam1: 'value', 
                                                        subParam2: 'value'
                                                    }
                                                }
  • callback Function

    A function to handle success/error responses from the API.
    The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.

update

(
  • params
  • callback
)

Defined in simplify.js:2226

Function to update a Subscription object.

Parameters:

  • params Object

    A map of parameters on which to update the Subscription object.

    Valid parameters include:

    • id : A string ID of the Subscription object to update
    • amount : Amount of the payment in the smallest unit of your currency. Example: 100 = $1.00
    • billingCycle : How the plan is billed to the customer. Values must be AUTO (indefinitely until the customer cancels) or FIXED (a fixed number of billing cycles). [default: AUTO]
    • billingCycleLimit : The number of fixed billing cycles for a plan. Only used if the billingCycle parameter is set to FIXED. Example: 4
    • coupon : Coupon being assigned to this subscription
    • currency : Currency code (ISO-4217). Must match the currency associated with your account.
    • currentPeriodEnd : End date of subscription's current period
    • currentPeriodStart : Start date of subscription's current period
    • frequency : Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY".
    • frequencyPeriod : Period of frequency of payment for the plan. Example: if the frequency is weekly, and periodFrequency is 2, then the subscription is billed bi-weekly. [min value: 1]
    • name : Name describing subscription
    • plan : Plan that should be used for the subscription.
    • prorate : Whether to prorate existing subscription. [default: true] (REQUIRED)
    • quantity : Quantity of the plan for the subscription. [min value: 1]
    • renewalReminderLeadDays : If set, how many days before the next billing cycle that a renewal reminder is sent to the customer. If null or 0, no emails are sent. Minimum value is 7 if set.

    NOTE: Any parameters with a sub-parameter (e.g. param.subParam) need to be nested when passed as an argument in e.g.

    {
                                                        param: {
                                                        subParam1: 'value', 
                                                        subParam2: 'value'
                                                    }
                                                }
  • callback Function

    A function to handle success/error responses from the API.
    The function takes 2 parameters, the first is an error object. This is null if no error occurs. The second parameter is the response data. This is null if an error occurs.