diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php index 92959adc68dec5699f4315a291cd703b9466c4d9..3f1a0115524e923863f7c009ee5c35cacb2be32e 100644 --- a/CRM/Core/Payment/StripeIPN.php +++ b/CRM/Core/Payment/StripeIPN.php @@ -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 = [ diff --git a/CRM/Stripe/Api.php b/CRM/Stripe/Api.php index 554563b3faa66aa09e6a224a840daf734d03e417..55137eba0bcd25c78d457de732fc0f009f5285ed 100644 --- a/CRM/Stripe/Api.php +++ b/CRM/Stripe/Api.php @@ -37,6 +37,9 @@ class CRM_Stripe_Api { case 'invoice_id': return (string) $stripeObject->invoice; + case 'captured': + return (bool) $stripeObject->captured; + } break;