diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 13efcf6d6d74..5e86c125ad0d 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -103,9 +103,7 @@ class AuthorizePaymentDriver extends BaseDriver } public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) - { - $this->setPaymentHash($payment_hash); - + { $this->setPaymentMethod($cgt->gateway_type_id); return $this->payment_method->tokenBilling($cgt, $payment_hash); diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index 71a920631077..c84c59272a58 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -322,8 +322,6 @@ class StripePaymentDriver extends BaseDriver public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) { - $this->setPaymentHash($payment_hash); - return (new Charge($this))->tokenBilling($cgt, $payment_hash); } diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php index 59253d0883b4..811c04c9186e 100644 --- a/app/Services/Client/PaymentMethod.php +++ b/app/Services/Client/PaymentMethod.php @@ -141,7 +141,6 @@ class PaymentMethod if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) { if($type == GatewayType::BANK_TRANSFER); - nlog($gateway->fees_and_limits); $this->payment_methods[] = [$gateway->id => $type]; } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 7641f6caad30..1718c5a7e243 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -41,9 +41,8 @@ class AutoBillInvoice extends AbstractService public function run() { /* Is the invoice payable? */ - if (! $this->invoice->isPayable()) { + if (! $this->invoice->isPayable()) return $this->invoice; - } /* Mark the invoice as sent */ $this->invoice = $this->invoice->service()->markSent()->save(); @@ -67,6 +66,7 @@ class AutoBillInvoice extends AbstractService info("balance remains to be paid!!"); + /* Retrieve the Client Gateway Token */ $gateway_token = $this->getGateway($amount); /* Bail out if no payment methods available */ @@ -74,7 +74,10 @@ class AutoBillInvoice extends AbstractService return $this->invoice; /* $gateway fee */ - $fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes); + //$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes); + $this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save(); + + $fee = $this->invoice->amount - $amount; /* Build payment hash */ $payment_hash = PaymentHash::create([ @@ -86,6 +89,7 @@ class AutoBillInvoice extends AbstractService $payment = $gateway_token->gateway ->driver($this->client) + ->setPaymentHash($payment_hash) ->tokenBilling($gateway_token, $payment_hash); return $this->invoice;