#garv_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1392067281626071173
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Code containing payment intent creation!
If you need any further info to solve this please let me know, I am also able to screen share if that helps!
I think you are looking for this:
https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements
const customerSession = await stripe.customerSessions.create({
customer: {{CUSTOMER_ID}},
components: {
payment_element: {
enabled: true,
features: {
payment_method_redisplay: 'enabled',
},
},
},
});
This gives me error of undefined!
stripe.customerSessions is undefined
๐ taking over for my colleague. Let me catch up.
what SDK version are you using?
stripe@13.11.0
it's a very old version
you need to upgrade the version to get access to customerSessions
Okay can you let this thread be open for 10-20 minutes, I'll try and get back to you if it still doesn't work!
this is the version where we first introduced customerSessions https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#14120---2024-01-12
so you need to upgrade at least to that
So it shows only 2 cards, however I have added 8+ Cards do you know why might that be?
did you set the allow_redisplay to always on all of them?
How do I ensure that this is set to true for cards stored after payment!
Since I was under the knoledge that cards used for payment are auto saved!
you can update the PaymentMethods as per the doc I sent you
or you could add a parameter that enables you to show all the saved PMs regardless of their allow_redisplay status https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements&lang=node#display-additional-saved-payment-methods
great! It works now one last thing, I am also using setup intent and CardElement to add a new card from my UI to Stripe, do I need to update that manually as well or is there someway I can pass a parameter to ensure its already enabled
CardElement doesn't support saved PMs
and why are you using CardElements?
you're already using PaymentElement here
We have also created a page where we show all saved cards of user and allow them to either create new card or update older cards
you should use the same component in all of these different UIs for a better UX
I understand but this is not a new payment its just adding a new card to stripe, can that be done using PaymentElement with no charge being deducted?
even though
yes
PaymentElement is just the name of the element
that doesn't mean it will charge the card
it depends on the intent you're passing
if you're using SetupIntents w/ PaymentElement then the card will only be saved
Got it thank you!