[JS-SDK] Trying to upgrade a subscription with a prorata charge, but still can't understand how

eLiosh
Contributor
Contributor

Hi to all,

I'm trying to solve an "upgrade your current plan" problem.

 

I've created two plan for the same product: both have a duration of 1 month, one has a price of 15€ and the second one has a price of 40€.

 

If a user buyed the cheaper one, I'd like to let him pay the difference if he tries to buy the expensive one.

 

I've tried with this js-code: 

 

revise_obj.plan = {};
revise_obj.plan.billing_cycles = [
  {
    sequence: 1,
    total_cycles: 1,
    tenure_type: "TRIAL",
    frequency: {
      interval_unit: "DAY",
      interval_count: 1
    },
    pricing_scheme: {
      fixed_price: {
        value: selector.dataset.prorata,
        currency_code: "EUR",
      },
    },
  },
  {
    sequence: 2,
    total_cycles: 0,
    tenure_type: "REGULAR",
    frequency: {
      interval_unit: "MONTH",
      interval_count: 1
    },
    pricing_scheme: {
      fixed_price: {
        value: selector.dataset.price,
        currency_code: "EUR",
      },
    },
  }
];
return actions.subscription.revise(settings.megapro.subscription_id, revise_obj);

 

 

But I have this error in developer console: 

Error: Revise Subscription Api HTTP-422 response: error:

{
    "name": "UNPROCESSABLE_ENTITY",
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "debug_id": "f4150769c579b",
    "details": [
        {
            "field": "/plan/billing_cycles/1/sequence",
            "value": "2",
            "location": "body",
            "issue": "INVALID_BILLING_CYCLE_SEQUENCE",
            "description": "The provided billing cycle sequence is not available."
        }
    ],
    "links": [
        {
            "href": "https://developer.paypal.com/docs/api/v1/billing/subscriptions#UNPROCESSABLE_ENTITY",
            "rel": "information_link",
            "method": "GET"
        }
    ]
}

 

 

I've tried also with a setup_fee, but without luck.

 

Do someone solved this problem ?

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.