Allow Gocardless ACSS payments for CAD customers

This commit is contained in:
David Bomba 2024-01-28 10:24:31 +11:00
parent 9f5cfd7440
commit 5b2428c2a4
4 changed files with 18 additions and 14 deletions

View File

@ -27,7 +27,7 @@ class CreatePaymentMethodRequest extends FormRequest
->filter(function ($method) use (&$available_methods) { ->filter(function ($method) use (&$available_methods) {
$available_methods[] = $method['gateway_type_id']; $available_methods[] = $method['gateway_type_id'];
}); });
if (in_array($this->query('method'), $available_methods)) { if (in_array($this->query('method'), $available_methods)) {
return true; return true;
} }

View File

@ -688,6 +688,11 @@ class Client extends BaseModel implements HasLocalePreference
return GatewayType::SEPA; 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'])) { if (in_array($this->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD','USD'])) {
return GatewayType::DIRECT_DEBIT; return GatewayType::DIRECT_DEBIT;
} }

View File

@ -148,7 +148,7 @@ class CompanyGateway extends BaseModel
'944c20175bbe6b9972c05bcfe294c2c7' => 313, '944c20175bbe6b9972c05bcfe294c2c7' => 313,
'kivcvjexxvdiyqtj3mju5d6yhpeht2xs' => 314, 'kivcvjexxvdiyqtj3mju5d6yhpeht2xs' => 314,
'65faab2ab6e3223dbe848b1686490baz' => 320, '65faab2ab6e3223dbe848b1686490baz' => 320,
'b9886f9257f0c6ee7c302f1c74475f6c' => 321, 'b9886f9257f0c6ee7c302f1c74475f6c' => 321, //GoCardless
'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9' => 322, 'hxd6gwg3ekb9tb3v9lptgx1mqyg69zu9' => 322,
'80af24a6a691230bbec33e930ab40666' => 323, '80af24a6a691230bbec33e930ab40666' => 323,
]; ];

View File

@ -11,23 +11,23 @@
namespace App\PaymentDrivers; 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\Client;
use App\Models\ClientGatewayToken;
use App\Models\Country; use App\Models\Country;
use App\Models\GatewayType;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\SystemLog;
use App\Models\GatewayType;
use App\Models\PaymentHash; use App\Models\PaymentHash;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Factory\ClientFactory;
use App\Utils\Traits\GeneratesCounter; use App\Jobs\Util\SystemLogger;
use App\Utils\Traits\MakesHash; 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 Illuminate\Database\QueryException;
use App\Http\Requests\Payments\PaymentWebhookRequest;
class GoCardlessPaymentDriver extends BaseDriver class GoCardlessPaymentDriver extends BaseDriver
{ {
@ -79,8 +79,7 @@ class GoCardlessPaymentDriver extends BaseDriver
if ( if (
$this->client $this->client
&& isset($this->client->country) && 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','CAD'])
&& in_array($this->client->currency()->code, ['EUR', 'GBP','DKK','SEK','AUD','NZD'])
) { ) {
$types[] = GatewayType::DIRECT_DEBIT; $types[] = GatewayType::DIRECT_DEBIT;
} }
@ -92,7 +91,7 @@ class GoCardlessPaymentDriver extends BaseDriver
if ($this->client->currency()->code === 'GBP') { if ($this->client->currency()->code === 'GBP') {
$types[] = GatewayType::INSTANT_BANK_PAY; $types[] = GatewayType::INSTANT_BANK_PAY;
} }
return $types; return $types;
} }