0
votes

I have angular as frontend. From there I'm getting customer cards details and creating a token

const { token, error } = await stripe.createToken(this.card, options);

I have Laravel as Backend

I need to save the customer card details in stripe and need to save the reponse details like last 4 digits. It should be feasible to save the multiple cards for the customer.

Note:Initially only the card details need to saved and payment happens later.

I have gone through the documents,but I didn't understand how to use the token that I get front frontend to save the customer card details.

Hoping for the solutions Thanks.

2
You should not save the card details. The token is all you need to make a charge.Bryan
@Bryan I’m not really sure what purpose your comment serves? Saving card details for future purchases is a pretty common activity, and something that Stripe themselves facilitates: stripe.com/docs/saving-cardsMartin Bean
@MartinBean I think you missed my point. It could also be I misinterpreted the question. What I mean is: YOU as a developer should not be saving a consumer's credit card details on your servers. It is a huge security risk. Allowing a company like stripe to save a card for you is different (it's literally their business). See pci compliance faq for more details: pcicomplianceguide.org/faq/#14Bryan
@Bryan Yup, I’m aware of PCI compliance and the security best practice of not holding any payment instrument details if possible. I don’t think OP is looking to save the card details themselves (if I’ve misinterpreted the question and you are, then heed Bryan’s advice: don’t). OP: Follow Stripe’s guide for saving cards their side.Martin Bean

2 Answers

1
votes

You use Stripe.js to generate a tokenized form of the user's card, which you can then pass to the backend and save to a Customer by following the steps here:

https://stripe.com/docs/saving-cards

0
votes

I am just working with the api recently. And the link my backend partner and I used is https://stripe.com/docs/payments/save-and-reuse. (the link contains all clientside/frontend codes you need that help me setup the frontend part eventually) Another one seems like an older api that stripe does not recommend.

You will end up getting a token and save it into your database associate with the client, and use the token (customer id) to retrieve information from stripe or make payment. The retrieve information contains last4 digits, card type, billing details, etc. that you can use to display on frontend.