From e2bd1b3f6f61cb77b9b27dcea7f2e3c19154d63c Mon Sep 17 00:00:00 2001 From: Glauber Silva Date: Sat, 31 Aug 2024 11:02:49 -0300 Subject: [PATCH] refactor: change OffSiteGatewayWebhookNotification properties --- .../OffSiteGatewayWebhookNotification.php | 16 +++++++++++----- ...OffSiteGatewaysWebhookNotificationHandler.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/OffSiteGateway/DataTransferObjects/OffSiteGatewayWebhookNotification.php b/src/OffSiteGateway/DataTransferObjects/OffSiteGatewayWebhookNotification.php index 001e6e3..4410f61 100644 --- a/src/OffSiteGateway/DataTransferObjects/OffSiteGatewayWebhookNotification.php +++ b/src/OffSiteGateway/DataTransferObjects/OffSiteGatewayWebhookNotification.php @@ -10,28 +10,34 @@ class OffSiteGatewayWebhookNotification /** * @var string */ - public $notificationType; + public $gatewayNotificationType; /** * @var string */ - public $paymentStatus; + public $gatewayPaymentStatus; /** * @var string */ - public $merchantPaymentId; + public $gatewayPaymentId; /** * @var string */ - public $gatewayPaymentId; + public $merchantPaymentId; + /** + * @unreleased + */ public static function fromRequest(array $request): OffSiteGatewayWebhookNotification { $self = new self(); - $self->notificationType = $request['notification_type'] ?? ''; + $self->gatewayNotificationType = $request['notification_type'] ?? ''; + $self->gatewayPaymentStatus = $request['payment_status'] ?? ''; + $self->gatewayPaymentId = $request['payment_id'] ?? ''; + $self->merchantPaymentId = $request['merchant_payment_id'] ?? ''; return $self; } diff --git a/src/OffSiteGateway/Webhooks/OffSiteGatewaysWebhookNotificationHandler.php b/src/OffSiteGateway/Webhooks/OffSiteGatewaysWebhookNotificationHandler.php index 4e78c44..a6d417c 100644 --- a/src/OffSiteGateway/Webhooks/OffSiteGatewaysWebhookNotificationHandler.php +++ b/src/OffSiteGateway/Webhooks/OffSiteGatewaysWebhookNotificationHandler.php @@ -29,7 +29,7 @@ public function __invoke(OffSiteGatewayWebhookNotification $webhookNotification) return; } - switch (strtolower($webhookNotification->paymentStatus)) { + switch (strtolower($webhookNotification->gatewayPaymentStatus)) { case 'complete': AsBackgroundJobs::enqueueAsyncAction( 'givewp_off-site_gateway_sample_event_donation_completed',