#abe_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/1273739974222675969
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
It's not totally clear to me what "allow_redisplay" means. The docs say:
This field indicates whether this payment method can be
shown again to its customer in a checkout flow. Stripe
products such as Checkout and Elements use this field
to determine whether a payment method can be shown as a
saved payment method in a checkout flow.
My use case is creating subscriptions that will be charged later. A user can have multiple separate monthly subscriptions with different payment methods. Users can add payment methods separately on a payment management screen (not attached to subscriptions) that can be later attached to new subscriptions or update existing subscriptions. This is a web interface using Stripe Elements.
So in this case should I set "allow_redisplay: 'always'" so they "can be shown as a saved payment method" ? If so how do I set it on my backend?
Currently, when adding a payment method I create a SetupIntent on my backend (Ruby on Rails):
setup_intent = Stripe::SetupIntent.create(
customer: stripe_customer_id,
payment_method_types: ['card'],
usage: 'off_session',
)
render json: { client_secret: setup_intent.client_secret }, status: :ok
and my frontend (JS) uses Stripe Elements to attach the payment method to the SetupIntent and confirm setup:
const result = await stripe.confirmCardSetup(data.client_secret, {
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
// empty
},
},
});
// ...
const confirmResponse = await fetch('/myapi/v1/stripe/setup_intents/confirm_setup', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ setup_intent_id: result.setupIntent.id }),
});
I was able to get "allow_redisplay" to be set to "always" by updating the frontend/client-side code:
const result = await stripe.confirmCardSetup(data.client_secret, {
payment_method: {
card: elements.getElement(CardElement),
billing_details: {
// empty
},
allow_redisplay: 'always',
},
});
However, I'd prefer that this be controlled by the backend rather than the frontend (so that it's tamper-proof), so I tried a couple modifications to my backend to set this field without success.
Things I've tried:
- I tried setting
payment_method_datawhen creating the SetupIntent on my backend:
Stripe::SetupIntent.create(
customer: stripe_customer_id,
payment_method_types: ['card'],
usage: 'off_session',
payment_method_data: {
type: 'card',
allow_redisplay: 'always',
},
)
Result: I get this error:
Stripe::InvalidRequestError (Missing required param: payment_method_data[card].):
It seems to want the full card data when providing the payment_method_data option, which I can't do since I'm tokenizing the card with Elements
- I also tried setting
payment_method_optionswhen creating the SetupIntent on my backend:
Stripe::SetupIntent.create(
customer: stripe_customer_id,
payment_method_types: ['card'],
usage: 'off_session',
payment_method_options: {
allow_redisplay: 'always',
},
)
Result: I get this error:
Stripe::InvalidRequestError (Received unknown parameter: payment_method_options[allow_redisplay]):
It seems like allow_redisplay isn't a valid option for this parameter.
So I'm wondering if you think I should be setting this parameter to "always" in the first place, and secondly, is there a way to set it from my backend rather than Stripe Elements / frontend?
Hi ๐ can you tell me more about how you're displaying the Payment Methods for the customer to select to use later?
Sure, it's a screen that looks like this right now
Pretty basic. But later when going through a "checkout" type of flow to create a donation I want them to be able to select from these payment methods (if they added them here previously)
cleaner screenshot
Are you using Checkout Sessions for those later flows? Or are you using Elements to surface the saved payment methods to the customer?
(I don't think so from the screenshots, but may be mistaken)
If not, I don't think you need to worry about allow_redisplay.
I'm using Elements on the checkout flow (currently incomplete). I'm probably just overthinking things it just seemed like a somewhat vague option in the docs and I didn't want to hamstring myself later by forgetting some minor detail like this
Great I won't worry about this any more then. Does it hurt anything if I leave the allow_redisplay: 'always' option on in the frontend? It should only be more permissive than leaving it as the default 'unspecified' I imagine?
Not that I'm aware of, no. That just allows Checkout Sessions or the Payment Element (specifically using the Paymetn Element to display already saved payment methods) to display those payment methods if you were using those flows.
Ah okay that makes sense. Perfect, thanks. You can mark this as resolved then. Thanks for your help!