Reputation: 7260
When I iterate through sessions or payment intents using stripe, status does not reveal if payment has been refunded.
How to know if Stripe payment intent or session has been refunded?
Upvotes: 1
Views: 944
Reputation: 1354
The PaymentIntent itself will not change when the payment is refunded. In Stripe, refunds are created off of the underlying Charges. You can if a payment intent was refunded by checking its latest_charge
's refunded
property.
const paymentIntent = await stripe.paymentIntents.retrieve(
'pi_1234',
['expand' => ['latest_charge']]
);
const refunded = paymentIntent.latest_charge.refunded;
const amount_refunded = paymentIntent.latest_charge.amount_refunded;
);
[1] https://stripe.com/docs/api/errors?lang=node#errors-payment_intent-latest_charge
[2] https://stripe.com/docs/api/charges/object?lang=node#charge_object-refunded
Upvotes: 4