Skip to content

Commit

Permalink
Merge pull request #325 from craftcms/bugfix/payment-intent-webhook-e…
Browse files Browse the repository at this point in the history
…rror

Fixed error handling webhook that doesn’t find a transaction
  • Loading branch information
lukeholder authored Feb 5, 2025
2 parents d223fef + 84288cd commit 7d9f00a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Stripe for Craft Commerce

## Unreleased

- Fixed a PHP error that could occur when handling a webhook request.

## 4.1.5.2 - 2025-02-03

- Fixed a JavaScript error that could occur when attempting to make a payment on a completed order. ([#312](https://github.com/craftcms/commerce-stripe/issues/312))
Expand Down
7 changes: 5 additions & 2 deletions src/base/SubscriptionGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public function getSubscriptionPlans(): array
$planName = null !== $plan['nickname'] ? $plan['nickname'] : $plan['id'] . ' (No nickname set)';
$output[] = ['name' => $planName, 'reference' => $plan['id']];
}

return $output;
}

Expand Down Expand Up @@ -527,7 +527,10 @@ public function handlePaymentIntentSucceeded(array $data): void
$updateTransaction = null;

if ($transaction->parentId === null) {
$children = Plugin::getInstance()->getTransactions()->getChildrenByTransactionId($transaction->id);
// Try and retrieve child transactions if this is a saved transaction
$children = $transaction->id
? Plugin::getInstance()->getTransactions()->getChildrenByTransactionId($transaction->id)
: [];

if (empty($children) && $transaction->status === TransactionRecord::STATUS_PROCESSING) {
$updateTransaction = $transaction;
Expand Down

0 comments on commit 7d9f00a

Please sign in to comment.