#kenny_code
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/1361623775942017044
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
there are a lot of limits to the text size i was allowed to send so if there's any other context I care share with you i'd be happy to
hi there!
I saved the payments following this guide: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#save-payment-methods
and they show up properly in my stripe dashboard
what's your end goal here? to show existing payment methods in the Checkout Session?
if so, did you follow all these steps? https://docs.stripe.com/payments/existing-customers?platform=web&ui=stripe-hosted#prefill-payment-fields
My goal here is for my saved payment methods to be accessible when checking out using the payment element. I'm trying to access my saved payment methods directly from the checkout session to display them to the user but it's always returning null. I didn't follow all of the above steps mentioned as I don't currently collect billing addresses. Is that required for me to access payment methods using the payment element though?
As you can see from my screenshot fetching the payment methods from stripe is trivial but I thought it would be best practice to grab the payment methods directly from the checkout session hook when a user is making a payment
so you managed to save the payment methods, but the issue is to redisplay them in the Payment Element?
yes, exactly. they're saved in stripe as you see in both of my screenshots
have you read this doc that covers exactly how to do this? https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements
I haven't seen this one before but looking at the implementation it's pretty much the same as what I did
Maybe because this is a payment for a subscription I need to save them as off_session for them to be picked up by the payment element?
does the PaymentMethod have allow_redispay correctly set? https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay
const intent = await stripe.setupIntents.create({
automatic_payment_methods: {
enabled: true,
},
customer: orgExt.customerId,
usage: "off_session",
});
const customerSession = await stripe.customerSessions.create({
customer: orgExt.customerId,
components: {
payment_element: {
enabled: true,
features: {
payment_method_redisplay: "enabled",
payment_method_save: "enabled",
payment_method_save_usage: "on_session",
payment_method_remove: "enabled",
},
},
},
});
return {
clientSecret: intent.client_secret,
customerSessionClientSecret: customerSession.client_secret,
};
can you share the PaymentMethod ID (pm_xxx) so I can check myself?
I just realized in the doc you sent me i'm only using setupIntents for the payment method collection and the checkout session for payment elements when your guide seems to use setupIntent for both. Do I need to change to that?
mastercard: pm_1RE4hHCWRQ9TqHkCv3b0BUrW
visa: pm_1RE4fhCWRQ9TqHkCThJf8oij
okay so change payment_method_redisplay: "enabled", to payment_method_redisplay: "always",?
oh it only allows enabled or disabled
Yeah I get that but wouldn't that value be controlled by creating the intents?
Or would I just hit the stripe api to change it from limited to always after stripe saves it
Yes, you just make a call to update an existing PaymentMethod object's allow_redisplay property: https://docs.stripe.com/api/payment_methods/update#update_payment_method-allow_redisplay
okay and will this only work with the setupIntent flow or does it also work with the checkout session flow as well?
bc now that i made it always this shows up when I add a payment method but it still looks like this on my checkout session payment element
Could you please share the CheckoutSession ID/URL?
saved_payment_method_options: {
payment_method_save: "enabled",
},
This allows you to save PMs, not show saved PMs.
Hmmm, actually, you shouldn't need to provide any parameters to show saved PMs.
Let me check...
Which of the screenshot shows the Checkout Session?
I see that the Checkout Session you shared is of ui_mode=custom
yes
i'm using the payment element
I followed this guide: https://docs.stripe.com/payments/payment-element/migration-ewcs
I am not sure PM redisplay is supported on Custom Checkout yet: https://docs.stripe.com/payments/existing-customers
okay, so would it be supported following this: https://docs.stripe.com/payments/payment-element/migration
Are you creating a Customer Session? https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements#paymentintent-customersession
i don't really understand the difference between the two of these
Yes
This is basically this: https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements
I'm creating this:
const session = await stripe.checkout.sessions.create({
ui_mode: "custom",
line_items: [
{
price: formData.price,
quantity: formData.quantity,
},
],
mode: formData.mode,
return_url: `${BASE_URL}${href("/:orgSlug?")}?session_id={CHECKOUT_SESSION_ID}`,
automatic_tax: { enabled: false },
customer: orgExt.customerId,
saved_payment_method_options: {
payment_method_save: "enabled",
},
});
What do you want to achieve exactly?
There's multiple choices of how to handle this on the backend and frontend.
will payment intents and customer session approach work with subscriptions?
^this
Okay. Are you sure you want to use Payment Element, and not the full embedded checkout? https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=embedded-form
no clue, i'll give it a look
My guess is, if you use custom checkout (backend), with Payment Element (frontend), you need to create a customer session to redisplay payment methods: https://docs.stripe.com/payments/existing-customers?platform=web&ui=elements#paymentintent-customersession
gotcha, i'll give the embedded component a shot. One last question before you go on my add payment form the only way it becomes "always" and not limited is if they press Save payment details to firestorm for future purchases. This isn't for future purchases it's for them to add their own payment methods meaning this should be removed and just always by default. How can I do that?
this is my stripe backend code for that:
const intent = await stripe.setupIntents.create({
automatic_payment_methods: {
enabled: true,
},
customer: orgExt.customerId,
usage: "off_session",
});
const customerSession = await stripe.customerSessions.create({
customer: orgExt.customerId,
components: {
payment_element: {
enabled: true,
features: {
payment_method_redisplay: "enabled",
payment_method_save: "enabled",
payment_method_save_usage: "on_session",
payment_method_remove: "enabled",
},
},
},
});
You mean remove the disclaimer text at the bottom?
If you're not planning to use the PaymentMethod off-session, you could set usage="on_session". But if you want to be able to create a Subscription with this PM without bringing the customer on-session with Payment Element - the legal text is required.
no, not the legal text I mean the "Save payment details to firestorm for future purchases" thing they have to click for it to be saved
cuz if they don't click that checkbox then it's saved as limited
not always
I am not sure I am following. It must be saved with allow_redisplay=always that way.
yes, I want to save it but I want to set allow_redisplay=always without having to call the stripe api after already creating the payment method
๐ taking over for my colleague. Let me catch up.
can i modify something in the backend code I sent above so that it will set allow_redisplay=always by default?
unfortunately this needs to be done after you save the payment details
okay, instead of setting it to always can I make it so that the element will show limited cards?
if the customer checks the box to save for future payments then allow_redisplay would be saved as always