#geimsdin-PaymentElement

1 messages · Page 1 of 1 (latest)

hidden radish
#

Hi there, so you want to avoid the redirects that triggered by the PaymentElement, am I right?

empty turtle
#

Yes, if I display on Iframe I just want to get the submit event on the payment form and then handle everything on the modal Iframe. When done get the response and if successful trigger the order closing, if error stay there and ask for another payment info to the customer.

hidden radish
#

For instance, if your customer chooses credit card as the payment method, no redirected is triggered. However, if you customer chooses Klarna, redirect will still be triggered.

empty turtle
#

The payment methods offered are card and sepa_debit

#

What if the credit card requires £ds auth?

#

3ds

hidden radish
#

The 3DS will be handled in a modal, no redirect is needed.

#

However sepa_debit still requires a redirect if I remember correctly.

empty turtle
#

there is no way to avoid the redirect or handle it in a modal?

hidden radish
#

No I'm afraid, certain payment methods require redirect to complete the payment

empty turtle
#

ok

empty turtle
#

I'm testing using the documentation provided cards, even if I use the cards without not sufficient funds the payload that I receive back is always this:

pay_for_order: true
key:
setup_intent: seti_1LV5oHLmxBucQd15xnFlloQ8
setup_intent_client_secret: seti_1LV5oHLmxBucQd15xnFlloQ8_secret_MDWsH967jAstQg5JaU6raWtz4V3x45I
redirect_status: succeeded

How should I know that the payment has failed?

hidden radish
#

There's no payment involved here because you are using SetupIntents API

empty turtle
#

Ok but if the card submitted is not valid how should I know?

#

Not enough found, wrong data or any other failure is not reported?

#

*funds

hidden radish
#

You will only get not sufficient funds error during a payment (e.g., PaymentIntents API), that's when the card issuer checks the customer's account and decide whether to approve/decline the transaction

empty turtle
#

Then, in my specific case I need to start a scheduled subscription, I collect the Payment Method through a setup intent, then I should charge it right away for the first iteration and get the data in the same payload, as far as I understand it is impossible because subscription will only hand me the data through webhook even if the starting date is "now", correct?

Do you have any suggestion on how to verify the payment live?

#

the payment method, not the payment.

#

Is it SetupAttempts?

hidden radish
#

There's no way to avoid the not sufficient funds error even if the SetupIntents are successful.

When a recurring payment fails, Stripe will perform smart retries and/or send emails to your customer based on your settings. You can also listen to webhook event invoice.payment_failed and inform your customer to provide another payment method.

empty turtle
#

I understand Jack, the problem is that I would like to avoid to create an order based on a payment method that will never work, I would like to inform the customer of the failure and invite him to provide a correct one before creating that order.

#

There is not a "charge attempt" method that I can run by php before create the schedule and the order?

hidden radish
#

I'll suggest to make your application more robust in the payment failure handling because it's very common. Even if you have a successful payment before creating the subscription, the same payment method can still fail in the subscription's recurring payments.

empty turtle
#

Ok, I will follow your suggestion. Thanks for being always competent and kind.

have a nice day, you can close this.

hidden radish
#

No problem. Happy to help 🙂

empty turtle
#

Wait

#

Another problem I'm noticing

hidden radish
#

Sure

empty turtle
#

If I test with some failing card like this: 4000000000000119

I get a js error and the process stucks

#

Here are the screenshots

hidden radish
#

Can you share with me the request ID?

empty turtle
#

SetupIntent id?

#

payment_method_data[payment_user_agent]: stripe.js/1220a6236; stripe-js-v3/1220a6236; payment-element
payment_method_data[time_on_page]: 12507
payment_method_data[guid]: 4ce7c14a-b6b6-4acf-96d4-a152db9782b5633102
payment_method_data[muid]: b4b0d16e-45fb-4358-b651-88817774d79022eba6
payment_method_data[sid]: 57621158-bb47-4d72-aacb-ea29c15b76ebb3f06a

#

is this enough?

hidden radish
#

You can share with me the SetupIntent ID

empty turtle
#

seti_1LV6RBLmxBucQd1590Gh2yOC_secret_MDXWQOWhzXODkK9mF7RaXDf9qM0yIdF

#

Setup intent id and client secret

hidden radish
empty turtle
#

Why stripe is replying with a 402?

#

I see the json response with all the error data

#

but 402 crashes

hidden radish
#

Because you are using a failing test card, it's expected to return a 402

empty turtle
#

ok, I'm also using the js provided in stripe examples to handle the error

#

form.addEventListener('submit', async (event) => {
event.preventDefault();

    const {error} = await stripe.confirmSetup({
        //`Elements` instance that was used to create the Payment Element
        elements,
        confirmParams: {
            return_url: wcNinjaPaymentData.wcNpReturnUrl,
        }
    });

    if (error) {
        // This point will only be reached if there is an immediate error when
        // confirming the payment. Show error to your customer (for example, payment
        // details incomplete)
        const messageContainer = document.querySelector('#wcnp-error-message');
        messageContainer.textContent = error.message;
    } else {
        // Your customer will be redirected to your `return_url`. For some payment
        // methods like iDEAL, your customer will be redirected to an intermediate
        // site first to authorize the payment, then redirected to the `return_url`.
    }
});
#

it should handle it and fill my error div

hidden radish
#

I don't see a problem in this code

empty turtle
#

me too

#

ok, it is just woocommerce not closing the ajax request because of error, I will force it

hidden radish
#

you may want to check with woocommerce on this problem, and ask whether they are handling the card decline properly.

empty turtle
#

I will deal it myself 🙂

#

Thanks again Jack