Actions
2 years ago
DonationAbandoned.php
2 years ago
DonationCancelled.php
2 years ago
DonationCompleted.php
2 years ago
DonationFailed.php
2 years ago
DonationPending.php
2 years ago
DonationPreapproval.php
2 years ago
DonationProcessing.php
2 years ago
DonationRefunded.php
2 years ago
DonationRevoked.php
2 years ago
SubscriptionActive.php
2 years ago
SubscriptionCancelled.php
2 years ago
SubscriptionCompleted.php
2 years ago
SubscriptionExpired.php
2 years ago
SubscriptionFailing.php
2 years ago
SubscriptionFirstDonationCompleted.php
2 years ago
SubscriptionRenewalDonationCreated.php
2 years ago
SubscriptionSuspended.php
2 years ago
DonationProcessing.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\Webhooks\EventHandlers; |
| 4 | |
| 5 | use Exception; |
| 6 | use Give\Donations\ValueObjects\DonationStatus; |
| 7 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\UpdateDonationStatus; |
| 8 | |
| 9 | /** |
| 10 | * @since 3.6.0 |
| 11 | */ |
| 12 | class DonationProcessing |
| 13 | { |
| 14 | /** |
| 15 | * @since 3.6.0 |
| 16 | * @throws Exception |
| 17 | */ |
| 18 | public function __invoke(string $gatewayTransactionId, string $message = '', $skipRecurringDonations = false) |
| 19 | { |
| 20 | $donation = give()->donations->getByGatewayTransactionId($gatewayTransactionId); |
| 21 | |
| 22 | if ( ! $donation || $donation->status->isProcessing()) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | if ($skipRecurringDonations && ! $donation->type->isSingle()) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | (new UpdateDonationStatus())($donation, DonationStatus::PROCESSING(), $message); |
| 31 | } |
| 32 | } |
| 33 |