I’ve created a custom PaidPlans signup experience for my users - it works fine.
However if user wishes to upgrade from Plan A to Plan B (or vice-versa) what is the proper api workflow?
I assume the following:-
1 - identify user’s current plan and display option button to select alternative plan.
2 - if user chooses another plan, then cancel user’s current plan and order the new plan
But I foresee numerous problems. What if user backs out of new plan order - we can’t leave them with no plan - we need to rollback to previous plan, for example.
I don’t wont user to have > 1 plan or < 1 plan.
Any ideas very gratefully received.
Hi
When users try to upgrade their plan, you better wait for the new plan purchase to succeed, THEN cancel their previous plan, this way, if the purchase failed for any reason, they’ll still got their plan, and when the purchase is completed successfully, the old plan will be cancelled.
I also highly recommend putting this code a module on the Backend for better results, so even if users close their browser after upgrading, the cancel process might not be done, and they’ll get away with two plans, but running this code on the Backend won’t give them a chance.
Hope that helped~!
Ahmad
Excellent - many thanks @Ahmad that’s very helpful. Makes good sense.
You’re welcome If you need any assistance feel free to post a new question or you can tag me or contact me.
@ahmadnasriya Thanks Ahmad - I am now getting back into this project and I have identified wix-paid-plans-backend has a built-in event “onPlanPurchased”. I’m hoping to use this event to trigger the following actions:-
-
identify the subscriber (maybe with: wix-users-backend.currentUser
-
obtain a dataset of all Plans subscribed by this member (maybe: wix-uers.user.getPricingPlans( ).
-
try to figure out which Plan is the old plan? (would it be the first plan or last plan??) - then delete that subscription using wix-paid-plans.cancelOrder( ).
I would much appreciate your comments. Is this a workable approach?