0
votes

I am working on a ReactJS app where users will register. we have our own points system, users will use those points to buy products. for points either someone will give them as a gift or they can purchase points using credit card (primarily). First we wanted to store credit cards in DB, then we realize about PCI compliance and other danger or saving CC info in db. so now we are using Stripe.

I am using ReactJS library of Stripe. I understand there is an option to register users as a customer, which I did. but I am confused about how to add and save credit cards to those customers. so that whenever in future a user want to use that card, they can use by selecting payment method. Stripe provides these objects: Card object, Payment Method object, Setup Intent, Sources and Payment Intent. each of them request similar data and returns similar data.

My main objective is to get credit card info, store it in stripe, in return stripe will give me some ID (like it gave me customer id to get customer data). I will store that ID in my database. in future I will pass that ID to stripe so that stripe can charge the customer against that ID.

Note:

  • I have already working frontend using react where I used stripe.createPaymentMethod() function to add a payment method which returned an ID like pm_1Haffm2eZvKYxxx. so I need a name of correct Object.
  • App will sometime give users money in their account as a refund or withdraw. so I will deposit amount to that same card.(is this possible?)
1

1 Answers

0
votes

You approach of using createPaymentMethod might suffice, and you should then attach the payment method to a Customer.

If you want to handle SCA and authenticate the cardholder up front, you should use Setup Intents to save the card details with Elements or push your Customer though Checkout in setup mode. Both of these will help you handle 3D Secure actions if needed.

Using any of these approaches, you would end up with a Customer and one or more attached payment methods. You can then make payments later by providing the customer and payment_method when creating a payment intent.