0 votes
in Databases by (2k points)
recategorized by

I'm new to stipe, and I'm just wondering if that I'm doing is a standard way of working with Stripe.

I have a very simple User model which I've added 2 new fields - stripe_id and card_id. When a user registers an API call to Stripe is made to generate a stripe_id. Then I ask for a credit card. I've used to basic stripe.js API to retrieve a card_id. I then store that card in the User model.

Is this safe to do this? I then card the user with their stripe_id and card_id.

I know that a user has more than one card, so eventually I'll move the cards a seperate table.

Can anyone solve my problem?


1 Answer

0 votes
by (1.9k points)

If you want to use the card later again store the card_id.

This is an example of how you would retrieve card info later in PHP

$customer = \Stripe\Customer::retrieve({CUSTOMER_ID});
$card = $customer->sources->retrieve({CARD_ID});

So you need both stripe_id and card_id.

If you only store stripe_id you can still list customer's all cards' information:

  "object" => "card"

Hope you will be satisfy with the answer.

131 questions

117 answers


378 users

Welcome to Todayask Q&A, where you can ask questions and receive answers from other members of the community.