#antonio-giano_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/1225567253248872578
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- antonio-giano_best-practices, 3 hours ago, 17 messages
- antonio-giano_best-practices, 4 hours ago, 9 messages
Hello, in case it was not understood, I am happy to elucidate further
Hello! Can you link to the guide you're referring to?
Yep, i am following as follows: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements#create-subscription
What i mean with the question is the following:
``// Initialize Stripe.js using your publishable key
const stripe = Stripe('pk_test_51NaMMyF07S1euBUTme3OQEpK0ySsAirJeeUnEdKbzRLdnMWHtFfrxPqW8vF51G5Avj3CmBKOI1HdgVQ7I1YFsKwy00Jefozlxh');
// Retrieve the "payment_intent_client_secret" query parameter appended to
// your return_url by Stripe.js
const clientSecret = new URLSearchParams(window.location.search).get(
'payment_intent_client_secret'
);
// Retrieve the PaymentIntent
stripe.retrievePaymentIntent(clientSecret).then(({paymentIntent}) => {
const message = document.querySelector('#message')
// Inspect the PaymentIntent status to indicate the status of the payment
// to your customer.
//
// Some payment methods will [immediately succeed or fail][0] upon
// confirmation, while others will first enter a processing state.
//
// [0]: https://stripe.com/docs/payments/payment-methods#payment-notification
switch (paymentIntent.status) {
case 'succeeded':
message.innerText = 'Success! Payment received.';
break;
case 'processing':
message.innerText = "Payment processing. We'll update you when payment is received.";
break;
case 'requires_payment_method':
message.innerText = 'Payment failed. Please try another payment method.';
// Redirect your user back to your payment page to attempt collecting
// payment again
break;
default:
message.innerText = 'Something went wrong.';
break;
}
});``
What you're referring to happens later in the process. When you use a test card like the one you mentioned, which immediately declines, the error case in the code snippet here is encountered so the customer can correct the issue in the Payment Element: https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=web&ui=elements#complete-payment
The return_url is only used if an immediate error/decline is not encountered.
Got it. What situations, then, lead to having an event of type requires_payment_method?
just to get a complete idea of how to treat 360 degrees
One example is when payment info is provided, a next action of some kind is required (like 3D Secure), that process fails, and thus you get a non-immediate decline. In that case the Payment Method that failed is detached from the Payment Intent and the status of the Payment Intent changes to requires_payment_method. That's when your code above would run.
Got it. Do we have other events besides those present?
Events? Do you mean Payment Intent statuses?
Yes, i mean that
There are others, yeah, but they may not happen in your particular flow. Have a look here: https://docs.stripe.com/payments/paymentintents/lifecycle
Perfect. Thanks for the link
Happy to help!