This article covers
One time coupon is getting reapplied when upgrading the plan using API
Summary
The merchant faces an issue of a one-time coupon being reapplied while reactivating a canceled subscription.
Please find the steps below which the merchant executed:
Subscribe with coupon code (coupon code name: "test") and we get a discount of 30% which is expected. API used chargebee.HostedPage.checkout_new_for_items)
Cancel the subscription from the Chargebee portal (without issuing the credit - Option chosen).
Reactivate the subscription by using the API (chargebee.HostedPage.checkout_existing_for_items). We have received the error message in the UI (Chargebee popup) when we enter the coupon code "test".
Verify the invoice, we can see that the coupon code has been applied again.
Solution
Please find the observations below:
Initially, they are creating a subscription using the plan which has a 14 days trial via the checkout_new_for_items API endpoint and they are adding the coupon on checkout
So when they add the coupon to the subscription it is just added to the subscription but it's not applied/consumed
Then when they try to update the subscription via checkout_existing_for_items API endpoint by removing the trial period (subscription[trial_end]) and reactivating the subscription the already added coupon gets applied/consumed which is expected