Fix for gateway fees w/partial

This commit is contained in:
Hillel Coren 2017-03-16 19:34:14 +02:00
parent 0c3db5a8e4
commit d105943bf3
2 changed files with 10 additions and 5 deletions

View File

@ -27,12 +27,12 @@ trait ChargesFees
if ($settings->fee_percent) {
// prevent charging taxes twice on the surcharge
$amount = $this->getRequestedAmount();
$amount = $this->amount;
$taxField = $account->gateway_fee_location == FEE_LOCATION_CHARGE1 ? 'custom_invoice_taxes1' : 'custom_invoice_taxes1';
if ($account->$taxField) {
$taxAmount = 0;
foreach ($this->getTaxes() as $key => $tax) {
$taxAmount += $tax['amount'] - $tax['paid'];
$taxAmount += $tax['amount'];
}
$amount -= $taxAmount;
}

View File

@ -132,9 +132,11 @@ class BasePaymentDriver
return redirect()->to('view/' . $this->invitation->invitation_key);
}
// apply gateway fees
$invoicRepo = app('App\Ninja\Repositories\InvoiceRepository');
$invoicRepo->setGatewayFee($this->invoice(), $this->gatewayType);
if (! $this->isGatewayType(GATEWAY_TYPE_TOKEN)) {
// apply gateway fees
$invoicRepo = app('App\Ninja\Repositories\InvoiceRepository');
$invoicRepo->setGatewayFee($this->invoice(), $this->gatewayType);
}
if ($this->isGatewayType(GATEWAY_TYPE_TOKEN) || $gateway->is_offsite) {
if (Session::has('error')) {
@ -267,6 +269,9 @@ class BasePaymentDriver
->firstOrFail();
}
$invoicRepo = app('App\Ninja\Repositories\InvoiceRepository');
$invoicRepo->setGatewayFee($this->invoice(), $paymentMethod->payment_type->gateway_type_id);
if (! $this->meetsGatewayTypeLimits($paymentMethod->payment_type->gateway_type_id)) {
// The customer must have hacked the URL
Session::flash('error', trans('texts.limits_not_met'));