Plan
Plan: Update
See also the Plan response object.
- Python
result = gateway.plan.update("a_plan_id", {
"id": "new_id",
"name": "Awesome Bar",
"description": "Incredibly Mediocre",
"price": "2.00"
})
If the plan can't be found, it will throw a NotFoundError
exception.
Arguments
id
required, strAdditional Parameters
The collection of add-ons associated with a plan. Add-on details can only be managed within the Control Panel.
'add'
array'amount'
Decimal'name'
str'remove'
array'update'
array'amount'
Decimal'name'
str'billing_day_of_month'
integer or string'billing_frequency'
integer or stringA collection of discounts associated with this plan. Discount details can only be managed within the Control Panel.
'add'
array'amount'
Decimal'name'
str'remove'
array'update'
array'amount'
Decimal'name'
str'id'
str'name'
str'never_expires'
boolean or string'number_of_billing_cycles'
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.
day
or month
.'trial_period'
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.
- Python
result = gateway.plan.update("a_plan_id", {
"id": "new_id",
"name": "Awesome Bar",
"description": "Incredibly Mediocre",
"price": "2.00",
"modification_tokens": ["modification1_token", "modification2_token"]
})
Secondly, you can modify the add-ons and discounts by passing add_ons/discounts when updating a plan.
- 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
- Python
result = gateway.plan.update("the_plan_id", {
"add_ons": {
"add": [
{
"inherited_from_id": "add_on_id_1",
"amount": Decimal("25.00")
}
],
"update": [
{
"existing_id": "add_on_id_2",
"amount": Decimal("50.00")
}
],
"remove": ["add_on_id_3"]
},
"discounts": {
"add": [
{
"inherited_from_id": "discount_id_1",
"amount": Decimal("7.00")
}
],
"update": [
{
"existing_id": "discount_id_2",
"amount": Decimal("15.00")
}
],
"remove": ["discount_id_3"]
}
})
Multiple updates
You can also add, update and remove multiple add-ons/discounts at the same time.
- Python
result = gateway.plan.update("the_plan_id", {
"add_ons": {
"add": [
{
"inherited_from_id": "add_on_id_1",
"amount": Decimal("20.00")
},
{
"inherited_from_id": "add_on_id_2",
"amount": Decimal("30.00")
}
],
"update": [
{
"existing_id": "add_on_id_3",
"quantity": 2
},
{
"existing_id": "add_on_id_4",
"quantity": 3
}
],
"remove": ["add_on_id_5", "add_on_id_6"]
}
})
Override details
When adding add-ons/discounts, all details will be inherited from the add-on/discount specified by the inherited_from_id. When updating add-ons/discounts, all details will be inherited from the add-on/discount specified by the existing_id. You can override any of the following:
- amount
- number_of_billing_cycles
- name
- description
- Python
result = gateway.plan.update("the_plan_id", {
"add_ons": {
"add": [
{
"inherited_from_id": "add_on_id_1",
"amount": Decimal("20.00"),
"number_of_billing_cycles": 2,
"name": "NewName",
"description": "NewDescription"
}
],
"update": [
{
"existing_id": "add_on_id_2",
"amount": Decimal("15.00"),
"number_of_billing_cycles": 2,
"name": "NewName",
"description": "NewDescription"
}
]
},
"discounts": {
"add": [
{
"inherited_from_id": "discount_id_1",
"amount": Decimal("20.00"),
"number_of_billing_cycles": 2,
"name": "NewName",
"description": "NewDescription"
}
],
"update": [
{
"existing_id": "discount_id_2",
"amount": Decimal("15.00"),
"never_expires": True,
"quantity": 3
"number_of_billing_cycles": 2,
"name": "NewName",
"description": "NewDescription"
}
]
}
})
Update trail period
Updating a plan removes "billing day of the month" when trial_period is passed. In the example below, the plan will not have its "billing day of the month" after it is updated.
- Python
result = gateway.plan.update("a_plan_id", {
"description": "Incredibly Mediocre",
"trial_period": "2"
})