sunknudsen
sunknudsen

Reputation: 7260

How to know if Stripe payment intent or session has been refunded?

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

Answers (1)

Pompey
Pompey

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

Related Questions