Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is mirroring Stripe (Subscriptions, Invoices, Coupons...) in your own local database efficient?

Is mirroring Stripe with your own local database is a good thing?

Mirroring using both API calls (create a new plan, coupon, subscription, etc.) and webhooks (new invoice or charge generated, payment failed.) so you can store all data (literally have similar tables with columns matching the stripe objects) locally and work with it faster.

If not, what data do you save locally and what do you request?

Thank you.

like image 748
Lazhar Avatar asked Jan 23 '16 22:01

Lazhar


1 Answers

Typically, saving the same data in two different places is not a good idea. By avoiding data duplication, you save a lot of time and prevent possible issues like data being out of sync.

That being said,

  1. You do not control data saved on Stripe's side. If it disappears for any reason, you are in trouble. Even though such an event is highly unlikely, I would recommend to store locally the most critical information.

In my apps I typically store Stripe's customer ID and which plan a user is subscribed to. Obviously, I also have all plans in my code since they determine what a user can do within an app.

  1. You may want to store some data locally for performance reasons, but a call to your own database is not necessarily faster than an API call. More importantly, even if there is a difference of a few hundred milliseconds, users will not notice it. And most users access such data (list of their invoices, etc.) very infrequently.
like image 78
Andrei Volgin Avatar answered Nov 14 '22 23:11

Andrei Volgin