Add gateway fees for autobill

This commit is contained in:
David Bomba 2021-01-28 08:31:31 +11:00
parent 0c7ae3bca8
commit 756f421319
4 changed files with 8 additions and 9 deletions

View File

@ -103,9 +103,7 @@ class AuthorizePaymentDriver extends BaseDriver
} }
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{ {
$this->setPaymentHash($payment_hash);
$this->setPaymentMethod($cgt->gateway_type_id); $this->setPaymentMethod($cgt->gateway_type_id);
return $this->payment_method->tokenBilling($cgt, $payment_hash); return $this->payment_method->tokenBilling($cgt, $payment_hash);

View File

@ -322,8 +322,6 @@ class StripePaymentDriver extends BaseDriver
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{ {
$this->setPaymentHash($payment_hash);
return (new Charge($this))->tokenBilling($cgt, $payment_hash); return (new Charge($this))->tokenBilling($cgt, $payment_hash);
} }

View File

@ -141,7 +141,6 @@ class PaymentMethod
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) { if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) {
if($type == GatewayType::BANK_TRANSFER); if($type == GatewayType::BANK_TRANSFER);
nlog($gateway->fees_and_limits);
$this->payment_methods[] = [$gateway->id => $type]; $this->payment_methods[] = [$gateway->id => $type];
} }

View File

@ -41,9 +41,8 @@ class AutoBillInvoice extends AbstractService
public function run() public function run()
{ {
/* Is the invoice payable? */ /* Is the invoice payable? */
if (! $this->invoice->isPayable()) { if (! $this->invoice->isPayable())
return $this->invoice; return $this->invoice;
}
/* Mark the invoice as sent */ /* Mark the invoice as sent */
$this->invoice = $this->invoice->service()->markSent()->save(); $this->invoice = $this->invoice->service()->markSent()->save();
@ -67,6 +66,7 @@ class AutoBillInvoice extends AbstractService
info("balance remains to be paid!!"); info("balance remains to be paid!!");
/* Retrieve the Client Gateway Token */
$gateway_token = $this->getGateway($amount); $gateway_token = $this->getGateway($amount);
/* Bail out if no payment methods available */ /* Bail out if no payment methods available */
@ -74,7 +74,10 @@ class AutoBillInvoice extends AbstractService
return $this->invoice; return $this->invoice;
/* $gateway fee */ /* $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 */ /* Build payment hash */
$payment_hash = PaymentHash::create([ $payment_hash = PaymentHash::create([
@ -86,6 +89,7 @@ class AutoBillInvoice extends AbstractService
$payment = $gateway_token->gateway $payment = $gateway_token->gateway
->driver($this->client) ->driver($this->client)
->setPaymentHash($payment_hash)
->tokenBilling($gateway_token, $payment_hash); ->tokenBilling($gateway_token, $payment_hash);
return $this->invoice; return $this->invoice;