#florin_unexpected
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/1311639506277109781
š Have more to share? Add more details, code, screenshots, videos, etc. below.
Sure @twilit lagoon
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
customer: 'cus_RG1LQaLr7ob9Gg',
line_items,
mode: 'payment',
success_url: process.env.FRONTEND_SUCCESS_PAYMENT_URL,
cancel_url: process.env.FRONTEND_FAILED_PAYMENT_URL,
billing_address_collection: 'required',
shipping_address_collection: { allowed_countries: ['GB', 'RO'] },
payment_intent_data: {
setup_future_usage: 'on_session',
},
});
Basically, in my app you will be able to manage your payment methods, billing and shipping adresses and I want to fill this data upon checkout creation
I meant the ID cs_test_xxx
ok, one sec
cs_test_a1RT4U5MyKnupGDGxKHF4B2R5yumZ8f8ganyHSBddELAo5wSzv35meBvVs
@twilit lagoon Basically, in my app you will be able to manage your payment methods, billing and shipping adresses and I want to fill this data upon checkout creation, chat gpt told me that if I pass the customer id I should be able to select the card between the customerās saved cards.
that's correct
can it be something from the way my frontend handles it? I am only using stripe.redirectToCheckout({sessionId:data.session_id})
please give me a couple of minutes I'm looking at your checkout session
the PaymentMethods (PMs) that are attached on this customer are configured as https://docs.stripe.com/api/payment_methods/object#payment_method_object-allow_redisplay 'limited'
you need to update them and set https://docs.stripe.com/api/payment_methods/update#update_payment_method-allow_redisplay to 'always' for them to show
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Oh, now it works
Thanks so much, is it possible to do something like this, but for billing and shipping addresses? @twilit lagoon
if the customer chooses a pre-saved payment method they won't be asked for billing information
for shipping there's no autofill
Hmm, can I not split the payment method from the billing and shipping address?
Yea, I see that it saves all the payment details at once
I'm not sure what you mean by that
like, he can choose between cards, but also change their billing and shipping address.
like a dropdown but for cards only,
Basically I want to independently change the billing and cards from each other.
we don't offer that unfortunately
billing details are tightly coupled with PaymentMethods
hmm, I see that setting payment method save to enabled only saves the last card, is that right? @twilit lagoon
I'm not sure I understand
Because I used both the visa and mastercard and only the last one seems to be saved
Basically when I get to the checkout page, I can use the last card I paid with but if I click the change button it asks me for a new card, I was expecting to be able to choose between multiple saved payment methods
I was expecting a dropdown or something with the saved payment methods, not to be able to only use the last card or add a new one
do both have the allowed_redisplay set to always?
Yes @twilit lagoon
{
Ā Ā id: 'pm_1QQ5iTKCK5mmw7xEazxTTw7s',
Ā Ā object: 'payment_method',
Ā Ā allow_redisplay: 'always',
Ā Ā billing_details: {
Ā Ā Ā address: [Object],
Ā Ā Ā email: 'jenny.rosen@gmail.com',
Ā Ā Ā name: 'Jenny Rosen',
Ā Ā Ā phone: null
Ā Ā },
Ā Ā card: {
Ā Ā Ā brand: 'mastercard',
Ā Ā Ā checks: [Object],
Ā Ā Ā country: 'US',
Ā Ā Ā display_brand: 'mastercard',
Ā Ā Ā exp_month: 2,
Ā Ā Ā exp_year: 2029,
Ā Ā Ā fingerprint: 'bxcB9BYdMEIvJGXM',
Ā Ā Ā funding: 'credit',
Ā Ā Ā generated_from: null,
Ā Ā Ā last4: '4444',
Ā Ā Ā networks: [Object],
Ā Ā Ā three_d_secure_usage: [Object],
Ā Ā Ā wallet: null
Ā Ā },
Ā Ā created: 1732792621,
Ā Ā customer: 'cus_RG1LQaLr7ob9Gg',
Ā Ā livemode: false,
Ā Ā metadata: {},
Ā Ā type: 'card'
Ā },
{
Ā Ā id: 'pm_1QQ5WuKCK5mmw7xECjtMrASx',
Ā Ā object: 'payment_method',
Ā Ā allow_redisplay: 'always',
Ā Ā billing_details: {
Ā Ā Ā address: [Object],
Ā Ā Ā email: 'jenny.rosen@gmail.com',
Ā Ā Ā name: 'Jenny Rosen',
Ā Ā Ā phone: null
Ā Ā },
Ā Ā card: {
Ā Ā Ā brand: 'visa',
Ā Ā Ā checks: [Object],
Ā Ā Ā country: 'US',
Ā Ā Ā display_brand: 'visa',
Ā Ā Ā exp_month: 1,
Ā Ā Ā exp_year: 2029,
Ā Ā Ā fingerprint: 'eTVIaPphhRKp4JAs',
Ā Ā Ā funding: 'credit',
Ā Ā Ā generated_from: null,
Ā Ā Ā last4: '4242',
Ā Ā Ā networks: [Object],
Ā Ā Ā three_d_secure_usage: [Object],
Ā Ā Ā wallet: null
Ā Ā },
Ā Ā created: 1732791904,
Ā Ā customer: 'cus_RG1LQaLr7ob9Gg',
Ā Ā livemode: false,
Ā Ā metadata: {},
Ā Ā type: 'card'
Ā },
I'm looking to see whether this is a limitation on the Checkout Session, because AFAICR, in Elements we display all the allow_redisplay PMs
just fyi, this https://docs.stripe.com/payments/checkout/save-during-payment?payment-ui=stripe-hosted#save-payment-methods-to-prefill-them-in-checkout is how you can set the Checkout Session to automatically apply the allow_redisplay: 'always'
Yea, that is what I did
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
customer: 'cus_RG1LQaLr7ob9Gg',
line_items,
mode: 'payment',
success_url: process.env.FRONTEND_SUCCESS_PAYMENT_URL,
cancel_url: process.env.FRONTEND_FAILED_PAYMENT_URL,
// billing_address_collection: 'required',
// shipping_address_collection: { allowed_countries: ['GB', 'RO'] },
payment_intent_data: {
setup_future_usage: 'on_session',
},
saved_payment_method_options: {
payment_method_save: 'enabled',
},
});
perfect
still looking into the above mentioned issue
ok so, yes, Checkout Sessions has chosen to only see the latest saved PM
if you need to show more, you would eventually need to migrate to PaymentElements
Can I use that with an embedded cart?
what do you mean by embedded cart?
Right now I am redirecting the user to the stripe payment page, but eventually I want to move it to be embedded in my app
Do I need a custom checkout to use payment elements?
Checkout* I am sorry
yes PaymentElement is our custom flow
hmm, I donāt really want to create a custom flow because I will need to use the payment intent api, I am new to stripe. Can I instead pass a saved payment method on the stripe checkout session creation?
no that's not really possible
So basically my customer will choose their payment method before the stripe checkout page
So I am kinda forced to use the custom checkout, right
if these are you requirements then yes
Ok, so I need to use the payment intent api instead of the checkout session one
My idea of a flow was to create a payment intent and an invoice, the customer pays, and on the webhooks the invoice is being sent and my order from my db is being updated, am
i missing any steps ?
hi! I'm taking over this thread.
create a payment intent and an invoice
you should only create an Invoice, and it will automatically contain a PaymentIntent for you
and I should set the invoice to not be sent right away, and instead finalize it on the payment intent success webhook, right?
it depends. can you share more about your end goal here? what would be the payment flow from the customer's point of view?
I am selling digital and physical products, I have not used stripe before, and I dont want to miss any steps, like sending invoices for example
how do you want end users to enter their payment method? Payment Element, Checkout Session, something else?
do you really need an Invoice, or a payment receipt is enough?
But basically this is my flow: A user can manage their payment methods and adresses in the accout section, and I want to let him choose between them on the checkout page, or create new ones
I was thinking of using the custom checkout because otherwise I cannot seem to be able to fill their payment method with a saved card
and I want to let him choose between them on the checkout page, or create new ones
then you should use the Payment Element then.
here's our guide about it: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements
by default this doesn't create an Invoice, but you do get a payment recipt.
but the PaymentElement component lets me choose between my users cards? In the docs it shows that I can just choose between other providers
the PaymentElement can show the customer's existing saved payment method yes. this is explained in this section: https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#save-payment-methods
I am sorry, this might be a stupid question, does it only show the previously used method? (only the last one?) or does it show all of them? I wanna know before I start implementing the custom checkout @light tiger
it can show multiple saved payment method. not sure what's the maximum number we can display. give me a few minutes to try this.
for card payment methods, it looks like one one is displayed. so if you need more control over this, you would need to build your own UI for this.
you can learn more about this here: https://docs.stripe.com/payments/existing-customers?platform=web&ui=direct-api
so only one card payment method is being displayed?
I created a customer with 5 saved cards and Sepa Debit. and this is what the Payment Element looks like:
so it's one payment method of each type that is shown
so to be 100% sure, if I would save the 4242 VISA card and a MAstercard card, I would only see the last one saved?
looks like it yes