From 91126b2dad49189bf6370da23c0c7e8f4dcf5899 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:15:23 +0100 Subject: [PATCH 1/7] Translate Stripe payment texts --- app/PaymentDrivers/Stripe/Charge.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index 691f6ca5bb13..a9751a49ca73 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -62,9 +62,9 @@ class Charge $invoice = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->first(); if ($invoice) { - $description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } else { - $description = "Payment with no invoice for amount {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } $this->stripe->init(); From e9820ee984e8f8d896c63d47fb8bae47c79c2793 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:18:41 +0100 Subject: [PATCH 2/7] Add translation strings --- lang/en/texts.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lang/en/texts.php b/lang/en/texts.php index 1bc294749e4a..ce33ae3b3693 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -254,6 +254,8 @@ $LANG = array( 'notification_invoice_paid' => 'A payment of :amount was made by client :client towards Invoice :invoice.', 'notification_invoice_sent' => 'The following client :client was emailed Invoice :invoice for :amount.', 'notification_invoice_viewed' => 'The following client :client viewed Invoice :invoice for :amount.', + 'stripe_paymenttext' => 'Invoice :invoicenumber for :amount for client :client', + 'stripe_paymenttext_without_invoice' => 'Payment with no invoice for amount :amount for client :client', 'reset_password' => 'You can reset your account password by clicking the following button:', 'secure_payment' => 'Secure Payment', 'card_number' => 'Card Number', From eecc2bb8af4f095319e94b9ce1f1f51b1f45b2dc Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:28:37 +0100 Subject: [PATCH 3/7] ACH translations --- app/PaymentDrivers/Stripe/ACH.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index 2a5689ccf901..c40ad045d64f 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -172,9 +172,9 @@ class ACH ->first(); if ($invoice) { - $description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } else { - $description = "Payment with no invoice for amount {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } @@ -210,9 +210,9 @@ class ACH ->first(); if ($invoice) { - $description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } else { - $description = "Payment with no invoice for amount {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } if (substr($cgt->token, 0, 2) === 'pm') { @@ -454,9 +454,9 @@ class ACH ->first(); if ($invoice) { - $description = "Invoice {$invoice->number} for {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } else { - $description = "Payment with no invoice for amount {$amount} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); } if (substr($source->token, 0, 2) === 'pm') { From 40a78a433631be01da59b37c83aed7db681ce6cd Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:33:13 +0100 Subject: [PATCH 4/7] Add translation --- app/PaymentDrivers/Stripe/CreditCard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 838af9c2328c..445a513049a8 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -62,7 +62,7 @@ class CreditCard // $description = $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')) . " for client {$this->stripe->client->present()->name()}"; $invoice_numbers = collect($data['invoices'])->pluck('invoice_number')->implode(','); - $description = "Invoices: {$invoice_numbers} for {$data['total']['amount_with_fee']} for client {$this->stripe->client->present()->name()}"; + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice_numbers, 'amount' => $data['total']['amount_with_fee'], 'client' => $this->stripe->client->present()->name()]); $payment_intent_data = [ 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()), From 974d2f9c755fbe0e12f1aa9814f1b795b15b7f34 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:54:05 +0100 Subject: [PATCH 5/7] Add currency sign to text --- app/PaymentDrivers/Stripe/Charge.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/PaymentDrivers/Stripe/Charge.php b/app/PaymentDrivers/Stripe/Charge.php index a9751a49ca73..94798d485c79 100644 --- a/app/PaymentDrivers/Stripe/Charge.php +++ b/app/PaymentDrivers/Stripe/Charge.php @@ -32,6 +32,7 @@ use Stripe\Exception\CardException; use Stripe\Exception\InvalidRequestException; use Stripe\Exception\RateLimitException; use Stripe\StripeClient; +use App\Utils\Number; class Charge { @@ -62,9 +63,9 @@ class Charge $invoice = Invoice::whereIn('id', $this->transformKeys(array_column($payment_hash->invoices(), 'invoice_id')))->withTrashed()->first(); if ($invoice) { - $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } else { - $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } $this->stripe->init(); From dd5c8129692a1fd0dd95866f8227718b65d8a266 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:55:20 +0100 Subject: [PATCH 6/7] Add currency sign --- app/PaymentDrivers/Stripe/ACH.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index c40ad045d64f..cd386b8287b3 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -36,6 +36,7 @@ use Stripe\Exception\CardException; use Stripe\Exception\InvalidRequestException; use Stripe\Exception\RateLimitException; use Stripe\PaymentIntent; +use App\Utils\Number; class ACH { @@ -172,9 +173,9 @@ class ACH ->first(); if ($invoice) { - $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } else { - $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } @@ -210,9 +211,9 @@ class ACH ->first(); if ($invoice) { - $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } else { - $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } if (substr($cgt->token, 0, 2) === 'pm') { @@ -454,9 +455,9 @@ class ACH ->first(); if ($invoice) { - $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice->number, 'amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } else { - $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => $amount, 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext_without_invoice', ['amount' => Number::formatMoney($amount, $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); } if (substr($source->token, 0, 2) === 'pm') { From c3a1d21c61cd931800c6be4d711179f9f7928133 Mon Sep 17 00:00:00 2001 From: Lars Kusch Date: Tue, 29 Nov 2022 09:56:16 +0100 Subject: [PATCH 7/7] Add currency sign --- app/PaymentDrivers/Stripe/CreditCard.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 445a513049a8..5fb8bd2e2d6a 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -23,6 +23,7 @@ use App\PaymentDrivers\StripePaymentDriver; use App\PaymentDrivers\Stripe\Jobs\UpdateCustomer; use Stripe\PaymentIntent; use Stripe\PaymentMethod; +use App\Utils\Number; class CreditCard { @@ -62,7 +63,7 @@ class CreditCard // $description = $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')) . " for client {$this->stripe->client->present()->name()}"; $invoice_numbers = collect($data['invoices'])->pluck('invoice_number')->implode(','); - $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice_numbers, 'amount' => $data['total']['amount_with_fee'], 'client' => $this->stripe->client->present()->name()]); + $description = ctrans('text.stripe_paymenttext', ['invoicenumber' => $invoice_numbers, 'amount' => Number::formatMoney($data['total']['amount_with_fee'], $this->stripe->client), 'client' => $this->stripe->client->present()->name()]); $payment_intent_data = [ 'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),