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 likepm_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?)