#wesley-s_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/1400268103388102666
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I think I didn't make it clear enough, the confirm request failed with that error. I didn't get to see the Klarna page
hello! can you share the PaymentIntent id?
hmmm, gimme a while to look at this
okay
I have Pix setup in pretty much the same way and it's working perfectly. Do you want me to send the failing confirm payload?
it's alright! I can see the failing confirm payload on my end ๐
can you try again with these billing details and a return_url in confirmKlarnaPayment?
...
payment_method: {
billing_details: {
email: 'jenny.rosen@example.com',
address: {
country: 'US',
},
},
},
return_url: xxx,
}
...
no worries, take your time
let's confirm that it works if the return_url is correct
actually none of those should be mandatory fields right now. I believe we may have overlooked some changes to the confirmKlarnaPayment method.
If you're alright, can we take a step back first and can you share some background on why you're using the Direct API for Klarna instead of the Payment Element?
We are using the Direct API mostly because it will be easier to integrate with the payment flow we already had
The old flow consists on just card and walled payments and relies on first creating the payment method and then creating the payment intent. However, the company requested the integration of other payment methods
We could replace everything to use the Payment Element but they wanted to have a finer control of what information we get when dealing with card payments
can you give some examples of what you mean by finer control of what information you get when dealing with card payments?
Actually I don't know 100% for sure because I didn't work on the old implementation, but for what I could tell is something silly as they couldn't get the Payment Element to always request the card holder name
ah, okay, so the Payment Element will only require for the fields that are required for a particular payment method. So you are right that it doesn't request the cardholder name for card payments. What we typically recommend is to configure the Payment Element to never request the name, and use your own input field to collect the name and pass it into the billing details when confirming the payment.
from what you described, I would also recommend looking at the deferred intent flow where you don't need to initialize the Payment Element with an Intent : https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment
I actually encourage you to consider using the Payment Element since if you need to support new PaymentMethods in the future, it should just be a matter of enabling the PaymentMethod in the Dashboard, instead of additional code
but going back to your original problem, if you comment out the billing_details in confirmKlarnaPayment, it'll actually still work ๐
so we seem to have forgotten to clean up some checks or something.
options = {
payment_method: {
// billing_details: {
// email: 'jenny.rosen@example.com',
// address: {
// country: 'DE',
// },
// },
},
return_url: url, // already set to current url,
}
If you try using confirmPayment instead : https://docs.stripe.com/js/payment_intents/confirm_payment (just pass in the client_secret) and you'll see that you don't actually need to pass in any payment_method details at all and it'll still work
Thanks, I'll try to convince them to use the Payment Element
Oh, one las question
does it internally have the logic to determine the available payment methods in that context, or does it make a request to ask the server which ones to show?
yep, it does internally have the logic to determine the available payment methods in that context, you can test this out for example by switching the currencies defined in options. https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=payment#add-the-payment-element-to-your-checkout-page
you can read up more about dynamic payment methods here : https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods
Thanks! That was all. Have a good one