简体   繁体   English

如何知道 Stripe payment intent 或 session 是否已退款?

[英]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.当我使用stripe遍历会话付款意向时,状态不会显示付款是否已退还。

How to know if Stripe payment intent or session has been refunded?如何知道 Stripe payment intent 或 session 是否已退款?

The PaymentIntent itself will not change when the payment is refunded.退款时 PaymentIntent 本身不会改变。 In Stripe, refunds are created off of the underlying Charges.在 Stripe 中,退款是根据基础费用创建的。 You can if a payment intent was refunded by checking its latest_charge 's refunded property.如果付款意向已通过检查其latest_chargerefunded属性进行退款,则可以。

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 [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 [2] https://stripe.com/docs/api/charges/object?lang=node#charge_object-refunded

Please provide some code to get help.请提供一些代码以获得帮助。

Here is an example from PaymentIntents这是PaymentIntents的一个例子

const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId);

console.log(paymentIntent)

PaymentIntents支付意向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM