#xh.liang
1 messages · Page 1 of 1 (latest)
Hi, if you have a Customer which already have saved Payment Methods, and specify that customer id when you create this Checkout Session, then it will be displayed here
Before that, you save in by setup_future_usage and pass in a newly created Customer Id: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#save-payment-method-details
Does stripe-js sdk provide method to load users' payment info by customer id?
For the https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout#handling-existing-customers, it seem it's server-side way?
Yes it's the server-side way. This require the setup from backend
For example,I have a spa web application developed by React. And I use stripe.js sdk (https://stripe.com/docs/js). So how can i associate payment info (show card info in the Input element) with current user?
The client side talk with backend with restful api.
@pseudo palm
It's the steps to be done in your backend, so you don't need to modify your React SPA app. On backend, simply follow 2 steps I mentioned above
Then in your SPA app, after you let your customer redirect to Stripe Checkout page, we will automatically display the saved Payment Methods on that customer
so it mean I can't achieve same result using yours sdk? (https://github.com/stripe/stripe-js/blob/master/examples/rollup/src/index.js#L1). Because we don't want t to redirect . We want create such card element manually.
@pseudo palm
we don't have any standalone component for showing a customer's payment methods no
so you can either redirect to Checkout with a supplied customer ID, or you can build your own UI for showing the customer their saved cards and picking one, by calling https://stripe.com/docs/api/payment_methods/customer_list and sending information to your frontend web page where you can use the details like card.brand / card.last4 etc to build some list/table view in your page
yes, I can get customer info by call stripe api. But the create element method it seem can not pass value when init card or cvc element.
https://stripe.com/docs/js/elements_object/create_element?type=card#elements_create-options-value
In fact, we want build our custom ui with create element method provided by stripejs
correct
not sure what that has to do with the answer I gave
I mean it seem i can't pre-filled exiting user payment info (sensitive data) with this method (https://stripe.com/docs/js/elements_object/create)
correct, you can not
the only way to build this is what I said above. You send information to your frontend web page where you can use the details like card.brand / card.last4 etc to build some list/table view in your page.
When the user picks something in that list, instead of using Elements or a CardElement or anything like that, you would directly call e.g. https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing with the ID pm_xxx of the card they picked from that list/table view
ok i will try it later.
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!