Simplify Logic

This commit is contained in:
cnohall 2024-09-13 13:03:46 +09:00
parent 56e327a238
commit eba06f2dfd

View File

@ -124,22 +124,13 @@ class BlockonomicsPaymentDriver extends BaseDriver
throw new PaymentFailed('Secret does not match'); throw new PaymentFailed('Secret does not match');
return; return;
} }
// Only accept confirmed transactions // Only accept confirmed transactions
if ($status != 2) { if ($status != 2) {
throw new PaymentFailed('Transaction not confirmed'); throw new PaymentFailed('Transaction not confirmed');
} }
switch ($status) { $statusId = Payment::STATUS_COMPLETED;
case 0:
$statusId = Payment::STATUS_PENDING;
break;
case 1:
$statusId = Payment::STATUS_PENDING;
break;
case 2:
$statusId = Payment::STATUS_COMPLETED;
break;
}
// Save the updated payment status // Save the updated payment status
if ($payment->status_id != $statusId) { if ($payment->status_id != $statusId) {
@ -148,7 +139,7 @@ class BlockonomicsPaymentDriver extends BaseDriver
} }
header('HTTP/1.1 200 OK'); header('HTTP/1.1 200 OK');
echo 'SUCCESS'; echo "Success";
return; return;
} }