From 07142287811d1bdbf02617c62c5b575d2a185639 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Thu, 8 Dec 2022 08:55:58 +0100 Subject: [PATCH 01/17] Change klarna integration according to Klarna's rules --- .../js/clients/payments/stripe-klarna.js | 41 ++++++------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index 67c379abd99d..5c85a4d2f2c9 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -18,10 +18,10 @@ class ProcessKlarna { setupStripe = () => { if (this.stripeConnect){ - // this.stripe.stripeAccount = this.stripeConnect; + // this.stripe.stripeAccount = this.stripeConnect; - this.stripe = Stripe(this.key, { - stripeAccount: this.stripeConnect, + this.stripe = Stripe(this.key, { + stripeAccount: this.stripeConnect, }); } @@ -33,16 +33,6 @@ class ProcessKlarna { return this; }; - handleError = (message) => { - document.getElementById('pay-now').disabled = false; - document.querySelector('#pay-now > svg').classList.add('hidden'); - document.querySelector('#pay-now > span').classList.remove('hidden'); - - this.errors.textContent = ''; - this.errors.textContent = message; - this.errors.hidden = false; - }; - handle = () => { document.getElementById('pay-now').addEventListener('click', (e) => { let errors = document.getElementById('errors'); @@ -56,28 +46,23 @@ class ProcessKlarna { { payment_method: { billing_details: { - name: document.getElementById("klarna-name").value, - email: document.querySelector('meta[name=email').content, + name: document.querySelector('meta[name=name]').content, + email: document.querySelector('meta[name=email]').content, address: { - line1: document.querySelector('input[name=address1]').value, - line2: document.querySelector('input[name=address2]').value, - city: document.querySelector('input[name=city]').value, - postal_code: document.querySelector('input[name=postal_code]').value, - state: document.querySelector('input[name=state]').value, - country: document.querySelector('meta[name=country').content, - } + line1: document.querySelector('meta[name=address-1]').content, + line2: document.querySelector('meta[name=address-2]').content, + city: document.querySelector('meta[name=city]').content, + postal_code: document.querySelector('meta[name=plz]').content, + state: document.querySelector('meta[name=state]').content, + country: document.querySelector('meta[name=country]').content, + } }, }, return_url: document.querySelector( 'meta[name="return-url"]' ).content, } - ).then((result) => { - if (result.hasOwnProperty('error')) { - return this.handleError(result.error.message); - } - - });; + ); }); }; } From 07e83900c093c7cf8bb346d45b23df10d0c9abce Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Thu, 8 Dec 2022 08:56:31 +0100 Subject: [PATCH 02/17] Delete klarna.blade.php --- .../gateways/stripe/klarna/klarna.blade.php | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php deleted file mode 100644 index 69bda5a6c29c..000000000000 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php +++ /dev/null @@ -1,69 +0,0 @@ -
- @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.name')]) -
- -
-
- -
-
- -
- -
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
- - @endcomponent -
From 80a7a7ce3feab5c53a0da773d1c266b2e76601b7 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Thu, 8 Dec 2022 08:56:48 +0100 Subject: [PATCH 03/17] Change klarna integration according to Klarna's rules --- .../ninja2020/gateways/stripe/klarna/pay.blade.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php index 1995f020acc4..e42e078b2c2e 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php @@ -2,16 +2,22 @@ @section('gateway_head') @if($gateway->company_gateway->getConfigField('account_id')) - - + + @else - + @endif + + + + + + @endsection @@ -23,7 +29,6 @@ @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) {{ ctrans('texts.klarna') }} ({{ ctrans('texts.bank_transfer') }}) @endcomponent - @include('portal.ninja2020.gateways.stripe.klarna.klarna') @include('portal.ninja2020.gateways.includes.pay_now') @endsection From 7590d985a06d6db2cd684ac030312025bbca2e53 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Thu, 8 Dec 2022 08:57:57 +0100 Subject: [PATCH 04/17] Create stripe-klarna.js --- public/js/clients/payments/stripe-klarna.js | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 public/js/clients/payments/stripe-klarna.js diff --git a/public/js/clients/payments/stripe-klarna.js b/public/js/clients/payments/stripe-klarna.js new file mode 100644 index 000000000000..88eb412a24ac --- /dev/null +++ b/public/js/clients/payments/stripe-klarna.js @@ -0,0 +1,2 @@ +/*! For license information please see stripe-klarna.js.LICENSE.txt */ +(()=>{var e,t,n,r;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.querySelector("meta[name=name]").content,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=plz]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}));new i(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); From 426bbe11e952efb4fa0d9826a11b2b21e90e9603 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Thu, 8 Dec 2022 08:58:46 +0100 Subject: [PATCH 05/17] Create stripe-klarna.js.LICENSE.txt --- public/js/clients/payments/stripe-klarna.js.LICENSE.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 public/js/clients/payments/stripe-klarna.js.LICENSE.txt diff --git a/public/js/clients/payments/stripe-klarna.js.LICENSE.txt b/public/js/clients/payments/stripe-klarna.js.LICENSE.txt new file mode 100644 index 000000000000..97e5374d6e40 --- /dev/null +++ b/public/js/clients/payments/stripe-klarna.js.LICENSE.txt @@ -0,0 +1,9 @@ +/** + * Invoice Ninja (https://invoiceninja.com) + * + * @link https://github.com/invoiceninja/invoiceninja source repository + * + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) + * + * @license https://www.elastic.co/licensing/elastic-license + */ From 9a168efdf9e6994bbb1b24d897e593fe0d8976f8 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Fri, 9 Dec 2022 10:42:20 +0100 Subject: [PATCH 06/17] Readded showing errors --- resources/js/clients/payments/stripe-klarna.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index 5c85a4d2f2c9..f7556a8aedcf 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -32,7 +32,17 @@ class ProcessKlarna { return this; }; + + handleError = (message) => { + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + this.errors.textContent = ''; + this.errors.textContent = message; + this.errors.hidden = false; + }; + handle = () => { document.getElementById('pay-now').addEventListener('click', (e) => { let errors = document.getElementById('errors'); @@ -62,7 +72,12 @@ class ProcessKlarna { 'meta[name="return-url"]' ).content, } - ); + ).then((result) => { + if (result.hasOwnProperty('error')) { + return this.handleError(result.error.message); + } + + }); }); }; } From 24681e2f23cf59fed556d8973f88d96ef27fb924 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Fri, 9 Dec 2022 14:25:18 +0100 Subject: [PATCH 07/17] 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; } From eb0445336959bf8639a12a3be49fd7f9fea804ac Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 05:49:57 +0100 Subject: [PATCH 08/17] Update StripePaymentDriver.php --- app/PaymentDrivers/StripePaymentDriver.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index c81f2c397514..7f8337322841 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -250,11 +250,10 @@ class StripePaymentDriver extends BaseDriver && $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->company->country()->getID(), ['840']) && 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; } - if ( $this->client && isset($this->client->country) From 46624c4be9b145ba2e8329833177702c0afe08fc Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 05:50:54 +0100 Subject: [PATCH 09/17] Added getter for ID --- app/Models/Country.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Models/Country.php b/app/Models/Country.php index 3b490892b765..45a840f4c9ba 100644 --- a/app/Models/Country.php +++ b/app/Models/Country.php @@ -35,4 +35,8 @@ class Country extends StaticModel { return trans('texts.country_'.$this->name); } + public function getID() :string + { + return $this->id; + } } From fd16a5e35ad3deaa1e6d8357440043586543ecbf Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 06:15:52 +0100 Subject: [PATCH 10/17] Add fix for special characters in names --- resources/js/clients/payments/stripe-klarna.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index f7556a8aedcf..851bab296e5d 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -56,7 +56,7 @@ class ProcessKlarna { { payment_method: { billing_details: { - name: document.querySelector('meta[name=name]').content, + name: document.querySelector('meta[name=name]').content.replace(",", ""), email: document.querySelector('meta[name=email]').content, address: { line1: document.querySelector('meta[name=address-1]').content, From 6750230bf050877c710ce82ca9fdbd3711554511 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 06:21:02 +0100 Subject: [PATCH 11/17] Updated compiled version --- public/js/clients/payments/stripe-klarna.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/clients/payments/stripe-klarna.js b/public/js/clients/payments/stripe-klarna.js index 88eb412a24ac..1dcb091adcfc 100644 --- a/public/js/clients/payments/stripe-klarna.js +++ b/public/js/clients/payments/stripe-klarna.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-klarna.js.LICENSE.txt */ -(()=>{var e,t,n,r;function o(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.querySelector("meta[name=name]").content,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=plz]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content})}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}));new i(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); +(()=>{var e,t,n,r;function o(e,t){for(var n=0;n svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),r.errors.textContent="",r.errors.textContent=e,r.errors.hidden=!1})),a(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){document.getElementById("errors");document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:document.querySelector("meta[name=name]").content.replace(",",""),email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=plz]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content}).then((function(e){if(e.hasOwnProperty("error"))return r.handleError(e.error.message)}))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}));new i(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})(); \ No newline at end of file From 936451b73ed24d0b14b393111c28f6f64512ed69 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 06:47:48 +0100 Subject: [PATCH 12/17] Show name field, when payment could fail --- .../js/clients/payments/stripe-klarna.js | 72 ++++++++++--------- .../gateways/stripe/klarna/klarna.blade.php | 8 +++ .../gateways/stripe/klarna/pay.blade.php | 2 + 3 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index 851bab296e5d..f4a123b301aa 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -32,7 +32,7 @@ class ProcessKlarna { return this; }; - + handleError = (message) => { document.getElementById('pay-now').disabled = false; document.querySelector('#pay-now > svg').classList.add('hidden'); @@ -42,42 +42,50 @@ class ProcessKlarna { this.errors.textContent = message; this.errors.hidden = false; }; - + handle = () => { document.getElementById('pay-now').addEventListener('click', (e) => { let errors = document.getElementById('errors'); - - document.getElementById('pay-now').disabled = true; - document.querySelector('#pay-now > svg').classList.remove('hidden'); - document.querySelector('#pay-now > span').classList.add('hidden'); - - this.stripe.confirmKlarnaPayment( - document.querySelector('meta[name=pi-client-secret').content, - { - payment_method: { - billing_details: { - name: document.querySelector('meta[name=name]').content.replace(",", ""), - email: document.querySelector('meta[name=email]').content, - address: { - line1: document.querySelector('meta[name=address-1]').content, - line2: document.querySelector('meta[name=address-2]').content, - city: document.querySelector('meta[name=city]').content, - postal_code: document.querySelector('meta[name=plz]').content, - state: document.querySelector('meta[name=state]').content, - country: document.querySelector('meta[name=country]').content, - } + let name = document.querySelector('meta[name=name]').content; + if (! "/^[A-Za-z\s]*$/".test(name)){ + document.getElementById('klarna-name').textContent = name.replace("/^[A-Za-z\s]*$/", "") + document.getElementById('klarna-name').focus(); + errors.textContent = document.querySelector( + 'meta[name=translation-email-required]' + ).content; + errors.hidden = false; + } + else { + document.getElementById('pay-now').disabled = true; + document.querySelector('#pay-now > svg').classList.remove('hidden'); + document.querySelector('#pay-now > span').classList.add('hidden'); + this.stripe.confirmKlarnaPayment( + document.querySelector('meta[name=pi-client-secret').content, + { + payment_method: { + billing_details: { + name: name, + email: document.querySelector('meta[name=email]').content, + address: { + line1: document.querySelector('meta[name=address-1]').content, + line2: document.querySelector('meta[name=address-2]').content, + city: document.querySelector('meta[name=city]').content, + postal_code: document.querySelector('meta[name=plz]').content, + state: document.querySelector('meta[name=state]').content, + country: document.querySelector('meta[name=country]').content, + } + }, }, - }, - return_url: document.querySelector( - 'meta[name="return-url"]' - ).content, - } - ).then((result) => { - if (result.hasOwnProperty('error')) { - return this.handleError(result.error.message); - } + return_url: document.querySelector( + 'meta[name="return-url"]' + ).content, + } + ).then((result) => { + if (result.hasOwnProperty('error')) { + return this.handleError(result.error.message); + } - }); + });} }); }; } diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php new file mode 100644 index 000000000000..4668535f81eb --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php @@ -0,0 +1,8 @@ +
+ @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.name')]) +
+ +
+ + @endcomponent +
diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php index e42e078b2c2e..c582cce5da91 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php @@ -19,6 +19,7 @@ + @endsection @section('gateway_content') @@ -29,6 +30,7 @@ @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) {{ ctrans('texts.klarna') }} ({{ ctrans('texts.bank_transfer') }}) @endcomponent + @include('portal.ninja2020.gateways.stripe.klarna.klarna') @include('portal.ninja2020.gateways.includes.pay_now') @endsection From 6ed6855c4641f27d98b8a27a05224ef57b98fc75 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 06:58:37 +0100 Subject: [PATCH 13/17] Further fixes --- lang/en/texts.php | 1 + resources/js/clients/payments/stripe-klarna.js | 8 ++++---- .../portal/ninja2020/gateways/stripe/klarna/pay.blade.php | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lang/en/texts.php b/lang/en/texts.php index 9fc9764b2a61..dd5b953622c3 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2503,6 +2503,7 @@ $LANG = array( 'alipay' => 'Alipay', 'sofort' => 'Sofort', 'sepa' => 'SEPA Direct Debit', + 'translation_name_without_special_characters' => 'Please enter a name with only the letter a-z and whitespaces', 'enable_alipay' => 'Accept Alipay', 'enable_sofort' => 'Accept EU bank transfers', 'stripe_alipay_help' => 'These gateways also need to be activated in :link.', diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index f4a123b301aa..fa5ea63b6327 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -46,12 +46,12 @@ class ProcessKlarna { handle = () => { document.getElementById('pay-now').addEventListener('click', (e) => { let errors = document.getElementById('errors'); - let name = document.querySelector('meta[name=name]').content; - if (! "/^[A-Za-z\s]*$/".test(name)){ - document.getElementById('klarna-name').textContent = name.replace("/^[A-Za-z\s]*$/", "") + let name = document.getElementById("klarna-name").value; + if (! /^[A-Za-z\s]*$/.test(name)){ + document.getElementById('klarna-name').textContent = name.replace(/^[A-Za-z\s]*$/, "") document.getElementById('klarna-name').focus(); errors.textContent = document.querySelector( - 'meta[name=translation-email-required]' + 'meta[name=translation-name-without-special-characters]' ).content; errors.hidden = false; } diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php index c582cce5da91..6ab1d2d42d24 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/pay.blade.php @@ -12,7 +12,6 @@ - From 88278832abe79f2dd9e2ac431b9fce6a5dc5f578 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 07:02:50 +0100 Subject: [PATCH 14/17] Further fixes --- lang/en/texts.php | 2 +- resources/js/clients/payments/stripe-klarna.js | 1 + .../portal/ninja2020/gateways/stripe/klarna/klarna.blade.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lang/en/texts.php b/lang/en/texts.php index dd5b953622c3..e5140fd79211 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2503,7 +2503,7 @@ $LANG = array( 'alipay' => 'Alipay', 'sofort' => 'Sofort', 'sepa' => 'SEPA Direct Debit', - 'translation_name_without_special_characters' => 'Please enter a name with only the letter a-z and whitespaces', + 'name_without_special_characters' => 'Please enter a name with only the letter a-z and whitespaces', 'enable_alipay' => 'Accept Alipay', 'enable_sofort' => 'Accept EU bank transfers', 'stripe_alipay_help' => 'These gateways also need to be activated in :link.', diff --git a/resources/js/clients/payments/stripe-klarna.js b/resources/js/clients/payments/stripe-klarna.js index fa5ea63b6327..e81ef819f08e 100644 --- a/resources/js/clients/payments/stripe-klarna.js +++ b/resources/js/clients/payments/stripe-klarna.js @@ -48,6 +48,7 @@ class ProcessKlarna { let errors = document.getElementById('errors'); let name = document.getElementById("klarna-name").value; if (! /^[A-Za-z\s]*$/.test(name)){ + document.getElementById('klarna-name-correction').hidden = false; document.getElementById('klarna-name').textContent = name.replace(/^[A-Za-z\s]*$/, "") document.getElementById('klarna-name').focus(); errors.textContent = document.querySelector( diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php index 4668535f81eb..63d8e7674219 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php @@ -1,7 +1,7 @@
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.name')]) -
- + @endcomponent From 1c1cf36ec30769702c623520d2aa310e3bd07848 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Sat, 10 Dec 2022 07:06:08 +0100 Subject: [PATCH 15/17] Further fixes --- lang/en/texts.php | 2 +- .../portal/ninja2020/gateways/stripe/klarna/klarna.blade.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lang/en/texts.php b/lang/en/texts.php index e5140fd79211..91810a48a534 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2503,7 +2503,7 @@ $LANG = array( 'alipay' => 'Alipay', 'sofort' => 'Sofort', 'sepa' => 'SEPA Direct Debit', - 'name_without_special_characters' => 'Please enter a name with only the letter a-z and whitespaces', + 'name_without_special_characters' => 'Please enter a name with only the letters a-z and whitespaces', 'enable_alipay' => 'Accept Alipay', 'enable_sofort' => 'Accept EU bank transfers', 'stripe_alipay_help' => 'These gateways also need to be activated in :link.', diff --git a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php index 63d8e7674219..4306e1bd5fad 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/klarna/klarna.blade.php @@ -1,6 +1,6 @@ -
+