We are using Stripe payment processing for our customer's subscriptions. When users change plans, we want them to be charged immediately for the prorated difference. Stripe does this automatically when plans have different billing intervals but when changing between plans with the same interval, Stripe defers payment till the next billing period.
The way we handle this now is to create an invoice after updating the subscription, but if the billing fails for it fails, we need to do a rollback.
stripe.subscriptions.update(/* change plan */);
if (plans_have_different_billing_intervals) {
try {
stripe.invoices.create(/* for all pending charges */);
} catch (err) {
/* rollback subscription to old plan */
}
}
Overall, this feels wrong and convoluted. Is there an easier/cleaner way to implement this that we aren't seeing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…