I need help regarding changing and updating customer plan/price id subscription using Stripe.js plugin.
What is the best way to implement this. Currently what I am doing is when customer wants to change plan or billing interval and [if customer already has existing subscription], I will Cancel current subscription and Create a new Subscription? Since I am cancelling subscription (potentially unused one as well], do I need to refund the amount paid (with proration=yes)?
Stripe.js have Subscription Update workflow but there is nothing in it for me to change any plan or price id.
I havenāt check the recent update of Stripe.js plugin, but from a glance at the version update, none mentioned about the Subscription Updateās plan/price id.
Please share with me if you have any solution for this.
So I got this figured out at least for my purposes, and for argumentās sake I used bubbleās-stripe plugin rather than Stripe.js - but you can use either one.
So this is what you need:
Under Settings/API ā Enable Workflow API and backend workflows needs to be checked
2 Create a table to capture charges - Include fields: Invoice_ID, Charge_ID, Subscription_ID, Customer_ID
In Your Stripe account you need to create a couple of webhooks ā This is found under the developerās menu item
In Bubble your last item where you expend the search for pages will be backend workflows
From here you have to create a new API workflow - Create one for subscription update
Click on āDetect Dataā button
Bubble will now display a url with āInitiate at the endā - copy this URL
In Stripe Create a webhook for when subscription is updated
Go back to bubble. Bubble and Stripe now will make a connection where stripe will send a whole bunch of data to bubble - make sure you create a record in your newly created table and capture the Invoice_ID, Subscription_ID and Customer_ID
You also need to create a webhook for when a charge is succeeded - from there you need to update your charge table record (where āinvoice idā from subscription update = āinvoice idā from charge succeeded) capture charge amount and charge_id.
Now you should have all the data you need to process a refund on a subscription.
In order to process a refund, there might be another way, but I used an API Connector plugin - where you have to connect to Stripe
Thank you so so so much for taking the time to write the step by step guide for me. The process that you explained means you are canceling userās current subscription (with refund) and create a new subscription, is it?
I am using Stripeās Subscription feature thus I am not using Charge.
I will take time to fully digest what you have mentioned above.
Iām sure @pawelodrās way of doing it works, and Using the Bubble Stripe plugin for this is definitely a good idea.
To update the subscription without cancelling and starting a new one (therefore letting Stripe deal with the proration calculation), here is what I did on an app I built:
store the SubscriptionID in the Userās DB when subscribing to a plan for the first time
use the Subscribe the user to a plan action (Bubble plugin) when you want to update the subscription
check both boxes (āApply this action to the current userā and āUpdate existing subscriptionā)
inform the Userās SubscriptionID and specify the new plan_id
Thank you so much @ambroisedlg for contributing in your knowledge. I didnāt use Bubbleās Stripe plugin, only Stripe.js plugin due to its features and I read it somewhere that Bubble is not updating/maintaining the stripe plugin anymore hence I am using Stripe.js .
Can I use both plugin at the same time, probably will use Bubbleā Stripe plugin for āupdatingā existing subscription? I will give it a try soon.
For the scenario of a User has already paid and subscribed to more expensive plan and moving to cheaper plan in the middle, using Bubbleā Stripe [ āUpdate existing subscriptionā)] , I still need to do the refund workflow or it is automated by Stripe?
Iām also using Stripe.js + API Connector for everything else - Iām just using Bubbleās plugin for the Update Subscription, so yes you can definitely use both together
Each Customer in Stripe has a balance, and Stripe calculates the proration automatically. Iām not sure they refund automatically, but I think they charge less on the following billing period. Iām not entirely sure though so I would suggest you do some tests in Stripe first!
From what I have read in stripe documentation, stripe does not refund automatically, and does charge less the following billing period. This did not necessarily work for me, as my two subscriptions have different time periods - one is annual and the other monthly, which means that if a user switches from monthly to annual subscription, the user would initially have to pay the whole amount for the new subscription and would have to wait a year in order to have the prorated amount credited to the next payment - at least this is how I understand the process. https://stripe.com/docs/api/subscriptions/cancel#cancel_subscription-prorate
Hence the additional refund process in bubble.
I hope this helps.
By the way, every time your customer is charged, you might not see it, but you are using Charge.
When subscribing, Stripe creates a subscription and an invoice, when you collect money (which might happen instantly), stripe references the invoice and assigns a charge to it to reference the payment. You can capture the charge through a stripe webhook and use it to process a refund.
In my experience this isnāt true though - if a User pays a $50USD monthly subscription, and then switches to a $500USD annual, the prorated amount spent for the current month will be deducted from the $500USD.
However the problem lies where the User wants to switch from annual to monthly, in that case youāre right, a manual refund is required.
Do you mind clarifying the way you work with API Connector when integrating Stripe? I decided to use this thread and not create a new one since I think itās relevant to the discussion.
Iāve successfully integrated Stripe using similar approach, it was mostly manual API calls and in testing environment it worked nicely. Now it must be deployed to live. What I 've done for other things with manual calls before was creating duplicates for every API call, changing keys to live version and checking āIsnāt live versionā condition in workflows to run dev or live API call version. Is there a simpler (more maintainable) way to handle dev/live versions?
Thanks,
Andrey
(Btw, I updated subscriptions without the plugin, as I understand Stripe should handle proration even when switching from billing period to another, itāll change invoicing date but other things should be the same. I believe you donāt have to manually refund in this case - never tested though)