diff --git a/app/PaymentDrivers/Stripe/BECS.php b/app/PaymentDrivers/Stripe/BECS.php index f2ccc0a696..a6069065a7 100644 --- a/app/PaymentDrivers/Stripe/BECS.php +++ b/app/PaymentDrivers/Stripe/BECS.php @@ -55,7 +55,7 @@ class BECS 'payment_method_types' => ['au_becs_debit'], 'setup_future_usage' => 'off_session', 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::BECS, diff --git a/app/PaymentDrivers/Stripe/Bancontact.php b/app/PaymentDrivers/Stripe/Bancontact.php index f4aa0ba1c3..2fe4e64094 100644 --- a/app/PaymentDrivers/Stripe/Bancontact.php +++ b/app/PaymentDrivers/Stripe/Bancontact.php @@ -5,7 +5,7 @@ * * @link https://github.com/invoiceninja/invoiceninja source repository * - * @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com) +* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */ @@ -51,7 +51,7 @@ class Bancontact 'currency' => 'eur', 'payment_method_types' => ['bancontact'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::BANCONTACT, diff --git a/app/PaymentDrivers/Stripe/BrowserPay.php b/app/PaymentDrivers/Stripe/BrowserPay.php index 27607aa022..f058475f11 100644 --- a/app/PaymentDrivers/Stripe/BrowserPay.php +++ b/app/PaymentDrivers/Stripe/BrowserPay.php @@ -70,7 +70,7 @@ class BrowserPay implements MethodInterface 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), 'currency' => $this->stripe->client->getCurrencyCode(), 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::APPLE_PAY, diff --git a/app/PaymentDrivers/Stripe/EPS.php b/app/PaymentDrivers/Stripe/EPS.php index 0608c715c4..8acefe4766 100644 --- a/app/PaymentDrivers/Stripe/EPS.php +++ b/app/PaymentDrivers/Stripe/EPS.php @@ -51,7 +51,7 @@ class EPS 'currency' => 'eur', 'payment_method_types' => ['eps'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::EPS, diff --git a/app/PaymentDrivers/Stripe/FPX.php b/app/PaymentDrivers/Stripe/FPX.php index fa835e4eb5..14402ff766 100644 --- a/app/PaymentDrivers/Stripe/FPX.php +++ b/app/PaymentDrivers/Stripe/FPX.php @@ -52,7 +52,7 @@ class FPX 'currency' => $this->stripe->client->getCurrencyCode(), 'payment_method_types' => ['fpx'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::FPX, diff --git a/app/PaymentDrivers/Stripe/GIROPAY.php b/app/PaymentDrivers/Stripe/GIROPAY.php index 167d790eea..593a64920c 100644 --- a/app/PaymentDrivers/Stripe/GIROPAY.php +++ b/app/PaymentDrivers/Stripe/GIROPAY.php @@ -51,7 +51,7 @@ class GIROPAY 'currency' => 'eur', 'payment_method_types' => ['giropay'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::GIROPAY, diff --git a/app/PaymentDrivers/Stripe/Klarna.php b/app/PaymentDrivers/Stripe/Klarna.php index c15660c867..c794a4e22b 100644 --- a/app/PaymentDrivers/Stripe/Klarna.php +++ b/app/PaymentDrivers/Stripe/Klarna.php @@ -47,15 +47,7 @@ class Klarna $data['customer'] = $this->stripe->findOrCreateCustomer()->id; $data['country'] = $this->stripe->client->country->iso_3166_2; - $amount = $data['total']['amount_with_fee']; - - $invoice_numbers = collect($data['invoices'])->pluck('invoice_number'); - - if ($invoice_numbers->count() > 0) { - $description = ctrans('texts.stripe_payment_text', ['invoicenumber' => $invoice_numbers->implode(', '), 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()], $this->stripe->client->company->locale()); - } else { - $description = ctrans('texts.stripe_payment_text_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()], $this->stripe->client->company->locale()); - } + $description = $this->stripe->getDescription(false); $intent = \Stripe\PaymentIntent::create([ 'amount' => $data['stripe_amount'], diff --git a/app/PaymentDrivers/Stripe/PRZELEWY24.php b/app/PaymentDrivers/Stripe/PRZELEWY24.php index 2066330349..1ccfc73db4 100644 --- a/app/PaymentDrivers/Stripe/PRZELEWY24.php +++ b/app/PaymentDrivers/Stripe/PRZELEWY24.php @@ -51,7 +51,7 @@ class PRZELEWY24 'currency' => 'eur', 'payment_method_types' => ['p24'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::PRZELEWY24, diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index 407aac4edc..b5b5a7268d 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -60,7 +60,7 @@ class SEPA 'payment_method_types' => ['sepa_debit'], 'setup_future_usage' => 'off_session', 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::SEPA, diff --git a/app/PaymentDrivers/Stripe/SOFORT.php b/app/PaymentDrivers/Stripe/SOFORT.php index 58067b9d5f..52a90cb2f6 100644 --- a/app/PaymentDrivers/Stripe/SOFORT.php +++ b/app/PaymentDrivers/Stripe/SOFORT.php @@ -51,7 +51,7 @@ class SOFORT 'currency' => 'eur', 'payment_method_types' => ['sofort'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::SOFORT, diff --git a/app/PaymentDrivers/Stripe/iDeal.php b/app/PaymentDrivers/Stripe/iDeal.php index dd32756e0b..5353181676 100644 --- a/app/PaymentDrivers/Stripe/iDeal.php +++ b/app/PaymentDrivers/Stripe/iDeal.php @@ -51,7 +51,7 @@ class iDeal 'currency' => 'eur', 'payment_method_types' => ['ideal'], 'customer' => $this->stripe->findOrCreateCustomer(), - 'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')), + 'description' => $this->stripe->getDescription(false), 'metadata' => [ 'payment_hash' => $this->stripe->payment_hash->hash, 'gateway_type_id' => GatewayType::IDEAL, diff --git a/public/js/clients/payments/stripe-eps.js b/public/js/clients/payments/stripe-eps.js index 80179fdfa4..f59c6767f0 100644 --- a/public/js/clients/payments/stripe-eps.js +++ b/public/js/clients/payments/stripe-eps.js @@ -65,7 +65,6 @@ var ProcessEPSPay = /*#__PURE__*/_createClass(function ProcessEPSPay(key, stripe if (!document.getElementById('eps-name').value) { errors.textContent = document.querySelector('meta[name=translation-name-required]').content; errors.hidden = false; - console.log("name"); return; } @@ -77,7 +76,7 @@ var ProcessEPSPay = /*#__PURE__*/_createClass(function ProcessEPSPay(key, stripe payment_method: { eps: _this.eps, billing_details: { - name: document.getElementById("ideal-name").value + name: document.getElementById("eps-name").value } }, return_url: document.querySelector('meta[name="return-url"]').content diff --git a/public/js/clients/payments/stripe-przelewy24.js b/public/js/clients/payments/stripe-przelewy24.js index 3aad589277..7305f5cae8 100644 --- a/public/js/clients/payments/stripe-przelewy24.js +++ b/public/js/clients/payments/stripe-przelewy24.js @@ -102,6 +102,20 @@ var ProcessPRZELEWY24 = /*#__PURE__*/_createClass(function ProcessPRZELEWY24(key } }, return_url: document.querySelector('meta[name="return-url"]').content + }).then(function (result) { + if (result.error) { + // Show error to your customer + errors.textContent = result.error.message; + errors.hidden = false; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + } else { + // The payment has been processed! + if (result.paymentIntent.status === 'succeeded') { + window.location = document.querySelector('meta[name="return-url"]').content; + } + } }); }); }); diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 394219993c..f979e28c5c 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -38,9 +38,9 @@ "/js/clients/payments/stripe-acss.js": "/js/clients/payments/stripe-acss.js?id=447c587a5eeb0c1de3091c8358db7ad7", "/js/clients/payments/stripe-bancontact.js": "/js/clients/payments/stripe-bancontact.js?id=f694d3f9f01e4550cb5a3eb6cb43c12d", "/js/clients/payments/stripe-becs.js": "/js/clients/payments/stripe-becs.js?id=97ea3555a8504662eda5fce9c9115e5a", - "/js/clients/payments/stripe-eps.js": "/js/clients/payments/stripe-eps.js?id=749cba1332a29baa444b37cee2ade2d7", + "/js/clients/payments/stripe-eps.js": "/js/clients/payments/stripe-eps.js?id=146d48d03f5fc4b1cf122189119e2877", "/js/clients/payments/stripe-ideal.js": "/js/clients/payments/stripe-ideal.js?id=34cf4ee3f189427fb69d0df8f5a4b766", - "/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=448b197a1d94b4408e130b5b8b1c2e53", + "/js/clients/payments/stripe-przelewy24.js": "/js/clients/payments/stripe-przelewy24.js?id=cfdcc5bf20d6bfa09700708dfdd943e2", "/js/clients/payments/stripe-browserpay.js": "/js/clients/payments/stripe-browserpay.js?id=7015e43eb5f9f9f2f45f54b41b5780a0", "/js/clients/payments/stripe-fpx.js": "/js/clients/payments/stripe-fpx.js?id=243c2929386b10c6a0c49ca3bcabfb2d", "/css/app.css": "/css/app.css?id=0cb847167b91d8db2ca50d30e0d691ae", diff --git a/resources/js/clients/payments/stripe-eps.js b/resources/js/clients/payments/stripe-eps.js index 1966262c95..2ae980bc32 100644 --- a/resources/js/clients/payments/stripe-eps.js +++ b/resources/js/clients/payments/stripe-eps.js @@ -56,7 +56,6 @@ class ProcessEPSPay { if (!document.getElementById('eps-name').value) { errors.textContent = document.querySelector('meta[name=translation-name-required]').content; errors.hidden = false; - console.log("name"); return ; } document.getElementById('pay-now').disabled = true; @@ -69,7 +68,7 @@ class ProcessEPSPay { payment_method: { eps: this.eps, billing_details: { - name: document.getElementById("ideal-name").value, + name: document.getElementById("eps-name").value, }, }, return_url: document.querySelector( diff --git a/resources/js/clients/payments/stripe-przelewy24.js b/resources/js/clients/payments/stripe-przelewy24.js index 4cd36a508a..9f990240d0 100644 --- a/resources/js/clients/payments/stripe-przelewy24.js +++ b/resources/js/clients/payments/stripe-przelewy24.js @@ -93,7 +93,22 @@ class ProcessPRZELEWY24 { }, return_url: document.querySelector('meta[name="return-url"]').content, } - ); + ).then(function (result) { + + if (result.error) { + // Show error to your customer + errors.textContent = result.error.message; + errors.hidden = false; + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + } else { + // The payment has been processed! + if (result.paymentIntent.status === 'succeeded') { + window.location = document.querySelector('meta[name="return-url"]').content; + } + } + }); }); }; }