Plan Class
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.plan.METHOD_NAME(params, function(error, data){
if(error){
// handle the error
}
// Awesome...no error, handle the data
});
Constructor
Plan
-
appKeys
Parameters:
-
appKeys
ObjectObject containing the public & private API keys
Methods
create
-
params
-
callback
Function to create a Plan object.
Parameters:
-
params
ObjectA map of parameters in which to create the Plan from.
Valid parameters include:- amount : Amount of payment for the plan in the smallest unit of your currency. Example: 100 = $1.00 (REQUIRED)
- 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
- currency : Currency code (ISO-4217) for the plan. Must match the currency associated with your account. [default: USD] (REQUIRED)
- frequency : Frequency of payment for the plan. Used in conjunction with frequencyPeriod. Valid values are "DAILY", "WEEKLY", "MONTHLY" and "YEARLY". [default: MONTHLY] (REQUIRED)
- 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, default: 1] (REQUIRED)
- name : Name of the plan [max length: 50, min length: 2] (REQUIRED)
- 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.
- trialPeriod : Plan free trial period selection. Must be Days, Weeks, or Month [default: NONE] (REQUIRED)
- trialPeriodQuantity : Quantity of the trial period. Must be greater than 0 and a whole number. [min value: 1]
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
FunctionA 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
Function to delete a Plan object.
Parameters:
-
A
Objectstring ID of the Plan to delete.
-
callback
FunctionA 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
Function to retrieve a Plan object from the API.
Parameters:
-
id
StringThe ID of the Plan to retrieve
-
callback
FunctionA 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
Function to retrieve a list Plan objects.
Parameters:
-
params
ObjectA map of parameters in which to define the Plan list from.
Valid parameters include:- filter :
filter.id Filter by the plan Id filter.text Filter by the name of the plan filter.frequency Filter by the frequency of the plan filter.amountMin & filter.amountMax The filter amountMin must be used with amountMax to find plans with plan values between the min and max figures filter.dateCreatedMin Filter by the minimum created date you are searching for - Date in UTC millis filter.dateCreatedMax Filter by the maximum created date you are searching for - Date in UTC millis filter.q You can use this to filter by the Id, the name or the amount of the plan
*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
- amount
- frequency
- name
- id
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' } }
- filter :
-
callback
FunctionA 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
Function to update a Plan object.
Parameters:
-
params
ObjectA map of parameters on which to update the Plan object.
Valid parameters include:- id : A string ID of the Plan object to update
- name : Name of the plan. [min length: 2] (REQUIRED)
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
FunctionA 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.