#.abishek
1 messages · Page 1 of 1 (latest)
so, I am trying to show a success message if there is no error on the promise
so I am trying to get information from the result object on the else section
if (result.error) {
// Inform the customer that there was an error.
}
else{
// Get info from the result object
// Show success message
}
What information do you want to get?
if I can know what the object is returned that would be helpful to know what to show to the customer
- payment_method
- id
- amount
etc..
Can you print the result object?
it redirects to the return url specified, I don't want it to redirect to the return url unless the payment requires it
So, first you will need to set redirect: if_required: https://stripe.com/docs/js/payment_intents/confirm_payment#confirm_payment_intent-options-redirect
And then you can inspect the result object yourself.
ok, i did that, but that doesn't provide info on what payment method was used to pay
how do I get that?
do I have to make a API call to get that?
You can retrieve the PaymentIntent by ID: https://stripe.com/docs/js/payment_intents/retrieve_payment_intent
what I retrieve on the result of confirmPayment is the same as retrieve_payment_intent
both objects don't have what payment method was used
Are you looking for a payment method type or Payment Method object ID?
Why do you need it on the frontend?
to show what payment method was used to make a payment
You can record it before confirming the PaymentIntent if you retrieve the Payment Element: https://stripe.com/docs/js/elements_object/get_payment_element
You can also listen to Payment Element change events and get the type from there value.type: https://stripe.com/docs/js/element/events/on_change?type=paymentElement
ok