From 851e60d43b47018146401e3fe6291f8023fcd3f2 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Wed, 1 Jan 2020 16:41:06 +0300 Subject: [PATCH] updated omnipay --- app/Traits/Omnipay.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/Traits/Omnipay.php b/app/Traits/Omnipay.php index 3b28d2e2f..c4feb1b9d 100644 --- a/app/Traits/Omnipay.php +++ b/app/Traits/Omnipay.php @@ -38,15 +38,24 @@ trait Omnipay if ($response->isSuccessful()) { $this->setReference($invoice, $response->getTransactionReference()); - $response = $this->gateway->capture([ - 'amount' => $invoice->amount, - 'currency' => $invoice->currency_code, - 'transactionId' => $this->getReference($invoice), - ])->send(); + $options['transactionReference'] = $response->getTransactionReference(); + + $response = $this->gateway->capture($options)->send(); return $this->finish($invoice, $request); } + if ($response->isRedirect()) { + $this->setReference($invoice, $response->getTransactionReference()); + + return response()->json([ + 'error' => false, + 'redirect' => $response->getRedirectUrl(), + 'success' => false, + 'data' => $response->getRedirectData(), + ]); + } + return $this->failure($invoice, $response); } @@ -187,4 +196,15 @@ trait Omnipay return $this->factory; } + + public function setCardFirstLastName(&$request) + { + $contact = explode(" ", $request['cardName']); + + $last_name = array_pop($contact); + $first_name = implode(" ", $contact); + + $request['cardFirstName'] = $first_name; + $request['cardLastName'] = $last_name; + } }