From 24681e2f23cf59fed556d8973f88d96ef27fb924 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Fri, 9 Dec 2022 14:25:18 +0100 Subject: [PATCH] Disallow payment with Klarna for business out of US --- app/PaymentDrivers/StripePaymentDriver.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index e6fa402b3a00..c81f2c397514 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -20,6 +20,7 @@ use App\Http\Requests\Request; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; +use App\Models\Country; use App\Models\Payment; use App\Models\PaymentHash; use App\Models\PaymentType; @@ -118,7 +119,7 @@ class StripePaymentDriver extends BaseDriver throw new StripeConnectFailure('Stripe Connect has not been configured'); } } else { - + $this->stripe = new StripeClient( $this->company_gateway->getConfigField('apiKey') ); @@ -240,8 +241,16 @@ class StripePaymentDriver extends BaseDriver } if ($this->client && $this->client->currency() - && in_array($this->client->currency()->code, ['EUR', 'DKK', 'GBP', 'NOK', 'SEK', 'USD', 'AUD', 'NZD', 'CAD', 'PLN', 'CHF']) + && in_array($this->client->currency()->code, ['EUR', 'DKK', 'GBP', 'NOK', 'SEK', 'AUD', 'NZD', 'CAD', 'PLN', 'CHF']) && isset($this->client->country) + && in_array($this->client->country->iso_3166_3, ['AUT','BEL','DNK','FIN','FRA','DEU','IRL','ITA','NLD','NOR','ESP','SWE','GBR'])) { + $types[] = GatewayType::KLARNA; + } + if ($this->client + && $this->client->currency() + && in_array($this->client->currency()->code, ['EUR', 'DKK', 'GBP', 'NOK', 'SEK', 'AUD', 'NZD', 'CAD', 'PLN', 'CHF', 'USD']) + && isset($this->client->country) + && in_array(Country::find($this->client->company->country()), ['USA']) && in_array($this->client->country->iso_3166_3, ['AUT','BEL','DNK','FIN','FRA','DEU','IRL','ITA','NLD','NOR','ESP','SWE','GBR','USA'])) { $types[] = GatewayType::KLARNA; }