#hickorydickorydock_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/1435946421181218828
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I have a server-side view that looks up the user's customer ID and recently used payment method ID and uses it to make a charge. Unfortunately, that's running into the error: The provided PaymentMethod was previously used with a PaymentIntent without Customer attachment, shared with a connected account without Customer attachment, or was detached from a Customer. It may not be used again. To use a PaymentMethod multiple times, you must attach it to a Customer first.
To fix this, I tried to Attach a PaymentMethod to a Customer after creating the payment intent (https://docs.stripe.com/api/payment_methods/attach) but that doesn't fails with stripe._error.InvalidRequestError: Request req_<request_id>: This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
Is there another way to do this? If not, I'm also exploring using setup_future_usage='off_session' on the Payments element when collecting the card details in the first place, but the language that appears doesn't exactly accurately describe what's happening, and I'd like to be able to customize it:
By providing your card information, you allow <Organization> to charge your card for future payments in accordance with their terms.
Unfortunately, I couldn't find in the docs any way of customizing that language.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Basically, I'm trying to set up a streamlined donation flow where they can donate to an organization they support from an email in a single click, which works well if the customer ID/payment method ID are attached correctly. So I'd like to be able to attach the two, and/or customize the language shown when setup_future_usage is set.
hey there ๐ looking into your question now
thank you so much!
so attaching a card with the PaymentMethod Attach endpoint is only possible before that card has been used for a payment, which is why you're getting the error when trying to attach it after the payment
you're right that the solution is to use setup_future_usage on the PaymentIntent when you collect the card (this will save/attach the card during the payment) - here's our guide on this flow:
https://docs.stripe.com/payments/save-during-payment?payment-ui=elements#create-the-paymentintent
for the language of the text that shows up, can you confirm which surface you're using on the front-end to collect the card (i.e. the Payment Element, the Card Element, something else)?
Thanks for confirming that! We're using the Payment Element (as well as the Link Authentication and Address elements, but that's probably not important here)
perfect! ok I'll just need a few minutes to look into this
cool, no worries, appreciate your help!
ok so it's not exactly possible to customise this text within the Payment Element, but it's possible to control whether it shows up or not: https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-terms
so if you'd prefer to use your own language, you can set this to never, and display your own text elsewhere on the page (i.e. outside the Element) - it's just worth noting that these are important for compliance purposes, and you'll be responsible for confirming that your langauge is sufficient
Cool, after a lil testing, looks like that's working! Thank you for your help today -- and I'll be sure to show some message with proper language to remain compliant. Thank you!
awesome! glad to hear it helps! ๐