← All changes
|
src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionRenewalDonationCreated.php
+19
-1
4.16.2
→
4.18.0
View file →
| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | */ |
| 12 | 12 | class SubscriptionRenewalDonationCreated |
| 13 | 13 | { |
| 14 | 14 | /** |
| 15 | + * @since 4.18.0 Bail when the subscription has no initial donation instead of fataling on it. | |
| 15 | 16 | * @since 4.0.0 updated to create the renewal from subscription model |
| 16 | 17 | * @since 3.16.0 Add log messages and a defensive approach to prevent duplicated renewals |
| 17 | 18 | * @since 3.6.0 |
| 18 | 19 | */ |
| @@ -36,9 +37,26 @@ | ||
| 36 | 37 | |
| 37 | 38 | return; |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | - if ($subscription->initialDonation()->gatewayTransactionId === $gatewayTransactionId) { | |
| 41 | + $initialDonation = $subscription->initialDonation(); | |
| 42 | + | |
| 43 | + if ( ! $initialDonation) { | |
| 44 | + PaymentGatewayLog::error( | |
| 45 | + sprintf('The renewal was not created for the gateway transaction ID %s because the subscription %s has no initial donation to copy the donor details from.', | |
| 46 | + $gatewayTransactionId, $subscription->id), | |
| 47 | + [ | |
| 48 | + 'Gateway Subscription ID' => $gatewaySubscriptionId, | |
| 49 | + 'Gateway Transaction ID' => $gatewayTransactionId, | |
| 50 | + 'Message' => $message, | |
| 51 | + 'Subscription' => $subscription->toArray(), | |
| 52 | + ] | |
| 53 | + ); | |
| 54 | + | |
| 55 | + return; | |
| 56 | + } | |
| 57 | + | |
| 58 | + if ($initialDonation->gatewayTransactionId === $gatewayTransactionId) { | |
| 41 | 59 | PaymentGatewayLog::error( |
| 42 | 60 | sprintf('The renewal was not created for the gateway transaction ID %s because the initial donation of the subscription %s is already using the informed gateway transaction ID %s.', |
| 43 | 61 | $gatewayTransactionId, $subscription->id, $gatewaySubscriptionId), |
| 44 | 62 | [ |