1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Support for DIRECT_DEBIT on authorization pages

This commit is contained in:
Benjamin Beganović 2021-10-19 15:37:23 +02:00
parent a562f7e711
commit 98d2a4a407
2 changed files with 19 additions and 3 deletions

View File

@ -149,11 +149,11 @@ class PaymentMethodController extends Controller
private function getClientGateway()
{
if (request()->query('method') == GatewayType::CREDIT_CARD) {
return $gateway = auth()->user()->client->getCreditCardGateway();
return auth()->user()->client->getCreditCardGateway();
}
if (request()->query('method') == GatewayType::BANK_TRANSFER) {
return $gateway = auth()->user()->client->getBankTransferGateway();
if (in_array(request()->query('method'), [GatewayType::BANK_TRANSFER, GatewayType::DIRECT_DEBIT])) {
return auth()->user()->client->getBankTransferGateway();
}
abort(404, 'Gateway not found.');

View File

@ -518,6 +518,18 @@ class Client extends BaseModel implements HasLocalePreference
}
if ($this->country->iso_3166_3 == 'GBR' && in_array(GatewayType::DIRECT_DEBIT, array_column($pms, 'gateway_type_id'))) {
foreach ($pms as $pm) {
if ($pm['gateway_type_id'] == GatewayType::DIRECT_DEBIT) {
$cg = CompanyGateway::find($pm['company_gateway_id']);
if ($cg && $cg->fees_and_limits->{GatewayType::DIRECT_DEBIT}->is_enabled) {
return $cg;
}
}
}
}
return null;
// $company_gateways = $this->getSetting('company_gateway_ids');
@ -556,6 +568,10 @@ class Client extends BaseModel implements HasLocalePreference
if ($this->currency()->code == 'EUR') {
return GatewayType::SEPA;
}
if ($this->currency()->code == 'GBP') {
return GatewayType::DIRECT_DEBIT;
}
}
public function getCurrencyCode()