Plan
Plan: Update
- Callback
- Promise
gateway.plan.update(
"aPlanId",
{
id: "newId",
name: "Awesome Bar",
description: "Incredibly Mediocre",
price: "2.00"
}, (err, result) => {
}
);
notFoundError
.
Arguments
id
required, StringAdditional Parameters
The collection of add-ons associated with a plan. Add-on details can only be managed within the Control Panel.
add
arrayamount
Stringdescription
StringinheritedFromId
Stringname
StringnumberOfBillingCycles
Stringremove
arrayupdate
arrayamount
Stringdescription
StringexistingId
Stringname
StringnumberOfBillingCycles
StringbillingDayOfMonth
integer or stringbillingFrequency
integer or stringcurrencyIsoCode
Stringdescription
StringA collection of discounts associated with this plan. Discount details can only be managed within the Control Panel.
add
arrayamount
Stringdescription
StringinheritedFromId
Stringname
StringnumberOfBillingCycles
Stringremove
arrayupdate
arrayamount
Stringdescription
StringexistingId
Stringname
StringnumberOfBillingCycles
Stringid
StringmodificationTokens
Stringname
StringneverExpires
boolean or stringnumberOfBillingCycles
integer or stringprice
decimal or stringtrialDuration
NumberThe 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-ons and discounts
There are two ways to add add_ons/discounts when updating a plan. First, modification tokens can be
passed along when updating a plan. A modification is either an add_on or a discount.
- Callback
- Promise
const modification_tokens = ["modification1_token", "modification2_token"];
gateway.plan.update(
"aPlanId",
{
id: "newId",
name: "Awesome Bar",
description: "Incredibly Mediocre",
price: "2.00",
modification_tokens: modification_tokens
}, (err, result) => {
});
- New add-ons/discounts can be added to the plan
- Existing add-ons/discounts associated with the plan can be updated
- Existing add-ons/discounts associated with the plan can be removed
- Callback
- Promise
gateway.plan.update("thePlanId", {
addOns: {
add: [{
inheritedFromId: "addOnId1",
amount: "25.00"
}],
update: [{
existingId: "addOnId2",
amount: "50.00"
}],
remove: ["addOnId3"]
},
discounts: {
add: [{
inheritedFromId: "discountId1",
amount: "7.00"
}],
update: [{
existingId: "discountId2",
amount: "15.00"
}],
remove: ["discountId3"]
}
}, (err, result) => {
// Handle result or error
});
Multiple updates
You can also add, update and remove multiple add-ons/discounts at the same time.
- Callback
- Promise
gateway.plan.update("thePlanId", {
addOns: {
add: [{
inheritedFromId: "addOnId1",
amount: "20.00"
}, {
inheritedFromId: "addOnId2",
amount: "30.00"
}],
update: [{
existingId: "addOnId3",
quantity: 2
}, {
existingId: "addOnId4",
quantity: 3
}],
remove: ["addOnId5", "addOnId_6"]
}
}, (err, result) => {
// Handle result or error
});
Override details
When adding add-ons/discounts, all details will be inherited from the add-on/discount specified by
the inheritedFromId. When updating add-ons/discounts, all details will
be inherited from the add-on/discount specified by the existingId. You
can override any of the following:
- amount
- numberOfBillingCycles
- name
- description
- Callback
- Promise
gateway.plan.update("thePlanId", {
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"
}]
}
}, (err, result) => {
// Handle result or error
});
Update trail period
Updating a plan removes "billing day of the month" when trialPeriod is
passed. In the example below, the plan will not have its "billing day of the month" after it is
updated.
- Callback
- Promise
gateway.plan.update("aPlanId", {
description: "Incredibly Mediocre",
trialPeriod: "2"
}, (err, result) => {
// Handle result or error
});