Attempt to re-enable paymongo webhook if found disabled #801
This commit is contained in:
parent
08084f682c
commit
c4b0513386
2 changed files with 19 additions and 2 deletions
|
|
@ -55,9 +55,21 @@ class ProcessLatePaymongoTransactionsCommand extends Command
|
|||
|
||||
return 0;
|
||||
} else {
|
||||
$output->writeln('<comment>Webhook is disabled! Logging event and proceeding...</comment>');
|
||||
$output->writeln('<comment>Webhook is disabled! Logging event and attempting to re-enable...</comment>');
|
||||
|
||||
$this->paymongo->log('WEBHOOK', "[]", json_encode($webhook['response'], JSON_PRETTY_PRINT), 'webhook');
|
||||
// attempt re-enabling of webhook
|
||||
$result = $this->paymongo->enableWebhook($this->webhook_id);
|
||||
if ($result['success'] && $result['response']['data']['attributes']['status'] ?? null === 'enabled') {
|
||||
$output->writeln('<info>Webhook ' . $this->webhook_id . ' re-enabled!</info>');
|
||||
|
||||
// log event
|
||||
$this->paymongo->log('WEBHOOK RE-ENABLED', "[]", json_encode($result['response'], JSON_PRETTY_PRINT), 'webhook');
|
||||
} else {
|
||||
$output->writeln('<comment>Webhook ' . $this->webhook_id . ' could not be re-enabled.</comment>');
|
||||
|
||||
// log event
|
||||
$this->paymongo->log('WEBHOOK FAILURE', "[]", json_encode($result['response'], JSON_PRETTY_PRINT), 'webhook');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,11 @@ class PayMongoConnector
|
|||
return $this->doRequest('/v1/webhooks/'. $id, 'GET');
|
||||
}
|
||||
|
||||
public function enableWebhook($id)
|
||||
{
|
||||
return $this->doRequest('/v1/webhooks/' . $id . '/enable', 'POST');
|
||||
}
|
||||
|
||||
protected function generateHash()
|
||||
{
|
||||
return base64_encode($this->secret_key);
|
||||
|
|
|
|||
Loading…
Reference in a new issue