From a7b87c09e899b4a020b0d6d95e8a7eff0f5032c0 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 27 Dec 2024 16:28:30 -0300 Subject: [PATCH 01/18] feature: add WebhookEvents api --- .../PaymentGateways/PaymentGateway.php | 19 +++ .../ValueObjects/WebhookEventStatus.php | 29 ++++ .../Webhooks/WebhookEvents.php | 130 ++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php create mode 100644 src/Framework/PaymentGateways/Webhooks/WebhookEvents.php diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index 47eed6d65e..949c04d401 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -14,6 +14,7 @@ use Give\Framework\PaymentGateways\Routes\RouteSignature; use Give\Framework\PaymentGateways\Traits\HandleHttpResponses; use Give\Framework\PaymentGateways\Traits\HasRouteMethods; +use Give\Framework\PaymentGateways\Webhooks\WebhookEvents; use Give\Framework\Support\ValueObjects\Money; use Give\Log\Log; use Give\Subscriptions\Models\Subscription; @@ -43,6 +44,13 @@ abstract class PaymentGateway implements PaymentGatewayInterface, public $subscriptionModule; /** + * @unreleased + * @var WebhookEvents $webhookEvents + */ + public $webhookEvents; + + /** + * @unreleased Set the webhookEvents property * @since 2.20.0 Change first argument type to SubscriptionModule abstract class. * @since 2.18.0 * @@ -55,6 +63,17 @@ public function __construct(SubscriptionModule $subscriptionModule = null) } $this->subscriptionModule = $subscriptionModule; + $this->webhookEvents = new WebhookEvents($this); + } + + /** + * @unreleased + */ + public static function webhookEvents(): WebhookEvents + { + $instance = new static(); + + return $instance->webhookEvents; } /** diff --git a/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php b/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php new file mode 100644 index 0000000000..d5f6d5e8a6 --- /dev/null +++ b/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php @@ -0,0 +1,29 @@ +gateway = $gateway; + } + + /** + * @unreleased + * + * @return int The webhook event ID. Zero if there was an error setting the event. + */ + public function setDonationStatus( + DonationStatus $status, + string $gatewayTransactionId, + string $message = '', + $skipRecurringDonations = false + ): int { + $hook = "givewp_{$this->gateway::id()}_webhook_event_donation_{$status->getValue()}"; + $args = [$gatewayTransactionId, $message, $skipRecurringDonations]; + $group = $this->getGroup(); + + return AsBackgroundJobs::enqueueAsyncAction($hook, $args, $group); + } + + /** + * @unreleased + * + * @return int The webhook event ID. Zero if there was an error setting the event. + */ + public function setSubscriptionStatus( + SubscriptionStatus $status, + string $gatewaySubscriptionId, + string $message = '', + bool $initialDonationShouldBeCompleted = false + ): int { + $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_{$status->getValue()}"; + $args = [$gatewaySubscriptionId, $message, $initialDonationShouldBeCompleted]; + $group = $this->getGroup(); + + return AsBackgroundJobs::enqueueAsyncAction($hook, $args, $group); + } + + /** + * @unreleased + * + * @return int The webhook event ID. Zero if there was an error setting the event. + */ + public function setSubscriptionFirstDonation( + string $gatewayTransactionId, + string $message = '', + bool $setSubscriptionActive = true + ): int { + $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_first_donation"; + $args = [$gatewayTransactionId, $message, $setSubscriptionActive]; + $group = $this->getGroup(); + + return AsBackgroundJobs::enqueueAsyncAction($hook, $args, $group); + } + + /** + * @unreleased + * + * @return int The webhook event ID. Zero if there was an error setting the event. + */ + public function setSubscriptionRenewalDonation( + string $gatewaySubscriptionId, + string $gatewayTransactionId, + string $message = '' + ): int { + $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_renewal_donation"; + $args = [$gatewaySubscriptionId, $gatewayTransactionId, $message]; + $group = $this->getGroup(); + + return AsBackgroundJobs::enqueueAsyncAction($hook, $args, $group); + } + + /** + * @unreleased + * + * @param string $returnFormat OBJECT, ARRAY_A, or ids. + * @param string $status ActionScheduler_Store::STATUS_COMPLETE, ActionScheduler_Store::STATUS_PENDING, ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_FAILED, ActionScheduler_Store::STATUS_CANCELED + * + * @return array + */ + public function getAll(string $returnFormat = OBJECT, string $status = ''): array + { + return AsBackgroundJobs::getActionsByGroup($this->getGroup(), $status); + } + + /** + * @unreleased + * + * @param string $status ActionScheduler_Store::STATUS_COMPLETE, ActionScheduler_Store::STATUS_PENDING, ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_FAILED, ActionScheduler_Store::STATUS_CANCELED + * + * @return int Total deleted webhook events. + */ + public function deleteAll(string $status = ''): int + { + return AsBackgroundJobs::deleteActionsByGroup($this->getGroup(), $status); + } + + /** + * @unreleased + */ + private function getGroup(): string + { + return 'give-' . $this->gateway::id(); + } +} From 3e434090848cb13c827d4a29b840f8cdeb91f0e2 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 12:35:07 -0300 Subject: [PATCH 02/18] feature: add service provider --- .../PaymentGateways/ServiceProvider.php | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/Framework/PaymentGateways/ServiceProvider.php diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php new file mode 100644 index 0000000000..b06f0a6125 --- /dev/null +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -0,0 +1,97 @@ +gateways->getPaymentGateways(); + foreach ($registeredPaymentGatewayIds as $gatewayId) { + $this->registerDonationEventHandlers($gatewayId); + } + } + + /** + * @unreleased + */ + private function registerDonationEventHandlers(string $gatewayId) + { + foreach (DonationStatus::values() as $status) { + switch ($status) { + case $status->isAbandoned(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationAbandoned::class); + break; + case $status->isCancelled(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationCancelled::class); + break; + case $status->isComplete(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationCompleted::class); + break; + case $status->isFailed(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationFailed::class); + break; + case $status->isPending(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationPending::class); + break; + case $status->isPreapproval(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationPreapproval::class); + break; + case $status->isProcessing(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationProcessing::class); + break; + case $status->isRefunded(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationRefunded::class); + break; + case $status->isRevoked(): + $this->addDonationStatusEventHandler($gatewayId, $status, DonationRevoked::class); + break; + } + } + } + + /** + * @unreleased + */ + private function addDonationStatusEventHandler( + string $gatewayId, + DonationStatus $status, + string $eventHandlerClass + ) { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_donation_%s', + $gatewayId, + $status->getValue() + ), + $eventHandlerClass + ); + } +} From 1d4ed35c90b9f718f9c77ad57caff98048c741b7 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 14:40:40 -0300 Subject: [PATCH 03/18] feature: add subscription events --- .../PaymentGateways/PaymentGateway.php | 9 +- .../PaymentGatewayRegister.php | 5 +- .../PaymentGateways/ServiceProvider.php | 90 ++++++++++++++++++- .../Webhooks/WebhookEvents.php | 8 +- 4 files changed, 103 insertions(+), 9 deletions(-) diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index 949c04d401..847770d1b7 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -50,20 +50,23 @@ abstract class PaymentGateway implements PaymentGatewayInterface, public $webhookEvents; /** - * @unreleased Set the webhookEvents property + * @unreleased Add the webhookEvents parameter + * * @since 2.20.0 Change first argument type to SubscriptionModule abstract class. * @since 2.18.0 * * @param SubscriptionModule|null $subscriptionModule */ - public function __construct(SubscriptionModule $subscriptionModule = null) + public function __construct(WebhookEvents $webhookEvents, SubscriptionModule $subscriptionModule = null) { + $webhookEvents->setGateway($this); + $this->webhookEvents = $webhookEvents; + if ($subscriptionModule !== null) { $subscriptionModule->setGateway($this); } $this->subscriptionModule = $subscriptionModule; - $this->webhookEvents = new WebhookEvents($this); } /** diff --git a/src/Framework/PaymentGateways/PaymentGatewayRegister.php b/src/Framework/PaymentGateways/PaymentGatewayRegister.php index a0d0cd72ce..b27edbbe99 100644 --- a/src/Framework/PaymentGateways/PaymentGatewayRegister.php +++ b/src/Framework/PaymentGateways/PaymentGatewayRegister.php @@ -7,6 +7,7 @@ use Give\Framework\Exceptions\Primitives\InvalidArgumentException; use Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator; use Give\Framework\PaymentGateways\Exceptions\OverflowException; +use Give\Framework\PaymentGateways\Webhooks\WebhookEvents; /** * @since 2.18.0 @@ -114,6 +115,7 @@ public function unregisterGateway($gatewayId) * Register Gateway with Service Container as Singleton * with option of adding Subscription Module through filter "give_gateway_{$gatewayId}_subscription_module" * + * @unreleased Add the webhookEvents parameter to the gateway class * @since 2.18.0 * * @return void @@ -123,7 +125,8 @@ private function registerGatewayWithServiceContainer(string $gatewayClass, strin give()->singleton($gatewayClass, function (Container $container) use ($gatewayClass, $gatewayId) { $subscriptionModule = apply_filters("givewp_gateway_{$gatewayId}_subscription_module", null); - return new $gatewayClass($subscriptionModule ? $container->make($subscriptionModule) : null); + return new $gatewayClass(new WebhookEvents(), + $subscriptionModule ? $container->make($subscriptionModule) : null); }); } } diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php index b06f0a6125..53643e8319 100644 --- a/src/Framework/PaymentGateways/ServiceProvider.php +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -12,8 +12,17 @@ use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationProcessing; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRefunded; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRevoked; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionActive; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCancelled; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCompleted; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionExpired; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFailing; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFirstDonationCompleted; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionRenewalDonationCreated; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionSuspended; use Give\Helpers\Hooks; use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; +use Give\Subscriptions\ValueObjects\SubscriptionStatus; /** * @unreleased @@ -36,6 +45,7 @@ public function boot() $registeredPaymentGatewayIds = give()->gateways->getPaymentGateways(); foreach ($registeredPaymentGatewayIds as $gatewayId) { $this->registerDonationEventHandlers($gatewayId); + $this->registerSubscriptionEventHandlers($gatewayId); } } @@ -87,7 +97,85 @@ private function addDonationStatusEventHandler( ) { Hooks::addAction( sprintf( - 'givewp_%s_webhook_event_donation_%s', + 'givewp_%s_webhook_event_donation_status_%s', + $gatewayId, + $status->getValue() + ), + $eventHandlerClass + ); + } + + /** + * @unreleased + */ + private function registerSubscriptionEventHandlers(string $gatewayId) + { + $this->addSubscriptionFirstDonationEventHandler($gatewayId); + $this->addSubscriptionRenewalDonationEventHandler($gatewayId); + + foreach (SubscriptionStatus::values() as $status) { + switch ($status) { + case $status->isActive(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionActive::class); + break; + case $status->isCancelled(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionCancelled::class); + break; + case $status->isCompleted(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionCompleted::class); + break; + case $status->isExpired(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionExpired::class); + break; + case $status->isFailing(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionFailing::class); + break; + case $status->isSuspended(): + $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionSuspended::class); + break; + } + } + } + + /** + * @unreleased + */ + private function addSubscriptionFirstDonationEventHandler(string $gatewayId) + { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_subscription_first_donation', + $gatewayId + ), + SubscriptionFirstDonationCompleted::class + ); + } + + /** + * @unreleased + */ + private function addSubscriptionRenewalDonationEventHandler(string $gatewayId) + { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_subscription_renewal_donation', + $gatewayId + ), + SubscriptionRenewalDonationCreated::class + ); + } + + /** + * @unreleased + */ + private function addSubscriptionStatusEventHandler( + string $gatewayId, + SubscriptionStatus $status, + string $eventHandlerClass + ) { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_subscription_status_%s', $gatewayId, $status->getValue() ), diff --git a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php index ffba7dc9b7..483824937c 100644 --- a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php +++ b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php @@ -20,7 +20,7 @@ class WebhookEvents /** * @unreleased */ - public function __construct(PaymentGateway $gateway) + public function setGateway(PaymentGateway $gateway) { $this->gateway = $gateway; } @@ -36,7 +36,7 @@ public function setDonationStatus( string $message = '', $skipRecurringDonations = false ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_donation_{$status->getValue()}"; + $hook = "givewp_{$this->gateway::id()}_webhook_event_donation_status_{$status->getValue()}"; $args = [$gatewayTransactionId, $message, $skipRecurringDonations]; $group = $this->getGroup(); @@ -54,7 +54,7 @@ public function setSubscriptionStatus( string $message = '', bool $initialDonationShouldBeCompleted = false ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_{$status->getValue()}"; + $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_status_{$status->getValue()}"; $args = [$gatewaySubscriptionId, $message, $initialDonationShouldBeCompleted]; $group = $this->getGroup(); @@ -125,6 +125,6 @@ public function deleteAll(string $status = ''): int */ private function getGroup(): string { - return 'give-' . $this->gateway::id(); + return 'givewp-payment-gateway-' . $this->gateway::id(); } } From 5bd3a0a480574ae291dc88b25960d43fc32a1d1c Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 15:00:29 -0300 Subject: [PATCH 04/18] refactor: remove parameter --- src/Framework/PaymentGateways/PaymentGateway.php | 9 ++++----- src/Framework/PaymentGateways/PaymentGatewayRegister.php | 5 +---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index 847770d1b7..d90f2b3a02 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -45,28 +45,27 @@ abstract class PaymentGateway implements PaymentGatewayInterface, /** * @unreleased + * * @var WebhookEvents $webhookEvents */ public $webhookEvents; /** - * @unreleased Add the webhookEvents parameter + * @unreleased Add the webhookEvents property * * @since 2.20.0 Change first argument type to SubscriptionModule abstract class. * @since 2.18.0 * * @param SubscriptionModule|null $subscriptionModule */ - public function __construct(WebhookEvents $webhookEvents, SubscriptionModule $subscriptionModule = null) + public function __construct(SubscriptionModule $subscriptionModule = null) { - $webhookEvents->setGateway($this); - $this->webhookEvents = $webhookEvents; - if ($subscriptionModule !== null) { $subscriptionModule->setGateway($this); } $this->subscriptionModule = $subscriptionModule; + $this->webhookEvents = new WebhookEvents(); } /** diff --git a/src/Framework/PaymentGateways/PaymentGatewayRegister.php b/src/Framework/PaymentGateways/PaymentGatewayRegister.php index b27edbbe99..a0d0cd72ce 100644 --- a/src/Framework/PaymentGateways/PaymentGatewayRegister.php +++ b/src/Framework/PaymentGateways/PaymentGatewayRegister.php @@ -7,7 +7,6 @@ use Give\Framework\Exceptions\Primitives\InvalidArgumentException; use Give\Framework\PaymentGateways\Contracts\PaymentGatewaysIterator; use Give\Framework\PaymentGateways\Exceptions\OverflowException; -use Give\Framework\PaymentGateways\Webhooks\WebhookEvents; /** * @since 2.18.0 @@ -115,7 +114,6 @@ public function unregisterGateway($gatewayId) * Register Gateway with Service Container as Singleton * with option of adding Subscription Module through filter "give_gateway_{$gatewayId}_subscription_module" * - * @unreleased Add the webhookEvents parameter to the gateway class * @since 2.18.0 * * @return void @@ -125,8 +123,7 @@ private function registerGatewayWithServiceContainer(string $gatewayClass, strin give()->singleton($gatewayClass, function (Container $container) use ($gatewayClass, $gatewayId) { $subscriptionModule = apply_filters("givewp_gateway_{$gatewayId}_subscription_module", null); - return new $gatewayClass(new WebhookEvents(), - $subscriptionModule ? $container->make($subscriptionModule) : null); + return new $gatewayClass($subscriptionModule ? $container->make($subscriptionModule) : null); }); } } From ac58b07813851194a70ce845bbacb0a4743d2cd7 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 15:07:16 -0300 Subject: [PATCH 05/18] refactor: move setGateway logic to constructor --- src/Framework/PaymentGateways/PaymentGateway.php | 2 +- src/Framework/PaymentGateways/Webhooks/WebhookEvents.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index d90f2b3a02..4170128fbf 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -65,7 +65,7 @@ public function __construct(SubscriptionModule $subscriptionModule = null) } $this->subscriptionModule = $subscriptionModule; - $this->webhookEvents = new WebhookEvents(); + $this->webhookEvents = new WebhookEvents($this); } /** diff --git a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php index 483824937c..bc20adf5b6 100644 --- a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php +++ b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php @@ -20,7 +20,7 @@ class WebhookEvents /** * @unreleased */ - public function setGateway(PaymentGateway $gateway) + public function __construct(PaymentGateway $gateway) { $this->gateway = $gateway; } From be0c8af8b007efcb6cfe2e969f08d8f14b135bdf Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 15:10:14 -0300 Subject: [PATCH 06/18] refactor: remove status parameters --- .../PaymentGateways/Webhooks/WebhookEvents.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php index bc20adf5b6..344af53ee0 100644 --- a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php +++ b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php @@ -99,25 +99,22 @@ public function setSubscriptionRenewalDonation( * @unreleased * * @param string $returnFormat OBJECT, ARRAY_A, or ids. - * @param string $status ActionScheduler_Store::STATUS_COMPLETE, ActionScheduler_Store::STATUS_PENDING, ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_FAILED, ActionScheduler_Store::STATUS_CANCELED * * @return array */ - public function getAll(string $returnFormat = OBJECT, string $status = ''): array + public function getAll(string $returnFormat = OBJECT): array { - return AsBackgroundJobs::getActionsByGroup($this->getGroup(), $status); + return AsBackgroundJobs::getActionsByGroup($this->getGroup()); } /** * @unreleased * - * @param string $status ActionScheduler_Store::STATUS_COMPLETE, ActionScheduler_Store::STATUS_PENDING, ActionScheduler_Store::STATUS_RUNNING, ActionScheduler_Store::STATUS_FAILED, ActionScheduler_Store::STATUS_CANCELED - * * @return int Total deleted webhook events. */ - public function deleteAll(string $status = ''): int + public function deleteAll(): int { - return AsBackgroundJobs::deleteActionsByGroup($this->getGroup(), $status); + return AsBackgroundJobs::deleteActionsByGroup($this->getGroup()); } /** From b81816665f7324c24e08cb5ab56a61980d87fef7 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 15:42:46 -0300 Subject: [PATCH 07/18] refactor: move register logic to give_init hook --- give.php | 1 + src/Framework/PaymentGateways/ServiceProvider.php | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/give.php b/give.php index 2a00cb3b32..9251db00e5 100644 --- a/give.php +++ b/give.php @@ -244,6 +244,7 @@ final class Give Give\DonationSpam\ServiceProvider::class, Give\Settings\ServiceProvider::class, Give\FeatureFlags\OptionBasedFormEditor\ServiceProvider::class, + Give\Framework\PaymentGateways\ServiceProvider::class, ]; /** diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php index 53643e8319..faccfde367 100644 --- a/src/Framework/PaymentGateways/ServiceProvider.php +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -42,11 +42,13 @@ public function register() */ public function boot() { - $registeredPaymentGatewayIds = give()->gateways->getPaymentGateways(); - foreach ($registeredPaymentGatewayIds as $gatewayId) { - $this->registerDonationEventHandlers($gatewayId); - $this->registerSubscriptionEventHandlers($gatewayId); - } + add_action('give_init', function () { + $registeredPaymentGatewayIds = give()->gateways->getPaymentGateways(); + foreach ($registeredPaymentGatewayIds as $gatewayId) { + $this->registerDonationEventHandlers($gatewayId); + $this->registerSubscriptionEventHandlers($gatewayId); + } + }, 999); } /** From 5a75b35f0645f1f15416cc9f46ddd6edd735f8c3 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 16:33:18 -0300 Subject: [PATCH 08/18] refactor: extract status logic to action classes --- .../PaymentGateways/ServiceProvider.php | 135 ++++-------------- .../GetEventHandlerClassByDonationStatus.php | 49 +++++++ ...tEventHandlerClassBySubscriptionStatus.php | 40 ++++++ 3 files changed, 117 insertions(+), 107 deletions(-) create mode 100644 src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php create mode 100644 src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php index faccfde367..88026762e4 100644 --- a/src/Framework/PaymentGateways/ServiceProvider.php +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -3,23 +3,10 @@ namespace Give\Framework\PaymentGateways; use Give\Donations\ValueObjects\DonationStatus; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationAbandoned; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationCancelled; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationCompleted; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationFailed; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationPending; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationPreapproval; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationProcessing; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRefunded; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\DonationRevoked; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionActive; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCancelled; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCompleted; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionExpired; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFailing; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\GetEventHandlerClassByDonationStatus; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\GetEventHandlerClassBySubscriptionStatus; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFirstDonationCompleted; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionRenewalDonationCreated; -use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionSuspended; use Give\Helpers\Hooks; use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; use Give\Subscriptions\ValueObjects\SubscriptionStatus; @@ -45,8 +32,10 @@ public function boot() add_action('give_init', function () { $registeredPaymentGatewayIds = give()->gateways->getPaymentGateways(); foreach ($registeredPaymentGatewayIds as $gatewayId) { - $this->registerDonationEventHandlers($gatewayId); - $this->registerSubscriptionEventHandlers($gatewayId); + $this->registerDonationStatusEventHandlers($gatewayId); + $this->registerSubscriptionStatusEventHandlers($gatewayId); + $this->registerSubscriptionFirstDonationEventHandler($gatewayId); + $this->registerSubscriptionRenewalDonationEventHandler($gatewayId); } }, 999); } @@ -54,37 +43,18 @@ public function boot() /** * @unreleased */ - private function registerDonationEventHandlers(string $gatewayId) + private function registerDonationStatusEventHandlers(string $gatewayId) { foreach (DonationStatus::values() as $status) { - switch ($status) { - case $status->isAbandoned(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationAbandoned::class); - break; - case $status->isCancelled(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationCancelled::class); - break; - case $status->isComplete(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationCompleted::class); - break; - case $status->isFailed(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationFailed::class); - break; - case $status->isPending(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationPending::class); - break; - case $status->isPreapproval(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationPreapproval::class); - break; - case $status->isProcessing(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationProcessing::class); - break; - case $status->isRefunded(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationRefunded::class); - break; - case $status->isRevoked(): - $this->addDonationStatusEventHandler($gatewayId, $status, DonationRevoked::class); - break; + if ($eventHandlerClass = (new GetEventHandlerClassByDonationStatus())($status)) { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_donation_status_%s', + $gatewayId, + $status->getValue() + ), + $eventHandlerClass + ); } } } @@ -92,49 +62,18 @@ private function registerDonationEventHandlers(string $gatewayId) /** * @unreleased */ - private function addDonationStatusEventHandler( - string $gatewayId, - DonationStatus $status, - string $eventHandlerClass - ) { - Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_donation_status_%s', - $gatewayId, - $status->getValue() - ), - $eventHandlerClass - ); - } - - /** - * @unreleased - */ - private function registerSubscriptionEventHandlers(string $gatewayId) + private function registerSubscriptionStatusEventHandlers(string $gatewayId) { - $this->addSubscriptionFirstDonationEventHandler($gatewayId); - $this->addSubscriptionRenewalDonationEventHandler($gatewayId); - foreach (SubscriptionStatus::values() as $status) { - switch ($status) { - case $status->isActive(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionActive::class); - break; - case $status->isCancelled(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionCancelled::class); - break; - case $status->isCompleted(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionCompleted::class); - break; - case $status->isExpired(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionExpired::class); - break; - case $status->isFailing(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionFailing::class); - break; - case $status->isSuspended(): - $this->addSubscriptionStatusEventHandler($gatewayId, $status, SubscriptionSuspended::class); - break; + if ($eventHandlerClass = (new GetEventHandlerClassBySubscriptionStatus())($status)) { + Hooks::addAction( + sprintf( + 'givewp_%s_webhook_event_subscription_status_%s', + $gatewayId, + $status->getValue() + ), + $eventHandlerClass + ); } } } @@ -142,7 +81,7 @@ private function registerSubscriptionEventHandlers(string $gatewayId) /** * @unreleased */ - private function addSubscriptionFirstDonationEventHandler(string $gatewayId) + private function registerSubscriptionFirstDonationEventHandler(string $gatewayId) { Hooks::addAction( sprintf( @@ -156,7 +95,7 @@ private function addSubscriptionFirstDonationEventHandler(string $gatewayId) /** * @unreleased */ - private function addSubscriptionRenewalDonationEventHandler(string $gatewayId) + private function registerSubscriptionRenewalDonationEventHandler(string $gatewayId) { Hooks::addAction( sprintf( @@ -166,22 +105,4 @@ private function addSubscriptionRenewalDonationEventHandler(string $gatewayId) SubscriptionRenewalDonationCreated::class ); } - - /** - * @unreleased - */ - private function addSubscriptionStatusEventHandler( - string $gatewayId, - SubscriptionStatus $status, - string $eventHandlerClass - ) { - Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_subscription_status_%s', - $gatewayId, - $status->getValue() - ), - $eventHandlerClass - ); - } } diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php new file mode 100644 index 0000000000..3ec6fef552 --- /dev/null +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatus.php @@ -0,0 +1,49 @@ +isAbandoned(): + return DonationAbandoned::class; + case $status->isCancelled(): + return DonationCancelled::class; + case $status->isComplete(): + return DonationCompleted::class; + case $status->isFailed(): + return DonationFailed::class; + case $status->isPending(): + return DonationPending::class; + case $status->isPreapproval(): + return DonationPreapproval::class; + case $status->isProcessing(): + return DonationProcessing::class; + case $status->isRefunded(): + return DonationRefunded::class; + case $status->isRevoked(): + return DonationRevoked::class; + default: + return ''; + } + } +} diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php new file mode 100644 index 0000000000..4fb58d3489 --- /dev/null +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php @@ -0,0 +1,40 @@ +isActive(): + return SubscriptionActive::class; + case $status->isCancelled(): + return SubscriptionCancelled::class; + case $status->isCompleted(): + return SubscriptionCompleted::class; + case $status->isExpired(): + return SubscriptionExpired::class; + case $status->isFailing(): + return SubscriptionFailing::class; + case $status->isSuspended(): + return SubscriptionSuspended::class; + default: + return ''; + } + } +} From 911936dbf9c04926bad083d4d293d95ebd24090e Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 16:34:58 -0300 Subject: [PATCH 09/18] refactor: remove unused value object --- .../ValueObjects/WebhookEventStatus.php | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php diff --git a/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php b/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php deleted file mode 100644 index d5f6d5e8a6..0000000000 --- a/src/Framework/PaymentGateways/Webhooks/ValueObjects/WebhookEventStatus.php +++ /dev/null @@ -1,29 +0,0 @@ - Date: Thu, 2 Jan 2025 16:48:32 -0300 Subject: [PATCH 10/18] refactor: better naming --- .../PaymentGateways/ServiceProvider.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php index 88026762e4..5c596dcd53 100644 --- a/src/Framework/PaymentGateways/ServiceProvider.php +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -28,14 +28,19 @@ public function register() * @unreleased */ public function boot() + { + $this->registerWebhookEventHandlers(); + } + + private function registerWebhookEventHandlers() { add_action('give_init', function () { $registeredPaymentGatewayIds = give()->gateways->getPaymentGateways(); foreach ($registeredPaymentGatewayIds as $gatewayId) { - $this->registerDonationStatusEventHandlers($gatewayId); - $this->registerSubscriptionStatusEventHandlers($gatewayId); - $this->registerSubscriptionFirstDonationEventHandler($gatewayId); - $this->registerSubscriptionRenewalDonationEventHandler($gatewayId); + $this->addDonationStatusEventHandlers($gatewayId); + $this->addSubscriptionStatusEventHandlers($gatewayId); + $this->addSubscriptionFirstDonationEventHandler($gatewayId); + $this->addSubscriptionRenewalDonationEventHandler($gatewayId); } }, 999); } @@ -43,7 +48,7 @@ public function boot() /** * @unreleased */ - private function registerDonationStatusEventHandlers(string $gatewayId) + private function addDonationStatusEventHandlers(string $gatewayId) { foreach (DonationStatus::values() as $status) { if ($eventHandlerClass = (new GetEventHandlerClassByDonationStatus())($status)) { @@ -62,7 +67,7 @@ private function registerDonationStatusEventHandlers(string $gatewayId) /** * @unreleased */ - private function registerSubscriptionStatusEventHandlers(string $gatewayId) + private function addSubscriptionStatusEventHandlers(string $gatewayId) { foreach (SubscriptionStatus::values() as $status) { if ($eventHandlerClass = (new GetEventHandlerClassBySubscriptionStatus())($status)) { @@ -81,7 +86,7 @@ private function registerSubscriptionStatusEventHandlers(string $gatewayId) /** * @unreleased */ - private function registerSubscriptionFirstDonationEventHandler(string $gatewayId) + private function addSubscriptionFirstDonationEventHandler(string $gatewayId) { Hooks::addAction( sprintf( @@ -95,7 +100,7 @@ private function registerSubscriptionFirstDonationEventHandler(string $gatewayId /** * @unreleased */ - private function registerSubscriptionRenewalDonationEventHandler(string $gatewayId) + private function addSubscriptionRenewalDonationEventHandler(string $gatewayId) { Hooks::addAction( sprintf( From a3bd5c3458f9b2d69990fbff7ae9253a9ee67422 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Thu, 2 Jan 2025 16:58:09 -0300 Subject: [PATCH 11/18] refactor: use sprintf --- .../PaymentGateways/ServiceProvider.php | 22 ++++--------------- .../Webhooks/WebhookEvents.php | 8 +++---- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/Framework/PaymentGateways/ServiceProvider.php b/src/Framework/PaymentGateways/ServiceProvider.php index 5c596dcd53..6bb8fa6bd6 100644 --- a/src/Framework/PaymentGateways/ServiceProvider.php +++ b/src/Framework/PaymentGateways/ServiceProvider.php @@ -53,11 +53,7 @@ private function addDonationStatusEventHandlers(string $gatewayId) foreach (DonationStatus::values() as $status) { if ($eventHandlerClass = (new GetEventHandlerClassByDonationStatus())($status)) { Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_donation_status_%s', - $gatewayId, - $status->getValue() - ), + sprintf('givewp_%s_webhook_event_donation_status_%s', $gatewayId, $status->getValue()), $eventHandlerClass ); } @@ -72,11 +68,7 @@ private function addSubscriptionStatusEventHandlers(string $gatewayId) foreach (SubscriptionStatus::values() as $status) { if ($eventHandlerClass = (new GetEventHandlerClassBySubscriptionStatus())($status)) { Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_subscription_status_%s', - $gatewayId, - $status->getValue() - ), + sprintf('givewp_%s_webhook_event_subscription_status_%s', $gatewayId, $status->getValue()), $eventHandlerClass ); } @@ -89,10 +81,7 @@ private function addSubscriptionStatusEventHandlers(string $gatewayId) private function addSubscriptionFirstDonationEventHandler(string $gatewayId) { Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_subscription_first_donation', - $gatewayId - ), + sprintf('givewp_%s_webhook_event_subscription_first_donation', $gatewayId), SubscriptionFirstDonationCompleted::class ); } @@ -103,10 +92,7 @@ private function addSubscriptionFirstDonationEventHandler(string $gatewayId) private function addSubscriptionRenewalDonationEventHandler(string $gatewayId) { Hooks::addAction( - sprintf( - 'givewp_%s_webhook_event_subscription_renewal_donation', - $gatewayId - ), + sprintf('givewp_%s_webhook_event_subscription_renewal_donation', $gatewayId), SubscriptionRenewalDonationCreated::class ); } diff --git a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php index 344af53ee0..59543c7ffd 100644 --- a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php +++ b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php @@ -36,7 +36,7 @@ public function setDonationStatus( string $message = '', $skipRecurringDonations = false ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_donation_status_{$status->getValue()}"; + $hook = sprintf('givewp_%s_webhook_event_donation_status_%s', $this->gateway::id(), $status->getValue()); $args = [$gatewayTransactionId, $message, $skipRecurringDonations]; $group = $this->getGroup(); @@ -54,7 +54,7 @@ public function setSubscriptionStatus( string $message = '', bool $initialDonationShouldBeCompleted = false ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_status_{$status->getValue()}"; + $hook = sprintf('givewp_%s_webhook_event_subscription_status_%s', $this->gateway::id(), $status->getValue()); $args = [$gatewaySubscriptionId, $message, $initialDonationShouldBeCompleted]; $group = $this->getGroup(); @@ -71,7 +71,7 @@ public function setSubscriptionFirstDonation( string $message = '', bool $setSubscriptionActive = true ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_first_donation"; + $hook = sprintf('givewp_%s_webhook_event_subscription_first_donation', $this->gateway::id()); $args = [$gatewayTransactionId, $message, $setSubscriptionActive]; $group = $this->getGroup(); @@ -88,7 +88,7 @@ public function setSubscriptionRenewalDonation( string $gatewayTransactionId, string $message = '' ): int { - $hook = "givewp_{$this->gateway::id()}_webhook_event_subscription_renewal_donation"; + $hook = sprintf('givewp_%s_webhook_event_subscription_renewal_donation', $this->gateway::id()); $args = [$gatewaySubscriptionId, $gatewayTransactionId, $message]; $group = $this->getGroup(); From de63d93768e1cf1cfe81c7513bafe6646f4861ce Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 13:12:30 -0300 Subject: [PATCH 12/18] tests: add tests for the new classes --- ...tEventHandlerClassByDonationStatusTest.php | 62 +++++++++++ ...ntHandlerClassBySubscriptionStatusTest.php | 50 +++++++++ .../Webhooks/WebhookEventsTest.php | 101 ++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatusTest.php create mode 100644 tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php create mode 100644 tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatusTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatusTest.php new file mode 100644 index 0000000000..126c2eb3e0 --- /dev/null +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassByDonationStatusTest.php @@ -0,0 +1,62 @@ +isAbandoned(): + $this->assertEquals(DonationAbandoned::class, $eventHandlerClass); + break; + case $status->isCancelled(): + $this->assertEquals(DonationCancelled::class, $eventHandlerClass); + break; + case $status->isComplete(): + $this->assertEquals(DonationCompleted::class, $eventHandlerClass); + break; + case $status->isFailed(): + $this->assertEquals(DonationFailed::class, $eventHandlerClass); + break; + case $status->isPending(): + $this->assertEquals(DonationPending::class, $eventHandlerClass); + break; + case $status->isPreapproval(): + $this->assertEquals(DonationPreapproval::class, $eventHandlerClass); + break; + case $status->isProcessing(): + $this->assertEquals(DonationProcessing::class, $eventHandlerClass); + break; + case $status->isRefunded(): + $this->assertEquals(DonationRefunded::class, $eventHandlerClass); + break; + case $status->isRevoked(): + $this->assertEquals(DonationRevoked::class, $eventHandlerClass); + break; + } + } + } + } +} diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php new file mode 100644 index 0000000000..0581b39d7c --- /dev/null +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php @@ -0,0 +1,50 @@ +isActive(): + $this->assertEquals(SubscriptionActive::class, $eventHandlerClass); + break; + case $status->isCancelled(): + $this->assertEquals(SubscriptionCancelled::class, $eventHandlerClass); + break; + case $status->isCompleted(): + $this->assertEquals(SubscriptionCompleted::class, $eventHandlerClass); + break; + case $status->isExpired(): + $this->assertEquals(SubscriptionExpired::class, $eventHandlerClass); + break; + case $status->isFailing(): + $this->assertEquals(SubscriptionFailing::class, $eventHandlerClass); + break; + case $status->isSuspended(): + $this->assertEquals(SubscriptionSuspended::class, $eventHandlerClass); + break; + } + } + } + } +} diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php new file mode 100644 index 0000000000..54573eaa27 --- /dev/null +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php @@ -0,0 +1,101 @@ +deleteAll(); + TestGateway::webhookEvents()->setDonationStatus($status, '123456'); + + $events = TestGateway::webhookEvents()->getAll(); + + $this->assertTrue(count($events) === 1); + $this->assertEquals( + sprintf('givewp_%s_webhook_event_donation_status_%s', TestGateway::id(), $status->getValue()), + current($events)->get_hook() + ); + } + } + + /** + * @unreleased + */ + public function testSetSubscriptionStatus() + { + foreach (SubscriptionStatus::values() as $status) { + // Ignore status that don't have event handler classes + if ( ! (new GetEventHandlerClassBySubscriptionStatus())($status)) { + continue; + } + + TestGateway::webhookEvents()->deleteAll(); + TestGateway::webhookEvents()->setSubscriptionStatus($status, '123456'); + + $events = TestGateway::webhookEvents()->getAll(); + + $this->assertTrue(count($events) === 1); + $this->assertEquals( + sprintf('givewp_%s_webhook_event_subscription_status_%s', TestGateway::id(), $status->getValue()), + current($events)->get_hook() + ); + } + } + + /** + * @unreleased + */ + public function testSetSubscriptionFirstDonation() + { + TestGateway::webhookEvents()->deleteAll(); + TestGateway::webhookEvents()->setSubscriptionFirstDonation('123456'); + + $events = TestGateway::webhookEvents()->getAll(); + + $this->assertTrue(count($events) === 1); + $this->assertEquals( + sprintf('givewp_%s_webhook_event_subscription_first_donation', TestGateway::id()), + current($events)->get_hook() + ); + } + + /** + * @unreleased + */ + public function testSetSubscriptionRenewalDonation() + { + TestGateway::webhookEvents()->deleteAll(); + TestGateway::webhookEvents()->setSubscriptionRenewalDonation('abc', '123456'); + + $events = TestGateway::webhookEvents()->getAll(); + + $this->assertTrue(count($events) === 1); + $this->assertEquals( + sprintf('givewp_%s_webhook_event_subscription_renewal_donation', TestGateway::id()), + current($events)->get_hook() + ); + } +} From c8100d63dced6edb0ee2c94bacab8a65431669b9 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 15:59:30 -0300 Subject: [PATCH 13/18] refactor: deprecated subscription statuses --- .../ValueObjects/SubscriptionStatus.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Subscriptions/ValueObjects/SubscriptionStatus.php b/src/Subscriptions/ValueObjects/SubscriptionStatus.php index 8ead12566d..6563f5cebf 100644 --- a/src/Subscriptions/ValueObjects/SubscriptionStatus.php +++ b/src/Subscriptions/ValueObjects/SubscriptionStatus.php @@ -12,8 +12,8 @@ * @method static SubscriptionStatus ACTIVE() * @method static SubscriptionStatus EXPIRED() * @method static SubscriptionStatus COMPLETED() - * @method static SubscriptionStatus REFUNDED() - * @method static SubscriptionStatus ABANDONED() + * @method static SubscriptionStatus REFUNDED() @deprecated Do not use this. Use SubscriptionStatus::CANCELLED() or SubscriptionStatus::SUSPENDED() instead. + * @method static SubscriptionStatus ABANDONED() @deprecated Do not use this. Use SubscriptionStatus::CANCELLED() instead. * @method static SubscriptionStatus FAILING() * @method static SubscriptionStatus CANCELLED() * @method static SubscriptionStatus SUSPENDED() @@ -22,8 +22,8 @@ * @method bool isActive() * @method bool isExpired() * @method bool isCompleted() - * @method bool isRefunded() - * @method bool isAbandoned() + * @method bool isRefunded() @deprecated Do not use this. Instead, use the CANCELLED or SUSPENDED statuses. + * @method bool isAbandoned() @deprecated Do not use this. Instead, use the CANCELLED status. * @method bool isFailing() * @method bool isCancelled() * @method bool isSuspended() @@ -34,13 +34,21 @@ class SubscriptionStatus extends Enum { const ACTIVE = 'active'; const EXPIRED = 'expired'; const COMPLETED = 'completed'; - const REFUNDED = 'refunded'; const FAILING = 'failing'; const CANCELLED = 'cancelled'; - const ABANDONED = 'abandoned'; const SUSPENDED = 'suspended'; const PAUSED = 'paused'; + /** + * @deprecated Do not use this. Use SubscriptionStatus::CANCELLED or SubscriptionStatus::SUSPENDED instead. + */ + const REFUNDED = 'refunded'; + + /** + * @deprecated Do not use this. Use SubscriptionStatus::CANCELLED instead. + */ + const ABANDONED = 'abandoned'; + /** * @since 3.17.0 Added a new "paused" status * @since 2.24.0 From 9005cc4762b450f742d4c83dc206b42e3b720f6e Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 16:03:01 -0300 Subject: [PATCH 14/18] refactor: instantiate the webhook events object --- .../Webhooks/WebhookEventsTest.php | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php index 54573eaa27..56156e432c 100644 --- a/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php @@ -5,6 +5,7 @@ use Give\Donations\ValueObjects\DonationStatus; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\GetEventHandlerClassByDonationStatus; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\Actions\GetEventHandlerClassBySubscriptionStatus; +use Give\Framework\PaymentGateways\Webhooks\WebhookEvents; use Give\PaymentGateways\Gateways\TestGateway\TestGateway; use Give\Subscriptions\ValueObjects\SubscriptionStatus; use Give\Tests\TestCase; @@ -23,15 +24,15 @@ class WebhookEventsTest extends TestCase public function testSetDonationStatus() { foreach (DonationStatus::values() as $status) { - // Ignore status that don't have event handler classes + // Ignore deprecated status that don't have event handler classes if ( ! (new GetEventHandlerClassByDonationStatus())($status)) { continue; } - TestGateway::webhookEvents()->deleteAll(); - TestGateway::webhookEvents()->setDonationStatus($status, '123456'); - - $events = TestGateway::webhookEvents()->getAll(); + $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $webhookEvents->deleteAll(); + $webhookEvents->setDonationStatus($status, '123456'); + $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( @@ -47,15 +48,15 @@ public function testSetDonationStatus() public function testSetSubscriptionStatus() { foreach (SubscriptionStatus::values() as $status) { - // Ignore status that don't have event handler classes + // Ignore deprecated status that don't have event handler classes if ( ! (new GetEventHandlerClassBySubscriptionStatus())($status)) { continue; } - TestGateway::webhookEvents()->deleteAll(); - TestGateway::webhookEvents()->setSubscriptionStatus($status, '123456'); - - $events = TestGateway::webhookEvents()->getAll(); + $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $webhookEvents->deleteAll(); + $webhookEvents->setSubscriptionStatus($status, '123456'); + $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( @@ -70,10 +71,10 @@ public function testSetSubscriptionStatus() */ public function testSetSubscriptionFirstDonation() { - TestGateway::webhookEvents()->deleteAll(); - TestGateway::webhookEvents()->setSubscriptionFirstDonation('123456'); - - $events = TestGateway::webhookEvents()->getAll(); + $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $webhookEvents->deleteAll(); + $webhookEvents->setSubscriptionFirstDonation('123456'); + $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( @@ -87,10 +88,10 @@ public function testSetSubscriptionFirstDonation() */ public function testSetSubscriptionRenewalDonation() { - TestGateway::webhookEvents()->deleteAll(); - TestGateway::webhookEvents()->setSubscriptionRenewalDonation('abc', '123456'); - - $events = TestGateway::webhookEvents()->getAll(); + $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $webhookEvents->deleteAll(); + $webhookEvents->setSubscriptionRenewalDonation('abc', '123456'); + $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( From b51c389bcf33fc368126b64a9d1b0d8bbb1d6e6e Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 16:03:51 -0300 Subject: [PATCH 15/18] feature: add missing event handler classes for subscription statuses --- ...tEventHandlerClassBySubscriptionStatus.php | 6 ++++ .../Actions/UpdateSubscriptionStatus.php | 7 +++++ .../EventHandlers/SubscriptionPaused.php | 30 +++++++++++++++++++ .../EventHandlers/SubscriptionPending.php | 29 ++++++++++++++++++ ...ntHandlerClassBySubscriptionStatusTest.php | 8 +++++ 5 files changed, 80 insertions(+) create mode 100644 src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPaused.php create mode 100644 src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPending.php diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php index 4fb58d3489..eff69ddbbf 100644 --- a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatus.php @@ -7,6 +7,8 @@ use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCompleted; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionExpired; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFailing; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPaused; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPending; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionSuspended; use Give\Subscriptions\ValueObjects\SubscriptionStatus; @@ -31,6 +33,10 @@ public function __invoke(SubscriptionStatus $status): string return SubscriptionExpired::class; case $status->isFailing(): return SubscriptionFailing::class; + case $status->isPaused(): + return SubscriptionPaused::class; + case $status->isPending(): + return SubscriptionPending::class; case $status->isSuspended(): return SubscriptionSuspended::class; default: diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/UpdateSubscriptionStatus.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/UpdateSubscriptionStatus.php index 23e74e3d2e..07a46edafe 100644 --- a/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/UpdateSubscriptionStatus.php +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/UpdateSubscriptionStatus.php @@ -41,6 +41,7 @@ public function __invoke( /** + * @unreleased Add support for PAUSED and PENDING statuses * @since 3.6.0 */ protected function getMessageFromStatus(SubscriptionStatus $status): string @@ -63,6 +64,12 @@ protected function getMessageFromStatus(SubscriptionStatus $status): string case ($status->isFailing()): $message = __('Subscription Failing.', 'give'); break; + case ($status->isPaused()): + $message = __('Subscription Paused.', 'give'); + break; + case ($status->isPending()): + $message = __('Subscription Pending.', 'give'); + break; case ($status->isSuspended()): $message = __('Subscription Suspended.', 'give'); break; diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPaused.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPaused.php new file mode 100644 index 0000000000..e2ea974ec6 --- /dev/null +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPaused.php @@ -0,0 +1,30 @@ +subscriptions->getByGatewaySubscriptionId($gatewaySubscriptionId); + + if ( ! $subscription || $subscription->status->isPaused()) { + return; + } + + (new UpdateSubscriptionStatus())($subscription, SubscriptionStatus::PAUSED(), $message); + } + +} diff --git a/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPending.php b/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPending.php new file mode 100644 index 0000000000..a13682ea90 --- /dev/null +++ b/src/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPending.php @@ -0,0 +1,29 @@ +subscriptions->getByGatewaySubscriptionId($gatewaySubscriptionId); + + if ( ! $subscription || $subscription->status->isPending()) { + return; + } + + (new UpdateSubscriptionStatus())($subscription, SubscriptionStatus::PENDING(), $message); + } +} diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php index 0581b39d7c..13500c9f31 100644 --- a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/Actions/GetEventHandlerClassBySubscriptionStatusTest.php @@ -8,6 +8,8 @@ use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionCompleted; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionExpired; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionFailing; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPaused; +use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionPending; use Give\Framework\PaymentGateways\Webhooks\EventHandlers\SubscriptionSuspended; use Give\Subscriptions\ValueObjects\SubscriptionStatus; use Give\Tests\TestCase; @@ -40,6 +42,12 @@ public function testShouldReturnSubscriptionStatusEventHandlerClass() case $status->isFailing(): $this->assertEquals(SubscriptionFailing::class, $eventHandlerClass); break; + case $status->isPaused(): + $this->assertEquals(SubscriptionPaused::class, $eventHandlerClass); + break; + case $status->isPending(): + $this->assertEquals(SubscriptionPending::class, $eventHandlerClass); + break; case $status->isSuspended(): $this->assertEquals(SubscriptionSuspended::class, $eventHandlerClass); break; From 1899c09a3f8ae5d11ca8f9b931a5e1bff27babe4 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 16:27:08 -0300 Subject: [PATCH 16/18] refactor: change parameter type --- .../PaymentGateways/PaymentGateway.php | 2 +- .../Webhooks/WebhookEvents.php | 21 +++++++++---------- .../Webhooks/WebhookEventsTest.php | 20 +++++++++++------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Framework/PaymentGateways/PaymentGateway.php b/src/Framework/PaymentGateways/PaymentGateway.php index 4170128fbf..47745aff35 100644 --- a/src/Framework/PaymentGateways/PaymentGateway.php +++ b/src/Framework/PaymentGateways/PaymentGateway.php @@ -65,7 +65,7 @@ public function __construct(SubscriptionModule $subscriptionModule = null) } $this->subscriptionModule = $subscriptionModule; - $this->webhookEvents = new WebhookEvents($this); + $this->webhookEvents = new WebhookEvents($this::id()); } /** diff --git a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php index 59543c7ffd..4b22b4b52e 100644 --- a/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php +++ b/src/Framework/PaymentGateways/Webhooks/WebhookEvents.php @@ -3,7 +3,6 @@ namespace Give\Framework\PaymentGateways\Webhooks; use Give\Donations\ValueObjects\DonationStatus; -use Give\Framework\PaymentGateways\PaymentGateway; use Give\Framework\Support\Facades\ActionScheduler\AsBackgroundJobs; use Give\Subscriptions\ValueObjects\SubscriptionStatus; @@ -13,16 +12,16 @@ class WebhookEvents { /** - * @var PaymentGateway + * @var string */ - protected $gateway; + protected $gatewayId; /** * @unreleased */ - public function __construct(PaymentGateway $gateway) + public function __construct(string $gatewayId) { - $this->gateway = $gateway; + $this->gatewayId = $gatewayId; } /** @@ -36,7 +35,7 @@ public function setDonationStatus( string $message = '', $skipRecurringDonations = false ): int { - $hook = sprintf('givewp_%s_webhook_event_donation_status_%s', $this->gateway::id(), $status->getValue()); + $hook = sprintf('givewp_%s_webhook_event_donation_status_%s', $this->gatewayId, $status->getValue()); $args = [$gatewayTransactionId, $message, $skipRecurringDonations]; $group = $this->getGroup(); @@ -54,7 +53,7 @@ public function setSubscriptionStatus( string $message = '', bool $initialDonationShouldBeCompleted = false ): int { - $hook = sprintf('givewp_%s_webhook_event_subscription_status_%s', $this->gateway::id(), $status->getValue()); + $hook = sprintf('givewp_%s_webhook_event_subscription_status_%s', $this->gatewayId, $status->getValue()); $args = [$gatewaySubscriptionId, $message, $initialDonationShouldBeCompleted]; $group = $this->getGroup(); @@ -71,7 +70,7 @@ public function setSubscriptionFirstDonation( string $message = '', bool $setSubscriptionActive = true ): int { - $hook = sprintf('givewp_%s_webhook_event_subscription_first_donation', $this->gateway::id()); + $hook = sprintf('givewp_%s_webhook_event_subscription_first_donation', $this->gatewayId); $args = [$gatewayTransactionId, $message, $setSubscriptionActive]; $group = $this->getGroup(); @@ -88,7 +87,7 @@ public function setSubscriptionRenewalDonation( string $gatewayTransactionId, string $message = '' ): int { - $hook = sprintf('givewp_%s_webhook_event_subscription_renewal_donation', $this->gateway::id()); + $hook = sprintf('givewp_%s_webhook_event_subscription_renewal_donation', $this->gatewayId); $args = [$gatewaySubscriptionId, $gatewayTransactionId, $message]; $group = $this->getGroup(); @@ -104,7 +103,7 @@ public function setSubscriptionRenewalDonation( */ public function getAll(string $returnFormat = OBJECT): array { - return AsBackgroundJobs::getActionsByGroup($this->getGroup()); + return AsBackgroundJobs::getActionsByGroup($this->getGroup(), $returnFormat); } /** @@ -122,6 +121,6 @@ public function deleteAll(): int */ private function getGroup(): string { - return 'givewp-payment-gateway-' . $this->gateway::id(); + return 'givewp-payment-gateway-' . $this->gatewayId; } } diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php index 56156e432c..283b12e48a 100644 --- a/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/WebhookEventsTest.php @@ -29,14 +29,15 @@ public function testSetDonationStatus() continue; } - $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $gatewayId = TestGateway::id(); + $webhookEvents = new WebhookEvents($gatewayId); $webhookEvents->deleteAll(); $webhookEvents->setDonationStatus($status, '123456'); $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( - sprintf('givewp_%s_webhook_event_donation_status_%s', TestGateway::id(), $status->getValue()), + sprintf('givewp_%s_webhook_event_donation_status_%s', $gatewayId, $status->getValue()), current($events)->get_hook() ); } @@ -53,14 +54,15 @@ public function testSetSubscriptionStatus() continue; } - $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $gatewayId = TestGateway::id(); + $webhookEvents = new WebhookEvents($gatewayId); $webhookEvents->deleteAll(); $webhookEvents->setSubscriptionStatus($status, '123456'); $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( - sprintf('givewp_%s_webhook_event_subscription_status_%s', TestGateway::id(), $status->getValue()), + sprintf('givewp_%s_webhook_event_subscription_status_%s', $gatewayId, $status->getValue()), current($events)->get_hook() ); } @@ -71,14 +73,15 @@ public function testSetSubscriptionStatus() */ public function testSetSubscriptionFirstDonation() { - $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $gatewayId = TestGateway::id(); + $webhookEvents = new WebhookEvents($gatewayId); $webhookEvents->deleteAll(); $webhookEvents->setSubscriptionFirstDonation('123456'); $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( - sprintf('givewp_%s_webhook_event_subscription_first_donation', TestGateway::id()), + sprintf('givewp_%s_webhook_event_subscription_first_donation', $gatewayId), current($events)->get_hook() ); } @@ -88,14 +91,15 @@ public function testSetSubscriptionFirstDonation() */ public function testSetSubscriptionRenewalDonation() { - $webhookEvents = new WebhookEvents(give(TestGateway::class)); + $gatewayId = TestGateway::id(); + $webhookEvents = new WebhookEvents($gatewayId); $webhookEvents->deleteAll(); $webhookEvents->setSubscriptionRenewalDonation('abc', '123456'); $events = $webhookEvents->getAll(); $this->assertTrue(count($events) === 1); $this->assertEquals( - sprintf('givewp_%s_webhook_event_subscription_renewal_donation', TestGateway::id()), + sprintf('givewp_%s_webhook_event_subscription_renewal_donation', $gatewayId), current($events)->get_hook() ); } From 44856df63c8ee480111e37464077f5a912c20539 Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 3 Jan 2025 16:32:53 -0300 Subject: [PATCH 17/18] tests: add new tests for new event handler classes --- .../EventHandlers/SubscriptionPausedTest.php | 37 +++++++++++++++++++ .../EventHandlers/SubscriptionPendingTest.php | 37 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPausedTest.php create mode 100644 tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPendingTest.php diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPausedTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPausedTest.php new file mode 100644 index 0000000000..e149ff0b21 --- /dev/null +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPausedTest.php @@ -0,0 +1,37 @@ +createWithDonation([ + 'status' => SubscriptionStatus::PENDING(), + 'gatewaySubscriptionId' => 'gateway-subscription-id', + ]); + + give(SubscriptionPaused::class)($subscription->gatewaySubscriptionId); + + $subscription = Subscription::find($subscription->id); // re-fetch subscription + $this->assertTrue($subscription->status->isPaused()); + } +} diff --git a/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPendingTest.php b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPendingTest.php new file mode 100644 index 0000000000..d8916b40a3 --- /dev/null +++ b/tests/Unit/Framework/PaymentGateways/Webhooks/EventHandlers/SubscriptionPendingTest.php @@ -0,0 +1,37 @@ +createWithDonation([ + 'status' => SubscriptionStatus::COMPLETED(), + 'gatewaySubscriptionId' => 'gateway-subscription-id', + ]); + + give(SubscriptionPending::class)($subscription->gatewaySubscriptionId); + + $subscription = Subscription::find($subscription->id); // re-fetch subscription + $this->assertTrue($subscription->status->isPending()); + } +} From d7e57e10f303c83f5a065357544f0068d38543ba Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Fri, 10 Jan 2025 18:33:31 -0300 Subject: [PATCH 18/18] chore: update composer.lock --- composer.lock | 463 +++++++++++++++++++++++++------------------------- 1 file changed, 232 insertions(+), 231 deletions(-) diff --git a/composer.lock b/composer.lock index 7f1b489795..06d4543edf 100644 --- a/composer.lock +++ b/composer.lock @@ -327,7 +327,7 @@ "support": { "source": "https://github.com/paypal/Checkout-PHP-SDK/tree/1.0.2" }, - "abandoned": true, + "abandoned": "paypal/paypal-server-sdk", "time": "2021-09-21T20:57:38+00:00" }, { @@ -675,8 +675,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -754,8 +754,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -827,12 +827,12 @@ }, "type": "metapackage", "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + }, "branch-alias": { "dev-main": "1.20-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" } }, "notification-url": "https://packagist.org/downloads/", @@ -878,20 +878,21 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.7.7", + "version": "6.8.0", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "cfbc0028cc23f057f2baf9e73bdc238153c22086" + "reference": "14ffa0e308f5634aa2489568b4b90b24073b6731" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/cfbc0028cc23f057f2baf9e73bdc238153c22086", - "reference": "cfbc0028cc23f057f2baf9e73bdc238153c22086", + "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/14ffa0e308f5634aa2489568b4b90b24073b6731", + "reference": "14ffa0e308f5634aa2489568b4b90b24073b6731", "shasum": "" }, "require": { - "php": ">=5.5.0" + "ext-curl": "*", + "php": ">=7.1.0" }, "type": "library", "autoload": { @@ -938,7 +939,7 @@ ], "support": { "issues": "https://github.com/tecnickcom/TCPDF/issues", - "source": "https://github.com/tecnickcom/TCPDF/tree/6.7.7" + "source": "https://github.com/tecnickcom/TCPDF/tree/6.8.0" }, "funding": [ { @@ -946,24 +947,24 @@ "type": "custom" } ], - "time": "2024-10-26T12:15:02+00:00" + "time": "2024-12-23T13:34:57+00:00" }, { "name": "woocommerce/action-scheduler", - "version": "3.8.2", + "version": "3.9.0", "source": { "type": "git", "url": "https://github.com/woocommerce/action-scheduler.git", - "reference": "2bc91d88fdbc2c07ab899cbb56b983e11e62cf69" + "reference": "90b98e6fe97d455679b1d288f050cad8f6f79771" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/2bc91d88fdbc2c07ab899cbb56b983e11e62cf69", - "reference": "2bc91d88fdbc2c07ab899cbb56b983e11e62cf69", + "url": "https://api.github.com/repos/woocommerce/action-scheduler/zipball/90b98e6fe97d455679b1d288f050cad8f6f79771", + "reference": "90b98e6fe97d455679b1d288f050cad8f6f79771", "shasum": "" }, "require": { - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "phpunit/phpunit": "^7.5", @@ -987,24 +988,24 @@ "homepage": "https://actionscheduler.org/", "support": { "issues": "https://github.com/woocommerce/action-scheduler/issues", - "source": "https://github.com/woocommerce/action-scheduler/tree/3.8.2" + "source": "https://github.com/woocommerce/action-scheduler/tree/3.9.0" }, - "time": "2024-09-12T23:12:58+00:00" + "time": "2024-11-15T00:11:39+00:00" } ], "packages-dev": [ { "name": "composer/ca-bundle", - "version": "1.5.2", + "version": "1.5.5", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137" + "reference": "08c50d5ec4c6ced7d0271d2862dec8c1033283e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/48a792895a2b7a6ee65dd5442c299d7b835b6137", - "reference": "48a792895a2b7a6ee65dd5442c299d7b835b6137", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/08c50d5ec4c6ced7d0271d2862dec8c1033283e6", + "reference": "08c50d5ec4c6ced7d0271d2862dec8c1033283e6", "shasum": "" }, "require": { @@ -1051,7 +1052,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.5.2" + "source": "https://github.com/composer/ca-bundle/tree/1.5.5" }, "funding": [ { @@ -1067,20 +1068,20 @@ "type": "tidelift" } ], - "time": "2024-09-25T07:49:53+00:00" + "time": "2025-01-08T16:17:16+00:00" }, { "name": "composer/class-map-generator", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/composer/class-map-generator.git", - "reference": "98bbf6780e56e0fd2404fe4b82eb665a0f93b783" + "reference": "4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/class-map-generator/zipball/98bbf6780e56e0fd2404fe4b82eb665a0f93b783", - "reference": "98bbf6780e56e0fd2404fe4b82eb665a0f93b783", + "url": "https://api.github.com/repos/composer/class-map-generator/zipball/4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915", + "reference": "4b0a223cf5be7c9ee7e0ef1bc7db42b4a97c9915", "shasum": "" }, "require": { @@ -1089,10 +1090,10 @@ "symfony/finder": "^4.4 || ^5.3 || ^6 || ^7" }, "require-dev": { - "phpstan/phpstan": "^1.6", - "phpstan/phpstan-deprecation-rules": "^1", - "phpstan/phpstan-phpunit": "^1", - "phpstan/phpstan-strict-rules": "^1.1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-deprecation-rules": "^1 || ^2", + "phpstan/phpstan-phpunit": "^1 || ^2", + "phpstan/phpstan-strict-rules": "^1.1 || ^2", "phpunit/phpunit": "^8", "symfony/filesystem": "^5.4 || ^6" }, @@ -1124,7 +1125,7 @@ ], "support": { "issues": "https://github.com/composer/class-map-generator/issues", - "source": "https://github.com/composer/class-map-generator/tree/1.4.0" + "source": "https://github.com/composer/class-map-generator/tree/1.5.0" }, "funding": [ { @@ -1140,20 +1141,20 @@ "type": "tidelift" } ], - "time": "2024-10-03T18:14:00+00:00" + "time": "2024-11-25T16:11:06+00:00" }, { "name": "composer/composer", - "version": "2.8.2", + "version": "2.8.4", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "6e543d03187c882ea1c6ba43add2467754427803" + "reference": "112e37d1dca22b3fdb81cf3524ab4994f47fdb8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/6e543d03187c882ea1c6ba43add2467754427803", - "reference": "6e543d03187c882ea1c6ba43add2467754427803", + "url": "https://api.github.com/repos/composer/composer/zipball/112e37d1dca22b3fdb81cf3524ab4994f47fdb8c", + "reference": "112e37d1dca22b3fdb81cf3524ab4994f47fdb8c", "shasum": "" }, "require": { @@ -1167,7 +1168,7 @@ "justinrainbow/json-schema": "^5.3", "php": "^7.2.5 || ^8.0", "psr/log": "^1.0 || ^2.0 || ^3.0", - "react/promise": "^3.2", + "react/promise": "^2.11 || ^3.2", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.2", "seld/signal-handler": "^2.0", @@ -1197,13 +1198,13 @@ ], "type": "library", "extra": { - "branch-alias": { - "dev-main": "2.8-dev" - }, "phpstan": { "includes": [ "phpstan/rules.neon" ] + }, + "branch-alias": { + "dev-main": "2.8-dev" } }, "autoload": { @@ -1238,7 +1239,7 @@ "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/composer/issues", "security": "https://github.com/composer/composer/security/policy", - "source": "https://github.com/composer/composer/tree/2.8.2" + "source": "https://github.com/composer/composer/tree/2.8.4" }, "funding": [ { @@ -1254,7 +1255,7 @@ "type": "tidelift" } ], - "time": "2024-10-29T15:12:11+00:00" + "time": "2024-12-11T10:57:47+00:00" }, { "name": "composer/metadata-minifier", @@ -1327,16 +1328,16 @@ }, { "name": "composer/pcre", - "version": "2.3.1", + "version": "2.3.2", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "26859a860a7f140fc08422c3cc14ad9c2a287d79" + "reference": "ebb81df8f52b40172d14062ae96a06939d80a069" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/26859a860a7f140fc08422c3cc14ad9c2a287d79", - "reference": "26859a860a7f140fc08422c3cc14ad9c2a287d79", + "url": "https://api.github.com/repos/composer/pcre/zipball/ebb81df8f52b40172d14062ae96a06939d80a069", + "reference": "ebb81df8f52b40172d14062ae96a06939d80a069", "shasum": "" }, "require": { @@ -1346,19 +1347,19 @@ "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.10", - "phpstan/phpstan-strict-rules": "^1.1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", "phpunit/phpunit": "^8 || ^9" }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "2.x-dev" } }, "autoload": { @@ -1386,7 +1387,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/2.3.1" + "source": "https://github.com/composer/pcre/tree/2.3.2" }, "funding": [ { @@ -1402,7 +1403,7 @@ "type": "tidelift" } ], - "time": "2024-08-27T12:02:26+00:00" + "time": "2024-11-12T16:24:47+00:00" }, { "name": "composer/semver", @@ -2250,16 +2251,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -2298,7 +2299,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -2306,7 +2307,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "nb/oxymel", @@ -2355,16 +2356,16 @@ }, { "name": "php-stubs/wordpress-stubs", - "version": "v6.6.2", + "version": "v6.7.1", "source": { "type": "git", "url": "https://github.com/php-stubs/wordpress-stubs.git", - "reference": "f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc" + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc", - "reference": "f50fd7ed45894d036e4fef9ab7e5bbbaff6a30cc", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/83448e918bf06d1ed3d67ceb6a985fc266a02fd1", + "reference": "83448e918bf06d1ed3d67ceb6a985fc266a02fd1", "shasum": "" }, "require-dev": { @@ -2373,9 +2374,9 @@ "php": "^7.4 || ^8.0", "php-stubs/generator": "^0.8.3", "phpdocumentor/reflection-docblock": "^5.4.1", - "phpstan/phpstan": "^1.10.49", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^9.5", - "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" }, "suggest": { @@ -2397,22 +2398,22 @@ ], "support": { "issues": "https://github.com/php-stubs/wordpress-stubs/issues", - "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.6.2" + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.1" }, - "time": "2024-09-30T07:10:48+00:00" + "time": "2024-11-24T03:57:09+00:00" }, { "name": "php-stubs/wp-cli-stubs", - "version": "v2.10.0", + "version": "v2.11.0", "source": { "type": "git", "url": "https://github.com/php-stubs/wp-cli-stubs.git", - "reference": "fbd7ff47393c9478e0f557d0b4caadaed20986fb" + "reference": "f27ff9e8e29d7962cb070e58de70dfaf63183007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-stubs/wp-cli-stubs/zipball/fbd7ff47393c9478e0f557d0b4caadaed20986fb", - "reference": "fbd7ff47393c9478e0f557d0b4caadaed20986fb", + "url": "https://api.github.com/repos/php-stubs/wp-cli-stubs/zipball/f27ff9e8e29d7962cb070e58de70dfaf63183007", + "reference": "f27ff9e8e29d7962cb070e58de70dfaf63183007", "shasum": "" }, "require": { @@ -2441,9 +2442,9 @@ ], "support": { "issues": "https://github.com/php-stubs/wp-cli-stubs/issues", - "source": "https://github.com/php-stubs/wp-cli-stubs/tree/v2.10.0" + "source": "https://github.com/php-stubs/wp-cli-stubs/tree/v2.11.0" }, - "time": "2024-02-09T02:10:10+00:00" + "time": "2024-11-25T10:09:13+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -4375,16 +4376,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", "shasum": "" }, "require": { @@ -4451,20 +4452,20 @@ "type": "open_collective" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2024-12-11T16:04:26+00:00" }, { "name": "symfony/console", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "108d436c2af470858bdaba3257baab3a74172017" + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/108d436c2af470858bdaba3257baab3a74172017", - "reference": "108d436c2af470858bdaba3257baab3a74172017", + "url": "https://api.github.com/repos/symfony/console/zipball/c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", + "reference": "c4ba980ca61a9eb18ee6bcc73f28e475852bb1ed", "shasum": "" }, "require": { @@ -4534,7 +4535,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.45" + "source": "https://github.com/symfony/console/tree/v5.4.47" }, "funding": [ { @@ -4550,20 +4551,20 @@ "type": "tidelift" } ], - "time": "2024-10-08T07:27:17+00:00" + "time": "2024-11-06T11:30:55+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v2.5.3", + "version": "v2.5.4", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", "shasum": "" }, "require": { @@ -4571,12 +4572,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4601,7 +4602,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" }, "funding": [ { @@ -4617,7 +4618,7 @@ "type": "tidelift" } ], - "time": "2023-01-24T14:02:46+00:00" + "time": "2024-09-25T14:11:13+00:00" }, { "name": "symfony/filesystem", @@ -4772,8 +4773,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4850,8 +4851,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4928,8 +4929,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -5004,8 +5005,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -5084,8 +5085,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -5142,16 +5143,16 @@ }, { "name": "symfony/process", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4" + "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4", - "reference": "95f3f19d0f8f06e4253c66a0828ddb69f8b8ede4", + "url": "https://api.github.com/repos/symfony/process/zipball/5d1662fb32ebc94f17ddb8d635454a776066733d", + "reference": "5d1662fb32ebc94f17ddb8d635454a776066733d", "shasum": "" }, "require": { @@ -5184,7 +5185,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.45" + "source": "https://github.com/symfony/process/tree/v5.4.47" }, "funding": [ { @@ -5200,7 +5201,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-06T11:36:42+00:00" }, { "name": "symfony/service-contracts", @@ -5265,16 +5266,16 @@ }, { "name": "symfony/string", - "version": "v5.4.45", + "version": "v5.4.47", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7f6807add88b1e2635f3c6de5e1ace631ed7cad2" + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7f6807add88b1e2635f3c6de5e1ace631ed7cad2", - "reference": "7f6807add88b1e2635f3c6de5e1ace631ed7cad2", + "url": "https://api.github.com/repos/symfony/string/zipball/136ca7d72f72b599f2631aca474a4f8e26719799", + "reference": "136ca7d72f72b599f2631aca474a4f8e26719799", "shasum": "" }, "require": { @@ -5331,7 +5332,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.45" + "source": "https://github.com/symfony/string/tree/v5.4.47" }, "funding": [ { @@ -5347,7 +5348,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:11:13+00:00" + "time": "2024-11-10T20:33:58+00:00" }, { "name": "symfony/yaml", @@ -5484,7 +5485,7 @@ "source": { "type": "git", "url": "https://github.com/wordpress/wordpress-develop.git", - "reference": "695476ea5e51d1c92f389ac236b138ceeaee8a99" + "reference": "1dd2f28680c98373468adb53aff18df00586c559" }, "require": { "ext-json": "*", @@ -5533,7 +5534,7 @@ "support": { "issues": "https://core.trac.wordpress.org/" }, - "time": "2024-10-29T15:36:56+00:00" + "time": "2025-01-10T18:12:08+00:00" }, { "name": "wp-cli/cache-command", @@ -5558,9 +5559,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "cache", @@ -5581,7 +5579,10 @@ "transient set", "transient type", "transient list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5633,14 +5634,14 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "core verify-checksums", "plugin verify-checksums" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5693,9 +5694,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "config", @@ -5709,7 +5707,10 @@ "config path", "config set", "config shuffle-salts" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5770,9 +5771,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "core", @@ -5785,7 +5783,10 @@ "core update", "core update-db", "core version" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5839,9 +5840,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "cron", @@ -5854,7 +5852,10 @@ "cron schedule", "cron schedule list", "cron event unschedule" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5906,9 +5907,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "db", @@ -5928,7 +5926,10 @@ "db tables", "db size", "db columns" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -5980,9 +5981,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "embed", @@ -5996,7 +5994,10 @@ "embed cache clear", "embed cache find", "embed cache trigger" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6051,9 +6052,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "comment", @@ -6232,7 +6230,10 @@ "user term set", "user unspam", "user update" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6283,14 +6284,14 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "eval", "eval-file" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6347,13 +6348,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "export" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6409,9 +6410,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "plugin", @@ -6446,7 +6444,10 @@ "theme status", "theme update", "theme mod list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6510,9 +6511,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "i18n", @@ -6521,7 +6519,10 @@ "i18n make-mo", "i18n make-php", "i18n update-po" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6574,13 +6575,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "import" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6634,9 +6635,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "language", @@ -6660,7 +6658,10 @@ "language theme uninstall", "language theme update", "site switch-language" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6711,9 +6712,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "maintenance-mode", @@ -6721,7 +6719,10 @@ "maintenance-mode deactivate", "maintenance-mode status", "maintenance-mode is-active" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6774,16 +6775,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "media", "media import", "media regenerate", "media image-size" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -6888,9 +6889,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "package", @@ -6899,7 +6897,10 @@ "package list", "package update", "package uninstall" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7014,16 +7015,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "rewrite", "rewrite flush", "rewrite list", "rewrite structure" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7074,9 +7075,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "role", @@ -7089,7 +7087,10 @@ "cap add", "cap list", "cap remove" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7141,9 +7142,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "scaffold", @@ -7155,7 +7153,10 @@ "scaffold post-type", "scaffold taxonomy", "scaffold theme-tests" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7209,13 +7210,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "search-replace" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7267,13 +7268,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "server" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7324,13 +7325,13 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "shell" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7382,16 +7383,16 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "super-admin", "super-admin add", "super-admin list", "super-admin remove" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7443,9 +7444,6 @@ }, "type": "wp-cli-package", "extra": { - "branch-alias": { - "dev-main": "2.x-dev" - }, "bundled": true, "commands": [ "widget", @@ -7458,7 +7456,10 @@ "widget update", "sidebar", "sidebar list" - ] + ], + "branch-alias": { + "dev-main": "2.x-dev" + } }, "autoload": { "files": [ @@ -7747,16 +7748,16 @@ }, { "name": "yoast/phpunit-polyfills", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/Yoast/PHPUnit-Polyfills.git", - "reference": "e9c8413de4c8ae03d2923a44f17d0d7dad1b96be" + "reference": "0b31ce834facf03b8b44b6587e65b3cf1d7cfb94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/e9c8413de4c8ae03d2923a44f17d0d7dad1b96be", - "reference": "e9c8413de4c8ae03d2923a44f17d0d7dad1b96be", + "url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/0b31ce834facf03b8b44b6587e65b3cf1d7cfb94", + "reference": "0b31ce834facf03b8b44b6587e65b3cf1d7cfb94", "shasum": "" }, "require": { @@ -7806,7 +7807,7 @@ "security": "https://github.com/Yoast/PHPUnit-Polyfills/security/policy", "source": "https://github.com/Yoast/PHPUnit-Polyfills" }, - "time": "2024-09-06T22:03:10+00:00" + "time": "2025-01-08T16:58:34+00:00" } ], "aliases": [], @@ -7823,5 +7824,5 @@ "platform-overrides": { "php": "7.2.24" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" }