Reset v2 into working stage (#3673)

* fix withsorting

* fix recurring invoices table

* Reset BasePaymentDriver
This commit is contained in:
Benjamin Beganović 2020-05-04 23:22:31 +02:00 committed by GitHub
parent 42ccfe0700
commit e3e52987c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 14 additions and 78 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -79,9 +79,9 @@
</div>
</div>
<div class="flex justify-center md:justify-between mt-6 mb-6">
@if($quotes->total() > 0)
@if($invoices->total() > 0)
<span class="text-gray-700 text-sm hidden md:block">
{{ ctrans('texts.showing_x_of', ['first' => $quotes->firstItem(), 'last' => $quotes->lastItem(), 'total' => $quotes->total()]) }}
{{ ctrans('texts.showing_x_of', ['first' => $invoices->firstItem(), 'last' => $invoices->lastItem(), 'total' => $invoices->total()]) }}
</span>
@endif
{{ $invoices->links() }}