diff --git a/src/Controller/PayMongoController.php b/src/Controller/PayMongoController.php index 167752e4..245cedfa 100644 --- a/src/Controller/PayMongoController.php +++ b/src/Controller/PayMongoController.php @@ -63,9 +63,11 @@ class PayMongoController extends Controller $metadata = $event['attributes']['metadata']; $obj = $this->getTransaction($metadata['transaction_id']); - // mark as paid - $obj->setStatus(TransactionStatus::PAID); - $this->em->flush(); + if (!empty($obj)) { + // mark as paid + $obj->setStatus(TransactionStatus::PAID); + $this->em->flush(); + } return $this->json([ 'success' => true, diff --git a/src/EntityListener/GatewayTransactionListener.php b/src/EntityListener/GatewayTransactionListener.php index 1181a12b..745fc5f9 100644 --- a/src/EntityListener/GatewayTransactionListener.php +++ b/src/EntityListener/GatewayTransactionListener.php @@ -58,7 +58,7 @@ class GatewayTransactionListener 'gateway_transaction' => $gt_obj, ]); - if ($obj) { + if (!empty($obj)) { // mark as paid $obj->setDatePay(new DateTime()); $obj->setStatus(InsuranceApplicationStatus::PAID); @@ -67,7 +67,7 @@ class GatewayTransactionListener // flag on api as paid $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']); } }