문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top