PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
← All changes | src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionFirstDonationCompleted.php +18 -3 4.16.0 → 4.18.0 View file →
@@ -16,8 +16,9 @@
16 16 */
17 17 class SubscriptionFirstDonationCompleted
18 18 {
19 19 /**
20 + * @since 4.18.0 Guard against a null initial donation and a missing subscription instead of fataling on them.
20 21 * @since 4.16.0 Add $donationId to support gateways that only receive the transaction ID via webhook (e.g. PayFast).
21 22 * @since 4.5.0 Add $setDonationComplete and $gatewaySubscriptionId parameters
22 23 * @since 3.6.0
23 24 */
@@ -46,14 +47,28 @@
46 47 $donation = give()->donations->getByGatewayTransactionId($gatewayTransactionId);
47 48
48 49 if (! $donation && ! empty($gatewaySubscriptionId) && $subscription = give()->subscriptions->getByGatewaySubscriptionId($gatewaySubscriptionId)) {
49 50 $donation = $subscription->initialDonation();
50 - $donation->gatewayTransactionId = $gatewayTransactionId;
51 - $donation->save();
51 +
52 + if ($donation) {
53 + $donation->gatewayTransactionId = $gatewayTransactionId;
54 + $donation->save();
55 + }
52 56 }
53 57 }
54 58
55 - if ( ! $donation || ! $donation->type->isSubscription() || $donation->id !== $donation->subscription->initialDonation()->id) {
59 + if ( ! $donation || ! $donation->subscription || ! $donation->type->isSubscription()) {
60 + PaymentGatewayLog::error(
61 + sprintf('The first donation was not updated for the gateway transaction ID %s because no valid subscription donation was found to update.',
62 + $gatewayTransactionId),
63 + [
64 + 'Gateway Subscription ID' => $gatewaySubscriptionId,
65 + 'Gateway Transaction ID' => $gatewayTransactionId,
66 + 'Donation ID' => $donationId,
67 + 'Message' => $message,
68 + ]
69 + );
70 +
56 71 return;
57 72 }
58 73
59 74 try {