Commit 58a49cd8 authored by mattwire's avatar mattwire
Browse files

Don't try to record refund for an uncaptured payment(Intent)

parent 0770e065
......@@ -248,6 +248,11 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
return TRUE;
case 'charge.refunded':
// Cancelling an uncaptured paymentIntent triggers charge.refunded but we don't want to process that
if (empty(CRM_Stripe_Api::getObjectParam('captured', $this->_inputParameters->data->object))) {
return TRUE;
};
// This charge was actually captured, so record the refund in CiviCRM
$this->setInfo();
$refunds = \Stripe\Refund::all(['charge' => $this->charge_id, 'limit' => 1]);
$params = [
......
......@@ -37,6 +37,9 @@ class CRM_Stripe_Api {
case 'invoice_id':
return (string) $stripeObject->invoice;
case 'captured':
return (bool) $stripeObject->captured;
}
break;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment