From 6aa737a3c737c3e49bcffdf373d11917515f1355 Mon Sep 17 00:00:00 2001 From: Jesper Kold-Hansen Date: Tue, 4 Jun 2024 10:15:50 +0200 Subject: [PATCH] fix: Adding a catured state. It is now possible to go to a captured state through the notification endpoint. --- src/Http/Controllers/OmnipayController.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Http/Controllers/OmnipayController.php b/src/Http/Controllers/OmnipayController.php index a67ea4d..0dcaf03 100644 --- a/src/Http/Controllers/OmnipayController.php +++ b/src/Http/Controllers/OmnipayController.php @@ -95,18 +95,15 @@ public function completePurchase(Transaction $transaction) if ($response->isTransparentRedirect()) { if ($response->isSuccessful()) { $transaction->status = Transaction::STATUS_PURCHASE_COMPLETE; - $transaction->save(); } elseif ($response->isCancelled()) { $transaction->status = Transaction::STATUS_VOID; - $transaction->save(); } elseif ($response->isPending()) { $transaction->status = Transaction::STATUS_PURCHASE; - $transaction->save(); } else { $transaction->status = Transaction::STATUS_DECLINED; - $transaction->save(); } - + $transaction->save(); + return response()->json($response->getData()); } if ($response->isSuccessful()) { @@ -213,18 +210,16 @@ public function completeAuthorize(Transaction $transaction) if ($response->isTransparentRedirect()) { if ($response->isSuccessful()) { $transaction->status = Transaction::STATUS_AUTHORIZE_COMPLETE; - $transaction->save(); } elseif ($response->isCancelled()) { $transaction->status = Transaction::STATUS_VOID; - $transaction->save(); } elseif ($response->isPending()) { $transaction->status = Transaction::STATUS_AUTHORIZE; - $transaction->save(); } else { $transaction->status = Transaction::STATUS_DECLINED; - $transaction->save(); } + $transaction->save(); + return response()->json($response->getData()); } if ($response->isSuccessful()) { @@ -439,13 +434,12 @@ public function notify(Transaction $transaction = null) } } elseif ($response->isCancelled()) { $transaction->status = Transaction::STATUS_VOID; - $transaction->save(); - } elseif ($response->isRefunded()) { + } elseif (method_exists($response, 'isCaptured') && $response->isCaptured()) { + $transaction->status = Transaction::STATUS_CAPTURE; + } elseif (method_exists($response, 'isRefunded') && $response->isRefunded()) { $transaction->status = Transaction::STATUS_REFUND_FULLY; - $transaction->save(); } else { $transaction->status = Transaction::STATUS_DECLINED; - $transaction->save(); } $transaction->save();