#chen_code

1 messages ยท Page 1 of 1 (latest)

void nightBOT
#

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

pure lynx
#

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?

modern estuary
#

I am using Stripe Elements

#

I can give you a beta testing environment where this behaviour is observed

#

but it is on our product

pure lynx
#

Is this for a specific payment method, or any payment method that creates a modal basically?

modern estuary
#

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

pure lynx
#

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

modern estuary
#

it is embedded directly

pure lynx
#

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

modern estuary
pure lynx
#

Do you know what specifically in your code is hanging here?

void nightBOT
modern estuary
#

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

pale terrace
#

๐Ÿ‘‹ stepping in here as Pompey needed to step away

modern estuary
#

this is what I get for using credit card to checkout

pale terrace
#

Have you added a log after you call confirmPayment()?

#

Can you show me your relevant client-side code here involving confirmPayment()?

modern estuary
#

    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,
        },
      },
    });
}
pale terrace
#

Are you following a certain set of docs here? You shouldn't be calling stripe.createPaymentMethod() when using Payment Element.

modern estuary
#

oh? how should I be using this?

pale terrace
#

Are you trying to confirm on your server?

#

Or client side?

modern estuary
#

this is client-side

pale terrace
#

You just want to take payment immediately here?

#

In which case you mostly just need to change createPaymentMethod() to confirmPayment() and ensure you are calling your server to get the client secret

modern estuary
#

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

pale terrace
#

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?

modern estuary
#

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

pale terrace
#

Can you show me your Stripe server-side code?

#

Are you setting confirm: true on your server and trying to pass the PaymentMethod ID?

modern estuary
#

the ticket is generated after stripe confirms payment

      const response = await createTickets(
        paymentMethod.id,
        paymentMethod.type,
        lang
      );

pale terrace
#

That is not a Stripe function so no idea what that does

#

Do you have access to your backend here?

modern estuary
#

I do

pale terrace
#

Okay can you show me your server-side code where you create your PaymentIntent?

dusky dawn
#

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?

modern estuary
#

Jonathan is someone else working on this problem with me that have better insights

pale terrace
#

Yeah you don't need to create the PaymentIntent up front, what you are doing now is fine.

#

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

#

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

modern estuary
#

i am assuming that is the same as mobilepay and twint

pale terrace
#

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.