modeling – Creating models for for a subscription-based service using third-party payment gateways

If this question is too broad for Q&A format, I’d appreciate a pointer on where to ask it.

Suppose that you’re using Stripe (or some similar service) to manage the payments for a service of some sort. Stripe has built-in support for recurring payments, a payment gateway.

What I’m struggling to understand is how much of that logic is mirrored over to the application?

For example:

  • Where does the subscription/payment data is stored? Is it mirrored in some local DB or just wrapped from Stripe API?
  • How does one handle various states of a subscription that can’t be fulfilled (card declined, card missing, card fradulent)? Suppose that Stripe only handles payments and not subscriptions, how does one invalidate a subscription if a payment fails?

In other words, should User.first.subscription return something that’s stored in the application or essentially just make a call to Stripe every single time? If that’s the case, should my application not even have a Subscription model as it’s essentially just piped in from Stripe?

My gut is telling me in this case Stripe should handle the entirety of the payment and subscription logic and the service application itself should only wrap Stripe, is this fair to say?