Skip to content

Commit 37b4dee

Browse files
authored
Fix: Stripe Payment Element refunded webhook logic (#8201)
1 parent 77aaf83 commit 37b4dee

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/PaymentGateways/Gateways/Stripe/Webhooks/Listeners/ChargeRefunded.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ private function addSupportForLegacyActionHook(Event $event)
5555
}
5656

5757
/**
58+
* @unreleased add support for payment_intent_id
5859
* @since 2.21.0
5960
* @inerhitDoc
6061
*/
@@ -63,6 +64,14 @@ protected function getDonation(Event $event)
6364
/* @var Charge $stripeCharge */
6465
$stripeCharge = $event->data->object;
6566

66-
return give(DonationRepository::class)->getByGatewayTransactionId($stripeCharge->id);
67+
// First try to find by charge ID (legacy Stripe gateways store charge ID)
68+
$donation = give(DonationRepository::class)->getByGatewayTransactionId($stripeCharge->id);
69+
70+
// If not found, try payment_intent (StripePaymentElementGateway stores payment intent ID)
71+
if (!$donation && !empty($stripeCharge->payment_intent)) {
72+
$donation = give(DonationRepository::class)->getByGatewayTransactionId($stripeCharge->payment_intent);
73+
}
74+
75+
return $donation;
6776
}
6877
}

0 commit comments

Comments
 (0)