Skip to content

Commit

Permalink
A fixed so that non handleled responses does not end in declined.
Browse files Browse the repository at this point in the history
  • Loading branch information
addgod committed May 16, 2023
1 parent 3b555b2 commit e26e076
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Http/Controllers/OmnipayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,19 @@ public function purchase(Transaction $transaction)
$transaction->status = Transaction::STATUS_PURCHASE;
$transaction->save();

$transaction->logs()->create([
'payload' => [
'action' => 'Complete Authorization',
'message' => $response->getMessage(),
'data' => $response->getData(),
],
]);

// We assume this means API driven
if ($response->isTransparentRedirect()) {
if ($response->isSuccessful()) {
$transaction->status = Transaction::STATUS_PURCHASE_COMPLETE;
$transaction->save();
} elseif ($response->isCancelled()) {
$transaction->status = Transaction::STATUS_VOID;
$transaction->save();
} else {
$transaction->status = Transaction::STATUS_DECLINED;
$transaction->save();
}

return response()->json($response->getData());
Expand Down Expand Up @@ -146,18 +148,20 @@ public function authorize(Transaction $transaction)

$transaction->status = Transaction::STATUS_AUTHORIZE;
$transaction->save();

$transaction->logs()->create([
'payload' => [
'action' => 'Complete Authorization',
'message' => $response->getMessage(),
'data' => $response->getData(),
],
]);

// We assume this means API driven
if ($response->isTransparentRedirect()) {
if ($response->isSuccessful()) {
$transaction->status = Transaction::STATUS_AUTHORIZE_COMPLETE;
$transaction->save();
} elseif ($response->isCancelled()) {
$transaction->status = Transaction::STATUS_VOID;
$transaction->save();
} else {
$transaction->status = Transaction::STATUS_DECLINED;
$transaction->save();
}

return response()->json($response->getData());
Expand Down

0 comments on commit e26e076

Please sign in to comment.