Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Stripe backend - best practice to store data locally or rely on API Calls?

Totally new to server-side programming and I am wondering about best practices regarding gathering information from a service like Stripe Payments, for example.

For some context -- a stripe customer can have multiple payment cards, one of which is considered the default payment card.

Now lets say a client hits my server and wants the default payment card for customer XX. My question is: should I be maintaining my own stripe database info, or should I just forward that request to stripe directly?

On the one hand, storing that information locally means I don't have to rely on a second network request to gather that information -- I can just send back directly what is in my database.

On the other hand, storing that information locally means I've got more code to maintain, and now I've got to worry about keeping it reflective of the true data over at stripe. That problem is solvable, but does the cost of doing so outweigh the negatives of extra API calls??

Any thoughts? I'd love to hear some opinions as this is very new to me :)

thanks!

like image 585
Sean Danzeiser Avatar asked Feb 22 '14 23:02

Sean Danzeiser


People also ask

Can I use Stripe with an API?

Everything in your Stripe account is an object, whether you create it with the API or not. Your balance corresponds to a Balance object, you track customers with Customer objects, you store payment details in PaymentMethod objects, and so on. Even low-code and no-code integrations produce these objects.

What makes Stripe API good?

It is built for its users, engineers Stripe's landing pages & online sandboxes play a key role at this. For each business area (Payment, Business operations, etc.), you can choose from integration guides, sample open source projects or no-code alternatives.

What database does Stripe use?

Stripe offers a simple platform for developers to accept online payments. They are a long-time user of MongoDB and have built a powerful and flexible system for enabling transactions on the web.

What is Stripe REST API?

The Stripe API allows developers to access the functionality of Stripe. Some example API methods include sending invoices, accepting payments, managing subscription billing, and editing and managing account information.


1 Answers

Generally it's a good idea to keep a local copy of the data you get from Stripe API in your own database. Otherwise you will have to make too many calls to Stripe API which will slow down your server requests. In order to keep your local database synchronized with Stripe you should use the webhooks in Stripe.

https://stripe.com/docs/webhooks

like image 84
nabeel Avatar answered Nov 16 '22 01:11

nabeel