Reputation: 8631
I have a rails app with stripe handling subscription payments. A subscription gives you a certain quota of messages to send and if you go over, I want to charge an overage fee for each message over the quota.
How should I go about doing this? How can I setup a stripe invoice (used for overages) right before the monthly subscription fee gets charged? I know how to do it right after a subscription fee gets charged (by listening to webhooks for a successful charge) but that doesn't seem like the right way of doing it.
Upvotes: 1
Views: 793
Reputation: 4288
Webhooks are still a right answer; you'd want the invoice.created
event. It fires when an invoice is created, and Stripe waits to actually charge the invoice until an hour after all your webhooks have succeeded (or until 3 days have passed, whichever's first).
You can also bill for each individual message (creating an invoiceitem
) as it happens if that makes more sense for your use case. They'll get rolled into the next invoice automatically.
Upvotes: 5