We can upgrade or downgrade a subscription by changing the plan within the same Product using the /v1/billing/subscriptions/{id}/revise
endpoint. We have to provide the new Plan ID in the Post body for our existing subscription within the Product.
I have two plans in my current application Basic
and Professional
. This is what their billing cycles look like after creation.
// Billing Cycle for Basic[ { frequency: { interval_unit: 'DAY', interval_count: 7, }, sequence: 1, tenure_type: 'TRIAL', pricing_scheme: { fixed_price: { value: '0', currency_code: 'USD', }, }, total_cycles: 1, }, { frequency: { interval_unit: 'MONTH', interval_count: 1, }, sequence: 2, tenure_type: 'REGULAR', pricing_scheme: { fixed_price: { value: '10', currency_code: 'USD', }, }, total_cycles: 0, // 0 means infinite },];// Billing Cycle for Premium[ { frequency: { interval_unit: 'DAY', interval_count: 7, }, sequence: 1, tenure_type: 'TRIAL', pricing_scheme: { fixed_price: { value: '0', currency_code: 'USD', }, }, total_cycles: 1, }, { frequency: { interval_unit: 'MONTH', interval_count: 1, }, sequence: 2, tenure_type: 'REGULAR', pricing_scheme: { fixed_price: { value: '20', currency_code: 'USD', }, }, total_cycles: 0, // 0 means infinite },];
What I want
What I want is that once the user buys a Basic
Plan let's say and after 3 days he wants to upgrade it to Premium
then I don't want to start as a free trial
in the premium plan but as a Regular
billing cycle, which means I want to skip the trial part when a user upgrades his/her subscription.
What I have researched
I have found that in the revise-endpoint you can also send one plan
object to customize the subscription, see here: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_revise
So when making a request I was passing plan like this:
// making request using Paypal SDK, I know it's deprecated but I will change that later request.requestBody({ plan_id: priceId, application_context: { ....// info here }, plan: { billing_cycles: [ { sequence: 1, total_cycles: 0, // I was thinking it would remove trial, I know for regular one this is interpreted as infinity }, { sequence: 2, total_cycles: 0, frequency: { interval_unit: "DAY", interval_count: 1 } } ] }, });//But I got this error from the PayPal{"name":"UNPROCESSABLE_ENTITY","issue":"INVALID_TRIAL_BILLING_TOTAL_CYCLES","description":"Total cycles for trial billing must be greater than '0'."}]....]}// other attempt I made is to start from sequence 2 directly but this doesn't work// I didn't got the error using below but it I think included trial from existing// price_id I am passing as a plan_id request.requestBody({ plan_id: priceId, application_context: { ....// info here }, plan: { billing_cycles: [ { sequence: 2, total_cycles: 0, frequency: { interval_unit: "DAY", interval_count: 1 } } ] }, });
I have also read this community forum: https://www.paypal-community.com/t5/REST-APIs/subscription-create-override-plan-frequency-interval/td-p/3033004
Looks like I have to create a different plan but still want to know if anyone came across this kind of problem in their application.
References