#zlanich_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/1461524472208031755
š Have more to share? Add more details, code, screenshots, videos, etc. below.
ChatGPT said I might be able to use a CustomerSession to reveal a checkbox to give the customer an option for this, but the docs imply I need a Stripe CheckoutSession for this, and I can't find any other evidence this is possible using just a PaymentIntent. Other docs and Reddit seem to imply Stripe API will just ignore the setup_future_usage parameter for unsupported payment methods, but just having Klarna in there an option throws an error that says I can't use that param with Klarna, so I'm just overall kind of stumped on how to make this work.
Hey! do give me some time to take a look at this!
Could you pass me the request ID where you see this error?
You may refer to this guide to locate request IDs in your Stripe account:Ā Ā https://support.stripe.com/questions/finding-the-id-for-an-api-request
Oh lord, I have no idea at this point. I got the error months ago, then just commented out the parameter. I'm just coming back to it now, and I'm trying to finish the quote for the client to allow customers to keep their card on file.
The thing I do recall clearly is that the error was pretty clear that the setup_future_usage param can't be used when Klarna is specified, and removing either of those made the error subside.
Hmm, Klarna does allow for setup_future_usage for Payment Intents API, you can set this value to either "on_session" or "off_session"
this is stated in our docs here: https://docs.stripe.com/payments/klarna/set-up-future-payments?payment-ui=direct-api
And obviously, removing Klarna caused Klarna not to show up as an option, and using setup_future_usage without specifying payment methods made Klarna not show up.
Interesting, has this changed in the last few months or so?
nope, i believe it has been supported for quite some time
I can help take a look at your dashboard to see if I can find the request where that error was returnee
could you send me your account ID? it should look like acct_xxx
Hello @crude scarab, we have sent you a direct message, please check it at https://discord.com/channels/@me/1461530102293860423
- š The message has instructions on how to grant read and write access to your Stripe Dashboard for our Developer Support team, in order to help you more effectively.
Can you approve the consent so that I can take a look at your dashboard settings?
thanks! taking a look at this now!
Ah, I believe this is the error you faced?
"error": {
"code":
"payment_intent_invalid_parameter",
"doc_url":
"https://stripe.com/docs/error-codes/payment-intent-invalid-parameter"
,
"message":
"A `setup_future_usage` value of on_session cannot be used with one or more of the values you specified in `payment_method_types`. Please remove `setup_future_usage` or remove these types from `payment_method_types`: [link].",
"request_log_url":
"https://dashboard.stripe.com/test/logs/req_gzsbAlMtmdu80D?t=1742507961"
,
"type":
"invalid_request_error",
},
}```
Yes, I'm 99.9% sure that's it
the error is saying that you canāt use link together with setup_future_usage:'on_session'
So it's actually not a klarna specific issue
Hmm, I don't recall clear enough how many different ways I tried this. But we would also like to use Link as well. Is there any way to allow future setup of credit cards for when the user chooses credit card, whlie still allowing Link as an option?
It just seems oddly limiting to me that we can't keep credit cards on file AND allow the user to have multiple payment options. the reason I specified them excplicitly was because Klarna wouldn't show up if I didnt.
Hmm, you could use the setup_future_usage:'off_session'
Hmm, I feel like I definitely tried that, but I can't be certain at this point. Is that supposed to work with Link?
Yup, you will only get that error when 'link' is specified with setup_future_usage:'on_session', but Stripe allows 'link' with setup_future_usage:'off_session'
Ok, I'm happy with that. I suppose I could have mixed up Klarna and Link at the time, because I was refactoring to add Klarna at the time, and I couldn't get it to show up, which is why I went down this rabbit hole of creating the payment intent with those params.
We don't charge users offline atm anyway, so this is fine. That being said, if I specify setup_future_usage, just the Stripe Elements UI just automagically have the user's previously used payment method available to choose next time around? I'm assuming this is how this works according to what I've read, but candidly, the Stripe docs are huge, and I sometimes have a hard time being certain about exactly how things work in practice.
Ah I see, i assumed that you wanted to charge your users offline in the future, and therefore wanted to use setup_future_usage. To be clear the setup_future_usage: āoff_sessionā field is mainly if you anticipate future payments being made without the customer actively being involvedĀ (i.e. offline reucurring payments)
But what you described sounds more like this instead: https://docs.stripe.com/payments/accept-a-payment?payment-ui=elements&api-integration=paymentintents#save-payment-methods
I actually just found a note in my code:
const input: Stripe.PaymentIntentCreateParams = {
amount,
currency: 'usd',
customer: stripeCustomerId,
// This doesn't seem to work very well, becaue Klarna, etc wouldn't show up due to conditions I don't know how to figure out
// You also can't have this AND payment_method_types or it will throw an error
// automatic_payment_methods: {
// enabled: true,
// },
/**
* @see https://docs.stripe.com/payments/payment-methods/overview for links that show API Enums for payment_method_types
*/
payment_method_types: allowedPaymentMethodTypes,
// This is for if we intend to use this payment method to attach the card to the user for future use, but it isn't compatible
// with Klarna (and possibly other) payment methods, so we disabled it for now (on_session doesn't work either, or it throws
// an error for link payment method type).
// setup_future_usage: 'off_session',
// TODO
// statement_descriptor: 'Fixed HHS',
};
But let me know look at what you just sent
Ok, the docs seem to imply this is for Stripe Checkout sessions, which we don't use, since we aren't using the Stripe hosted checkout. Is there a way to get this saved payment methods feature to work with just a payment intent and Stripe elements in Web + React Native?
Oh I'm sorry, it says customerSession, not checkout session
Yup! Its for Customer Sessions
It does mention setup_future_usage for forcing saving them though, which might be nice, considering ppl don't remember to check boxes
So is all I have to do is create a customer session along with the payment intent and pass that to elements, and it just works?
Given the features params in the docs
Yup!
Though my notes did say that setup_future_usage blew up on Klarna too, but I might have been mistaken and it only blew up on Link, so I'll have to test that.
So without setup_future_usage, does it give them the prompt to save, and with it does it automatically?
It will do so automatically:
You can specify setup_future_usage on a PaymentIntent or Checkout Session to override the default behaviour for saving payment methods. This ensures that you automatically save the payment method for future use, even if the customer doesnāt explicitly choose to save it.
Although, we do have a field in the Customer sessions that does the same as setting setup_future_usage: 'off_session' on the Payment Intent
So you can choose to either
- Set setup_future_usage: 'off_session' on the Payment Intent
- Set
payment_method_save_usage: 'off_session',on the Customer Session creation
Ok, I'm assuming this has the same limitation in regards to link?
To be clear the limitation/error encountered was because 'link' cannot be used with setup_future_usage: 'on_session'. So as long as the usage is for 'off_session' you should be fine
Yea, I'm hoping that's the case. My notes say that I tried it with off_session and it errored as well, but I could have been mistaken, so I will test that.
Ok, it will take me about an hour to refactor this (hopefully), so I will report back here to let you know if I have further issues, or if it worked. Thank you!
NP! Yup it should work with off_session, let us know about your progress!
āļø Stripe developers have stepped away for a short while
Please leave your questions here, and weāll respond as soon as we're back! If you need help urgently, you can contact Stripe support for help.
Ok, I'm using payment_method_save_usage, but the checkbox still shows up in the elements UI and it's not checked bby default either. Thoughts?
Hi @crude scarab I'm taking over this thread to continue helping you. Give me a sec to catch up
Ty!
The payment_method_save_usage controls whether the Payment Element displays a checkbox offering to save a new payment method. There's no option to make the checkbox checked by default.
If you want to always save a payment method upon completing a payment, you can just set setup_future_usage on the PaymentIntent itself.