diff --git a/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php index 76ffa929dfd7..5ba9c2fa104a 100644 --- a/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php +++ b/app/Http/Requests/ClientPortal/PaymentMethod/CreatePaymentMethodRequest.php @@ -27,7 +27,7 @@ class CreatePaymentMethodRequest extends FormRequest ->filter(function ($method) use (&$available_methods) { $available_methods[] = $method['gateway_type_id']; }); - + if (in_array($this->query('method'), $available_methods)) { return true; } diff --git a/app/Models/Client.php b/app/Models/Client.php index 8bfa386404a1..61bda7230946 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -688,6 +688,11 @@ class Client extends BaseModel implements HasLocalePreference return GatewayType::SEPA; } + //Special handler for GoCardless + if($this->currency()->code == 'CAD' && ($this->getBankTransferGateway()->gateway_key == 'b9886f9257f0c6ee7c302f1c74475f6c') ?? false) { + return GatewayType::DIRECT_DEBIT; + } + if (in_array($this->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD','USD'])) { return GatewayType::DIRECT_DEBIT; } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index d71e4ebd3fbe..253af5585fe6 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -148,7 +148,7 @@ class CompanyGateway extends BaseModel '944c20175bbe6b9972c05bcfe294c2c7' => 313, 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs' => 314, '65faab2ab6e3223dbe848b1686490baz' => 320, - 'b9886f9257f0c6ee7c302f1c74475f6c' => 321, + 'b9886f9257f0c6ee7c302f1c74475f6c' => 321, //GoCardless 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9' => 322, '80af24a6a691230bbec33e930ab40666' => 323, ]; diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 270bac07267e..3b1fb23e9589 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -11,23 +11,23 @@ namespace App\PaymentDrivers; -use App\Factory\ClientContactFactory; -use App\Factory\ClientFactory; -use App\Http\Requests\Payments\PaymentWebhookRequest; -use App\Jobs\Mail\PaymentFailedMailer; -use App\Jobs\Util\SystemLogger; use App\Models\Client; -use App\Models\ClientGatewayToken; use App\Models\Country; -use App\Models\GatewayType; use App\Models\Invoice; use App\Models\Payment; +use App\Models\SystemLog; +use App\Models\GatewayType; use App\Models\PaymentHash; use App\Models\PaymentType; -use App\Models\SystemLog; -use App\Utils\Traits\GeneratesCounter; +use App\Factory\ClientFactory; +use App\Jobs\Util\SystemLogger; use App\Utils\Traits\MakesHash; +use App\Models\ClientGatewayToken; +use App\Factory\ClientContactFactory; +use App\Jobs\Mail\PaymentFailedMailer; +use App\Utils\Traits\GeneratesCounter; use Illuminate\Database\QueryException; +use App\Http\Requests\Payments\PaymentWebhookRequest; class GoCardlessPaymentDriver extends BaseDriver { @@ -79,8 +79,7 @@ class GoCardlessPaymentDriver extends BaseDriver if ( $this->client && isset($this->client->country) - // && in_array($this->client->country->iso_3166_3, ['GBR']) - && in_array($this->client->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD']) + && in_array($this->client->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD','CAD']) ) { $types[] = GatewayType::DIRECT_DEBIT; } @@ -92,7 +91,7 @@ class GoCardlessPaymentDriver extends BaseDriver if ($this->client->currency()->code === 'GBP') { $types[] = GatewayType::INSTANT_BANK_PAY; } - + return $types; }