diff --git a/app/Models/Client.php b/app/Models/Client.php index 41fa0b2b88f0..1cde445dedc2 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -512,7 +512,7 @@ class Client extends BaseModel implements HasLocalePreference foreach ($gateways as $gateway) { foreach ($gateway->driver($this)->gatewayTypes() as $type) { - if(property_exists($gateway, 'fees_and_limits') property_exists($gateway->fees_and_limits, $type)){ + if(property_exists($gateway, 'fees_and_limits') && property_exists($gateway->fees_and_limits, $type)){ $fees_and_limits_for_payment_type = $gateway->fees_and_limits->{$type}; } else diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 8ca46609e902..c73465fbbcb1 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -69,7 +69,7 @@ class AutoBillInvoice extends AbstractService return $this->finalizePaymentUsingCredits(); info("balance remains to be paid!!"); - + $gateway_token = $this->getGateway($amount); /* Bail out if no payment methods available */ @@ -79,6 +79,8 @@ class AutoBillInvoice extends AbstractService /* $gateway fee */ $fee = $gateway_token->gateway->calcGatewayFee($amount); +//determine exact fee as per PaymentController + /* Build payment hash */ $payment_hash = PaymentHash::create([ 'hash' => Str::random(128), diff --git a/tests/Feature/CompanyGatewayResolutionTest.php b/tests/Feature/CompanyGatewayResolutionTest.php new file mode 100644 index 000000000000..e0d9061bb240 --- /dev/null +++ b/tests/Feature/CompanyGatewayResolutionTest.php @@ -0,0 +1,79 @@ +withoutMiddleware( + ThrottleRequests::class + ); + + if (! config('ninja.testvars.stripe')) { + $this->markTestSkipped('Skip test no company gateways installed'); + } + + $this->faker = \Faker\Factory::create(); + + Model::reguard(); + + $this->makeTestData(); + + $this->withoutExceptionHandling(); + + $cg = new CompanyGateway; + $cg->company_id = $this->company->id; + $cg->user_id = $this->user->id; + $cg->gateway_key = 'd14dd26a37cecc30fdd65700bfb55b23'; + $cg->require_cvv = true; + $cg->show_billing_address = true; + $cg->show_shipping_address = true; + $cg->update_details = true; + $cg->config = encrypt(config('ninja.testvars.stripe')); + $cg->save(); + } + + public function testGatewayResolution() + { + $this->assertTrue(true); + } +}