Add square webhook tests

This commit is contained in:
David Bomba 2023-08-20 19:59:59 +10:00
parent fdd9501af6
commit 6689a22f38

View File

@ -283,7 +283,7 @@ class SquarePaymentDriver extends BaseDriver
return false; return false;
} }
public function checkWebhooks(): bool public function checkWebhooks(): mixed
{ {
$this->init(); $this->init();
@ -295,7 +295,7 @@ class SquarePaymentDriver extends BaseDriver
foreach($api_response->getResult()->getSubscriptions() as $subscription) foreach($api_response->getResult()->getSubscriptions() as $subscription)
{ {
if($subscription->getName() == 'Invoice_Ninja_Webhook_Subscription') if($subscription->getName() == 'Invoice_Ninja_Webhook_Subscription')
return true; return $subscription->getId();
} }
} else { } else {
@ -394,8 +394,12 @@ class SquarePaymentDriver extends BaseDriver
$body->setEventType('payment.created'); $body->setEventType('payment.created');
//getsubscriptionid here //getsubscriptionid here
$subscription_id = $this->checkWebhooks();
$api_response = $this->square->getWebhookSubscriptionsApi()->testWebhookSubscription('subscription_id0', $body); if(!$subscription_id)
return nlog('No Subscription Found');
$api_response = $this->square->getWebhookSubscriptionsApi()->testWebhookSubscription($subscription_id, $body);
if ($api_response->isSuccess()) { if ($api_response->isSuccess()) {
$result = $api_response->getResult(); $result = $api_response->getResult();