#chen_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/1263572006415368314
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello, which Stripe surface are you using to charge here? (Checkout, Elements, etc)
And do you have an object ID of a session or intent that saw this behavior?
I am using Stripe Elements
I can give you a beta testing environment where this behaviour is observed
but it is on our product
Is this for a specific payment method, or any payment method that creates a modal basically?
I am in the process of implementing swish, mobilepay and twint with stripe elements. I am unable to test the use case of the modal popup phase (After submission, you will be redirected to securely complete next steps.) to pay with each respective payment provider. It just gets stuck on Processing order... Do not close or refresh this page while we complete your order.
it works fine with android pay/apple pay
Can you send me your code for setting up the payment element and your code for submitting the payment?
Also, is the Payment Element embedded directly in your page? Or are you using an iframe that points to a page that has the Payment Element in it? I think iframes can cause issues with modals but would need to look that up again
it is embedded directly
Gotcha. And actually, on second thought, I think the beta environment would be a good place to start.
Both will be helpful, happy to look at them in whichever order they are sent
https://widgets.staging.universe.engineer/66983039bd7fc70021b177b4
you can go through the checkout to the very end
Universe - Checkout
So I see that your page is making a call to create a payment method and that call is succeeding https://dashboard.stripe.com/test/logs/req_Y7hikjoiFvIdaE
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Do you know what specifically in your code is hanging here?
I wasn't able to see any of the popups
it just gets hung at the very end
if you use any other payment methods, it will successfully checkout
๐ stepping in here as Pompey needed to step away
this is what I get for using credit card to checkout
Have you added a log after you call confirmPayment()?
Can you show me your relevant client-side code here involving confirmPayment()?
if (!stripe || !elements) return;
const { error: submitError } = await elements.submit();
if (submitError) return;
const { error, paymentMethod } = await stripe.createPaymentMethod({
elements,
params: {
billing_details: {
name: `${buyerFirstName} ${buyerLastName}`,
email: buyerEmail,
},
},
});
}
Are you following a certain set of docs here? You shouldn't be calling stripe.createPaymentMethod() when using Payment Element.
oh? how should I be using this?
this is client-side
You just want to take payment immediately here?
I assume you are trying to do this flow: https://docs.stripe.com/payments/accept-a-payment-deferred?client=react
In which case you mostly just need to change createPaymentMethod() to confirmPayment() and ensure you are calling your server to get the client secret
don't I want to make sure I createPaymentMethod before I confirmPayment
so my current implementation works fine for card payment methods, but it wont work for swish pay, mobilepay and twint
When you call confirmPayment() that both creates a PaymentMethod and confirms the PaymentIntent
Are you trying to break this up into a multi-step process for some reason?
I wasn't the individual that implemented the original stripe
I think there might be considerations to follow certain stripe rules for countries we support
Can you show me your Stripe server-side code?
Are you setting confirm: true on your server and trying to pass the PaymentMethod ID?
the ticket is generated after stripe confirms payment
const response = await createTickets(
paymentMethod.id,
paymentMethod.type,
lang
);
That is not a Stripe function so no idea what that does
Do you have access to your backend here?
I do
Okay can you show me your server-side code where you create your PaymentIntent?
We create our payment intent on our backend and confirm it there, we only create a payment method client side. Do we need an action to happen on the payment intent and to provide a client secret to the element in order to present this modal or is there a way we can create a payment method using swish without creating an intent first?
Jonathan is someone else working on this problem with me that have better insights
Yeah you don't need to create the PaymentIntent up front, what you are doing now is fine.
Overall you are using a legacy version of our server-side confirmation flow: https://docs.stripe.com/payments/finalize-payments-on-the-server?platform=web
You'll see in those docs that we recommend creating a Confirmation Token.
In the legacy flow you would create a PaymentMethod as you are doing now.
However, if you are seeing the PaymentMethod be created here for Swish then overall the Stripe integration isn't the issue.
Ah
I see what is happening
Okay in your server-side code you are trying to attach this PaymentMethod to a Customer
You seem to be doing this by trying to pass the PaymentMethod ID to payment_method when you create the Customer. See: https://dashboard.stripe.com/test/logs/req_9uEXbkZQqHKdkb
However, Swish is a one-time PaymentMethod
So it can't be attached to a Customer
Thus the error that you can see in that request
i am assuming that is the same as mobilepay and twint
Yep
So you need to fix that issue in your backend
As that is causing your frontend to hang since the PaymentIntent is never actually being created/confirmed in your backend so nothing is telling your frontend that the payment was successful
While you are doing this, I'd recommend migrating your code to use Confirmation Tokens as opposed to this legacy route of using createPaymentMethod()
You likely will be forced to do that at some point in the future or you'll miss out on new features and development if you stay with createPaymentMethod() here.