diff --git a/app/Http/Livewire/CreditsTable.php b/app/Http/Livewire/CreditsTable.php index 9d9a8c3adce6..443b46b1efbc 100644 --- a/app/Http/Livewire/CreditsTable.php +++ b/app/Http/Livewire/CreditsTable.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire; use App\Models\Credit; -use App\Traits\WithSorting; +use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; diff --git a/app/Http/Livewire/PaymentMethodsTable.php b/app/Http/Livewire/PaymentMethodsTable.php index 81d7f3d79619..8b0c798ac256 100644 --- a/app/Http/Livewire/PaymentMethodsTable.php +++ b/app/Http/Livewire/PaymentMethodsTable.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire; use App\Models\ClientGatewayToken; -use App\Traits\WithSorting; +use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; diff --git a/app/Http/Livewire/PaymentsTable.php b/app/Http/Livewire/PaymentsTable.php index 8875cb4db08e..78cba62e7ad5 100644 --- a/app/Http/Livewire/PaymentsTable.php +++ b/app/Http/Livewire/PaymentsTable.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire; use App\Models\Payment; -use App\Traits\WithSorting; +use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; diff --git a/app/Http/Livewire/QuotesTable.php b/app/Http/Livewire/QuotesTable.php index 6dcc3214513d..bb350ddf714a 100644 --- a/app/Http/Livewire/QuotesTable.php +++ b/app/Http/Livewire/QuotesTable.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire; use App\Models\Quote; -use App\Traits\WithSorting; +use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; diff --git a/app/Http/Livewire/RecurringInvoicesTable.php b/app/Http/Livewire/RecurringInvoicesTable.php index 9ec1e33837c6..9dc2830c98ed 100644 --- a/app/Http/Livewire/RecurringInvoicesTable.php +++ b/app/Http/Livewire/RecurringInvoicesTable.php @@ -3,7 +3,7 @@ namespace App\Http\Livewire; use App\Models\RecurringInvoice; -use App\Traits\WithSorting; +use App\Utils\Traits\WithSorting; use Livewire\Component; use Livewire\WithPagination; diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index 8cf3ef1a56bd..b77e087a786c 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -143,21 +143,20 @@ class BasePaymentDriver */ public function refundPayment($payment, $amount = 0) { + if ($amount) { + $amount = min($amount, $payment->getCompletedAmount()); + } else { + $amount = $payment->getCompletedAmount(); + } if ($payment->is_deleted) { return false; } - if (!$amount || $amount == 0) { + if (! $amount) { return false; } - if ($amount) { - $amount = min($amount, $payment->getCompletedAmount()); - } else { - $amount = $payment->getCompletedAmount(); - } - if ($payment->type_id == Payment::TYPE_CREDIT_CARD) { return $payment->recordRefund($amount); } @@ -178,15 +177,6 @@ class BasePaymentDriver return false; } - protected function refundDetails($payment, $amount) - { - return [ - 'amount' => $amount, - 'transactionReference' => $payment->transaction_reference, - 'currency' => $payment->client->getCurrencyCode(), - ]; - } - protected function attemptVoidPayment($response, $payment, $amount) { // Partial refund not allowed for unsettled transactions @@ -236,7 +226,7 @@ class BasePaymentDriver acceptNotification() - convert an incoming request from an off-site gateway to a generic notification object for further processing */ - protected function paymentDetails() : array + protected function paymentDetails($input) : array { $data = [ 'currency' => $this->client->getCurrencyCode(), @@ -295,58 +285,4 @@ class BasePaymentDriver return $payment; } - - - - - - - - - - - - - - - - - - /////////////////////////////// V1 cut and paste - public function completeOffsitePurchase($input) - { - $this->input = $input; - $transRef = array_get($this->input, 'token'); - - if (method_exists($this->gateway(), 'completePurchase')) { - $details = $this->paymentDetails(); - $response = $this->gateway()->completePurchase($details)->send(); - $paymentRef = $response->getTransactionReference() ?: $transRef; - - if ($response->isCancelled()) { - return false; - } elseif (!$response->isSuccessful()) { - throw new \Exception($response->getMessage()); - } - } else { - $paymentRef = $transRef; - } - - //$this->updateClientFromOffsite($transRef, $paymentRef); - - // check invoice still has balance - if (!floatval($this->invoice()->balance)) { - throw new Exception(trans('texts.payment_error_code', ['code' => 'NB'])); - } - - // check this isn't a duplicate transaction reference - if (Payment::whereAccountId($this->invitation->account_id) - ->whereTransactionReference($paymentRef) - ->first() - ) { - throw new Exception(trans('texts.payment_error_code', ['code' => 'DT'])); - } - - return $this->createPayment($paymentRef); - } } diff --git a/resources/views/portal/ninja2020/components/livewire/recurring-invoices-table.blade.php b/resources/views/portal/ninja2020/components/livewire/recurring-invoices-table.blade.php index f9fa3854ce69..fbe8ab13d9cd 100644 --- a/resources/views/portal/ninja2020/components/livewire/recurring-invoices-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/recurring-invoices-table.blade.php @@ -79,9 +79,9 @@