Actions
11 months 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
11 months ago
SubscriptionPaused.php
11 months ago
SubscriptionPending.php
11 months ago
SubscriptionRenewalDonationCreated.php
1 year ago
SubscriptionSuspended.php
2 years ago
SubscriptionSuspended.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\Webhooks\EventHandlers; |
| 4 | |
| 5 | use Exception; |
| 6 | use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\UpdateSubscriptionStatus; |
| 7 | use Give\Subscriptions\ValueObjects\SubscriptionStatus; |
| 8 | |
| 9 | /** |
| 10 | * @since 3.6.0 |
| 11 | */ |
| 12 | class SubscriptionSuspended |
| 13 | { |
| 14 | /** |
| 15 | * @since 3.6.0 |
| 16 | * |
| 17 | * @throws Exception |
| 18 | */ |
| 19 | public function __invoke(string $gatewaySubscriptionId, string $message = '') |
| 20 | { |
| 21 | $subscription = give()->subscriptions->getByGatewaySubscriptionId($gatewaySubscriptionId); |
| 22 | |
| 23 | if ( ! $subscription || $subscription->status->isSuspended()) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | (new UpdateSubscriptionStatus())($subscription, SubscriptionStatus::SUSPENDED(), $message); |
| 28 | } |
| 29 | } |
| 30 |