#florin_unexpected

1 messages Ā· Page 1 of 1 (latest)

kindred pikeBOT
#

šŸ‘‹ 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.

twilit lagoon
#

šŸ‘‹ happy to help

#

would you mind sharing the checkout session?

hybrid pond
#

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

twilit lagoon
#

I meant the ID cs_test_xxx

hybrid pond
#

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.

twilit lagoon
#

that's correct

hybrid pond
#

can it be something from the way my frontend handles it? I am only using stripe.redirectToCheckout({sessionId:data.session_id})

twilit lagoon
#

please give me a couple of minutes I'm looking at your checkout session

hybrid pond
#

Oh, now it works

#

Thanks so much, is it possible to do something like this, but for billing and shipping addresses? @twilit lagoon

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

hybrid pond
#

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

twilit lagoon
hybrid pond
#

like, he can choose between cards, but also change their billing and shipping address.

#

like a dropdown but for cards only,

hybrid pond
twilit lagoon
#

we don't offer that unfortunately

#

billing details are tightly coupled with PaymentMethods

hybrid pond
#

hmm, I see that setting payment method save to enabled only saves the last card, is that right? @twilit lagoon

twilit lagoon
#

I'm not sure I understand

hybrid pond
#

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

twilit lagoon
#

do both have the allowed_redisplay set to always?

hybrid pond
#

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'
Ā  },

twilit lagoon
#

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

hybrid pond
#

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',
},
});

twilit lagoon
#

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

hybrid pond
#

Can I use that with an embedded cart?

twilit lagoon
#

what do you mean by embedded cart?

hybrid pond
#

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?

hybrid pond
twilit lagoon
#

yes PaymentElement is our custom flow

hybrid pond
#

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?

twilit lagoon
#

no that's not really possible

hybrid pond
#

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

twilit lagoon
#

if these are you requirements then yes

hybrid pond
#

Ok, so I need to use the payment intent api instead of the checkout session one

kindred pikeBOT
hybrid pond
#

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 ?

light tiger
#

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

hybrid pond
#

and I should set the invoice to not be sent right away, and instead finalize it on the payment intent success webhook, right?

light tiger
#

it depends. can you share more about your end goal here? what would be the payment flow from the customer's point of view?

hybrid pond
#

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

light tiger
#

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?

hybrid pond
#

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

light tiger
#

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.

#

by default this doesn't create an Invoice, but you do get a payment recipt.

hybrid pond
#

but the PaymentElement component lets me choose between my users cards? In the docs it shows that I can just choose between other providers

light tiger
hybrid pond
#

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

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.

hybrid pond
light tiger
#

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

hybrid pond
#

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?

light tiger
#

looks like it yes

hybrid pond
#

I see

#

so let's say I would retrieve all the saved payment methods from a customer on my frontend, can I pass them to the await stripe.confirmCardPayment function? or is it a different one

#

so the user can choose from their cards which one to use for the payments