mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add square webhook tests
This commit is contained in:
parent
fdd9501af6
commit
6689a22f38
@ -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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user