anil
anil

Reputation: 464

Customer Card save in Stripe with Stripe JS

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.

Upvotes: 0

Views: 1761

Answers (2)

Yunhai
Yunhai

Reputation: 1411

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.

Upvotes: 0

taintedzodiac
taintedzodiac

Reputation: 2898

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

Upvotes: 1

Related Questions