Add entity null check for paymongo webhooks #761
This commit is contained in:
parent
ee021da453
commit
a002da6aad
2 changed files with 7 additions and 5 deletions
|
|
@ -63,9 +63,11 @@ class PayMongoController extends Controller
|
||||||
$metadata = $event['attributes']['metadata'];
|
$metadata = $event['attributes']['metadata'];
|
||||||
$obj = $this->getTransaction($metadata['transaction_id']);
|
$obj = $this->getTransaction($metadata['transaction_id']);
|
||||||
|
|
||||||
// mark as paid
|
if (!empty($obj)) {
|
||||||
$obj->setStatus(TransactionStatus::PAID);
|
// mark as paid
|
||||||
$this->em->flush();
|
$obj->setStatus(TransactionStatus::PAID);
|
||||||
|
$this->em->flush();
|
||||||
|
}
|
||||||
|
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class GatewayTransactionListener
|
||||||
'gateway_transaction' => $gt_obj,
|
'gateway_transaction' => $gt_obj,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($obj) {
|
if (!empty($obj)) {
|
||||||
// mark as paid
|
// mark as paid
|
||||||
$obj->setDatePay(new DateTime());
|
$obj->setDatePay(new DateTime());
|
||||||
$obj->setStatus(InsuranceApplicationStatus::PAID);
|
$obj->setStatus(InsuranceApplicationStatus::PAID);
|
||||||
|
|
@ -67,7 +67,7 @@ class GatewayTransactionListener
|
||||||
|
|
||||||
// flag on api as paid
|
// flag on api as paid
|
||||||
$result = $this->ic->tagApplicationPaid($obj->getID());
|
$result = $this->ic->tagApplicationPaid($obj->getID());
|
||||||
if (!$result['success']) {
|
if (!$result['success'] || $result['response']['transaction_code'] !== 'GR004') {
|
||||||
error_log("INSURANCE MARK AS PAID FAILED FOR " . $obj->getID() . ": " . $result['error']['message']);
|
error_log("INSURANCE MARK AS PAID FAILED FOR " . $obj->getID() . ": " . $result['error']['message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue