#geimsdin-PaymentElement
1 messages · Page 1 of 1 (latest)
Hi there, so you want to avoid the redirects that triggered by the PaymentElement, am I right?
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.
Understood. You can set (https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-redirect) redirect to if_required so that Stripe.js will only redirect if your user chooses a redirect-based payment method.
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.
The payment methods offered are card and sepa_debit
What if the credit card requires £ds auth?
3ds
The 3DS will be handled in a modal, no redirect is needed.
However sepa_debit still requires a redirect if I remember correctly.
there is no way to avoid the redirect or handle it in a modal?
No I'm afraid, certain payment methods require redirect to complete the payment
ok
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?
There's no payment involved here because you are using SetupIntents API
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
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
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?
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.
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?
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.
Ok, I will follow your suggestion. Thanks for being always competent and kind.
have a nice day, you can close this.
No problem. Happy to help 🙂
Sure
If I test with some failing card like this: 4000000000000119
I get a js error and the process stucks
Here are the screenshots
Can you share with me the request ID?
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?
You can share with me the SetupIntent ID
seti_1LV6RBLmxBucQd1590Gh2yOC_secret_MDXWQOWhzXODkK9mF7RaXDf9qM0yIdF
Setup intent id and client secret
https://dashboard.stripe.com/test/logs/req_yQ8gkSC0CRHvO6 you can check the request here, it says Your card's security code is incorrect
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Why stripe is replying with a 402?
Request URL: https://api.stripe.com/v1/setup_intents/seti_1LV6fTLmxBucQd15SkGge0ZC/confirm
Request Method: POST
Status Code: 402
I see the json response with all the error data
but 402 crashes
Because you are using a failing test card, it's expected to return a 402
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
I don't see a problem in this code
me too
ok, it is just woocommerce not closing the ajax request because of error, I will force it
you may want to check with woocommerce on this problem, and ask whether they are handling the card decline properly.