diff --git a/api/wallet_transaction.php b/api/wallet_transaction.php index afed15a..8690ba7 100644 --- a/api/wallet_transaction.php +++ b/api/wallet_transaction.php @@ -1,9 +1,9 @@ false, 'error' => 'Unauthorized']); exit; } @@ -13,7 +13,6 @@ $action = $_POST['action'] ?? ''; $amount = (float)($_POST['amount'] ?? 0); if ($amount <= 0) { - header('Content-Type: application/json'); echo json_encode(['success' => false, 'error' => 'Please enter a valid amount greater than zero.']); exit; } @@ -55,7 +54,8 @@ try { } } catch (Exception $e) { - db()->rollBack(); - header('Content-Type: application/json'); + if (db()->inTransaction()) { + db()->rollBack(); + } echo json_encode(['success' => false, 'error' => $e->getMessage()]); } \ No newline at end of file