#nancy-e_code

1 messages ยท Page 1 of 1 (latest)

magic lakeBOT
#

๐Ÿ‘‹ 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/1451271772287664320

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

sour hedge
#

Hi ๐Ÿ‘‹

You can redisplay saved payment methods using the Stripe Payment Element as we document here.

ocean berry
#

Okay - so I can use the Payment Element with the SetupIntents API for new method creation, and for listing existing payment methods, I can generate a Customer Session and then use the secret on the client-side to generate the Payment Elements for display?

sour hedge
#

You need to make sure, when you create the Customer Session on your server, that you specify components.payment_element.features.payment_method_allow_redisplay_filters to unspecified. This will display saved payment methods even if the Payment Method was saved without a specific allow_redisplay value.

ocean berry
#

right right right okay

sour hedge
ocean berry
#

Is it possible to use CheckoutSessions to create new PaymentMethods without a charge or particular purchase? That's the method Stripe staff gave my team, but I wasn't able to use the Payment Element with the secret I generated in creating the CheckoutSession

sour hedge
ocean berry
#

Oof I can't find my code I used to test that out. I did try that 2-3 times unsuccecssfully. That was recommended. I guess I can try again, but I have been able to do this with no trouble with SetupIntents. This is to support both on-session and off-session flows where the user might not be the customer themselves

sour hedge
#

Oh, wait. The user may not be the Customer? Yeah Checkout Sessions won't do that

ocean berry
#

Gotcha. There are a few application surfaces here. In the future there will be one where the user is the customer

sour hedge
#

So you create the Payment Method, without a Customer and then later attach it to the Customer?

ocean berry
#

No, so we find-or-create the Stripe customer on load of our internal user detail page, and then use the Payment Element on the client-side to create and attach the PaymentMethod in one fell swoop.

#

It's a little hand-wavy because I'm not sure how the context of the Stripe Customer ID comes into play with the client-side SDK

sour hedge
#

Well that would come in with the Customer Session object. To be 100% clear, we expect you to already know you are displaying saved payment methods to that specific Customer.

I'm sure you can understand customers might be a bit concerned if their saved payment methods were being displayed to people other than themselves.

ocean berry
#

Lol yeah absolutely. OH I see what you're saying. Then in my case, that's coming in with the SetupIntent session object currently

#

We pass the found-or-created Stripe Customer.id to the backend to generate the secret and then use the secret on the frontend to mount the Payment Element

sour hedge
#

Well, what I mean is that if you render the Payment Element with both a Setup Intent and Customer Session it would redisplay any saved payment methods for that Customer.

In that scenario, only the individual represented by the Customer should be interfacing with the Payment Element.

#

If you just use the Setup Intent, we don't redisplay saved payment methods

ocean berry
#

oooooooh gotcha

#

so Customer Session is what I should be looking into

#

that's very helpful

sour hedge
#

When you want to redisplay the saved PMs to the Customer, yes.

ocean berry
#

๐Ÿ‘

sour hedge
#

And it's an option you can pass to Stripe Elements

ocean berry
#

Yeah we'll have application surfaces where the user is the customer and others where the user is doing things on behalf of the customer

magic lakeBOT
sour hedge
#

Yeah, making sure you have those two user paths cleanly separated is, I think, the key to properly setting this up. Getting the Payment Element configured to redisplay saved PMs is just an extra API call and one new param when creating Stripe elements.

ocean berry
#

๐Ÿ‘ okay. I'll do my best. how long will this thread exist for? This has been very helpful.

sour hedge
#

We close threads for inactivity but the actual thread itself is retained. You just won't be able to keep posting in it.

hollow grotto
#

fyi i'm taking over for snufkin, feel free to let me know if you have any more questions in the near term!