From fdd9501af69b52d14a5dc3bd2ceb9d6a94a7d39f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 20 Aug 2023 19:20:12 +1000 Subject: [PATCH] Add square webhook tests --- app/PaymentDrivers/Square/SquareWebhook.php | 2 +- app/PaymentDrivers/SquarePaymentDriver.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Square/SquareWebhook.php b/app/PaymentDrivers/Square/SquareWebhook.php index 8e99e160e10a..6f5062282bd1 100644 --- a/app/PaymentDrivers/Square/SquareWebhook.php +++ b/app/PaymentDrivers/Square/SquareWebhook.php @@ -272,7 +272,7 @@ class SquareWebhook implements ShouldQueue } else{ - nlog("Square Webhook - Payment not found: $payment_reference"); + nlog("Square Webhook - Payment not found: {$payment_reference}"); nlog($apiResponse->getErrors()); return null; } diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index 3ff5e09121a3..1046eee415c6 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -386,6 +386,27 @@ class SquarePaymentDriver extends BaseDriver } + public function testWebhook() + { + $this->init(); + + $body = new \Square\Models\TestWebhookSubscriptionRequest(); + $body->setEventType('payment.created'); + + //getsubscriptionid here + + $api_response = $this->square->getWebhookSubscriptionsApi()->testWebhookSubscription('subscription_id0', $body); + + if ($api_response->isSuccess()) { + $result = $api_response->getResult(); + nlog($result); + } else { + $errors = $api_response->getErrors(); + nlog($errors); + } + + } + public function convertAmount($amount) { $precision = $this->client->currency()->precision;