Adding proration behaviour to Stripe API plugin

Hi all,

I’m trying to alter the behaviour of the Stripe plugin so that prorated subscription changes are billed automatically. I notice that Stripe has parameters for proration_behavior which can be set along with billing_cycle_anchor and collecting_method. I have added these as a separate API call after the “Subscribe the user to a plan call” which works but the problem is for this to work the user must have a card saved.

To counter that I added a collect user’s CC information event if the card was not set but the issue with that is the later steps don’t see the updated card details if there is a delay in processing and an error is thrown by Stripe.

I was thinking of triggering a scheduled backend workflow that would update the billing anchor and proration method after a delay but I can see an issue with this too if the user changes their plan and then immediately changes it again. So I’m thinking of storing the scheduled api id so it can be cancelled if the plan is changed again but I feel like I’m going down a rabbit hole and there must be an easier way.

My workflow is as follows

I think I’ve decided just to use the Stripe customer portal. It seems you can deep link into the preview pages so I can still present a plan picker and redirect to the plan change preview page directly in the portal by dynamically building the URL.