Prevent insurance applications from being flagged as paid more than once #801

This commit is contained in:
Ramon Gutierrez 2024-05-31 06:50:34 +08:00
parent ad841a7e25
commit 952122a39e

View file

@ -58,17 +58,20 @@ class GatewayTransactionListener
'gateway_transaction' => $gt_obj,
]);
if (!empty($obj)) {
// make sure the object exists and has not been processed yet
if (!empty($obj) && $obj->getStatus === InsuranceApplicationStatus::CREATED) {
// mark as paid
$obj->setDatePay(new DateTime());
$obj->setStatus(InsuranceApplicationStatus::PAID);
$this->em->flush();
}
// flag on api as paid
$result = $this->ic->tagApplicationPaid($obj->getExtTransactionId());
if (!$result['success'] || $result['response']['transaction_code'] !== 'GR004') {
error_log("INSURANCE MARK AS PAID FAILED FOR " . $obj->getID() . ": " . $result['error']['message']);
// flag on api as paid
$result = $this->ic->tagApplicationPaid($obj->getExtTransactionId());
// something went wrong with insurance api
if (!$result['success'] || $result['response']['transaction_code'] !== 'GR004') {
error_log("INSURANCE MARK AS PAID FAILED FOR " . $obj->getID() . ": " . $result['error']['message']);
}
}
}
}