Plan
Plan: Create
- PHP
$result = $gateway->plan()->create([
'name' => "the_name",
'billingFrequency' => "the_billing_frequency",
'currencyIsoCode' => "the_currency_iso_code",
'price' => "the_price"
]);
Parameters
The collection of add-ons associated with a plan. Add-on details can only be managed within the Control Panel.
'add'
array'amount'
String'description'
string'inheritedFromId'
string'name'
string'numberOfBillingCycles'
string'remove'
array'update'
array'amount'
String'description'
string'existingId'
string'name'
string'numberOfBillingCycles'
string'billingDayOfMonth'
integer or string'billingFrequency'
integer or string'currencyIsoCode'
string'description'
stringA collection of discounts associated with this plan. Discount details can only be managed within the Control Panel.
'add'
array'amount'
String'description'
string'inheritedFromId'
string'name'
string'numberOfBillingCycles'
string'remove'
array'update'
array'amount'
String'description'
string'existingId'
string'name'
string'numberOfBillingCycles'
string'id'
string'modificationTokens'
string'name'
string'neverExpires'
boolean or string'numberOfBillingCycles'
integer or string'price'
decimal or stringThe trial timeframe specified in a plan. It is required if the trial period is set to true and must be 1-3 digits. If you specify a trial duration of 0, the gateway will start the subscription immediately and not consider it to include a trial period.
'trialDurationUnit'
stringday
or month
.'trialPeriod'
boolA value indicating whether a subscription should begin with a trial period. If not specified on creation, the gateway will generate false by default. It cannot have both a specified billing date and a trial period.
Add add_ons/discounts when creating a plan
There are two ways to add add_ons/discounts when creating a plan. First, modification tokens can be
passed along when creating a plan. A modification is either an add_on or a discount.
- PHP
$result = $gateway->subscription()->create([
'name' => 'the_name',
'billing_frequency' => 'the_billing_frequency',
'currency_iso_code' => 'the_currency_iso_code',
'price' => 'the_price',
'modification_tokens' => array(
"modification1_token",
"modification2_token"
)
]);
- Add-ons/discounts that would be inherited from the plan can be updated on the plan.
- Add-ons/discounts that would be inherited from the plan can be removed from the plan.
- PHP
$result = $gateway->plan()->create([
'name' => 'the_name',
'billing_frequency' => 'the_billing_frequency',
'currency_iso_code' => 'the_currency_iso_code',
'price' => 'the_price',
'addOns' => [
'add' => [
[
'inheritedFromId' => 'addOnId1',
'amount' => '20.00'
],
[
'inheritedFromId' => 'addOnId2',
'amount' => '30.00'
]
],
'update' => [
[
'existingId' => 'addOnId3',
'description' => 'Updated description'
],
[
'existingId' => 'addOnId4',
'description' => 'Updated description'
]
],
'remove' => ['addOnId5', 'addOnId6']
],
'discounts' => [
'add' => [
[
'inheritedFromId' => 'discountId1',
'amount' => '7.00'
]
],
'update' => [
[
'existingId' => 'discountId2',
'amount' => '15.00'
]
],
'remove' => ['discountId3']
]
]);
- amount
- numberOfBillingCycles
- name
- description
- PHP
$result = $gateway->plan()->create([
'name' => 'the_name',
'billing_frequency' => 'the_billing_frequency',
'currency_iso_code' => 'the_currency_iso_code',
'price' => 'the_price',
'addOns' => [
'add' => [
[
'inheritedFromId' => 'addOnId1',
'amount' => '20.00',
'numberOfBillingCycles' => 2,
'name' => 'NewName',
'description' => 'NewDescription'
]
],
'update' => [
[
'existingId' => 'addOnId2',
'amount' => '15.00',
'numberOfBillingCycles' => 2,
'name' => 'NewName',
'description' => 'NewDescription'
]
]
],
'discounts' => [
'add' => [
[
'inheritedFromId' => 'discountId1',
'amount' => '20.00',
'numberOfBillingCycles' => 2,
'name' => 'NewName',
'description' => 'NewDescription'
]
],
'update' => [
[
'existingId' => 'discountId2',
'amount' => '15.00',
'numberOfBillingCycles' => 2,
'name' => 'NewName',
'description' => 'NewDescription'
]
]
]
});