From f45c6d8d88326f4e8a64d9b7bb47f896cc9ca2fd Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 27 Nov 2024 13:21:35 +0100 Subject: [PATCH] O7 Setting to override Stripe Customer email with shop customer address --- Application/Model/Request/PaymentIntent.php | 6 +++++- Application/views/admin_twig/de/stripe_lang.php | 2 ++ Application/views/admin_twig/en/stripe_lang.php | 2 ++ metadata.php | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Application/Model/Request/PaymentIntent.php b/Application/Model/Request/PaymentIntent.php index f92f7d6..a24beda 100644 --- a/Application/Model/Request/PaymentIntent.php +++ b/Application/Model/Request/PaymentIntent.php @@ -6,6 +6,7 @@ namespace OxidSolutionCatalysts\Stripe\Application\Model\Request; +use OxidEsales\EshopCommunity\Core\Registry; use OxidSolutionCatalysts\Stripe\Application\Helper\Order as OrderHelper; use OxidSolutionCatalysts\Stripe\Application\Helper\Payment as PaymentHelper; use OxidSolutionCatalysts\Stripe\Application\Helper\User as UserHelper; @@ -48,7 +49,10 @@ public function addRequestParameters(CoreOrder $oOrder, $dAmount, $sReturnUrl, $ $this->addParameter('customer', $sStripeCustomerId); } - $this->addParameter('receipt_email', $this->getCustomerEmail($oCoreUser)); + //task STRIP-47, overriding customer email only if module setting is enabled + if (PaymentHelper::getInstance()->getShopConfVar('sStripeCustomerEmailOverride')) { + $this->addParameter('receipt_email', $this->getCustomerEmail($oCoreUser)); + } if ($oPaymentModel->isRedirectUrlNeeded($oOrder) === true) { $this->addParameter('return_url', $sReturnUrl); diff --git a/Application/views/admin_twig/de/stripe_lang.php b/Application/views/admin_twig/de/stripe_lang.php index d72bba0..78857d5 100644 --- a/Application/views/admin_twig/de/stripe_lang.php +++ b/Application/views/admin_twig/de/stripe_lang.php @@ -38,6 +38,7 @@ 'SHOP_MODULE_sStripeCronSecureKey' => 'Cronjob Sicherheits-Schlüssel', 'SHOP_MODULE_GROUP_STRIPE_WEBHOOKS' => 'Webhooks', 'SHOP_MODULE_sStripeWebhookEndpoint' => 'Webhook Endpoint', + 'SHOP_MODULE_sStripeCustomerEmailOverride' => 'Ersetzen Sie die E-Mail-Adresse des Kunden durch die Adresse aus dem Geschäft', 'HELP_SHOP_MODULE_sStripeTestKey' => 'Geben Sie Ihren persönlichen privaten TEST-API-Schlüssel ein, der zum Einrichten des Webhook-Endpunkts verwendet wird.', 'HELP_SHOP_MODULE_sStripeLiveKey' => 'Geben Sie Ihren persönlichen privaten LIVE-API-Schlüssel ein, der zum Einrichten des Webhook-Endpunkts verwendet wird.', @@ -52,6 +53,7 @@ 'HELP_SHOP_MODULE_sStripeCronSecondChanceActive' => 'Damit dieser Cronjob arbeitet, müssen Sie zusätzlich zu dieser Checkbox noch sicherstellen dass der Stripe Cronjob eingerichtet ist. Mehr dazu erfahren Sie in der README.md Datei des Moduls.', 'HELP_SHOP_MODULE_sStripeCronOrderShipmentActive' => 'Dieser Cronjob ist nur notwendig, wenn der Versandstatus in Ihrem Shop über ein externes System gesetzt wird und NICHT über den "Jetzt versenden" Button im Oxid-Admin. Damit dieser Cronjob arbeitet, müssen Sie zusätzlich zu dieser Checkbox noch sicherstellen dass der Stripe Cronjob eingerichtet ist. Mehr dazu erfahren Sie in der README.md Datei des Moduls.', 'HELP_SHOP_MODULE_sStripeCronSecureKey' => 'Diese Option benötigen Sie nur, wenn Sie den Cronjob per URL aufrufen müssen anstelle von dem Aufruf über die php cli. Konfigurieren Sie hier einen Sicherheitsschlüssel, den Sie über den GET-Parameter "secureKey" an den Aufruf des Cronjobs anfügen. Bsp.: https://YOUR-SHOP-URL-HERE/modules/fc/stripe/cron.php?secureKey=YOUR-SECURE-KEY', + 'HELP_SHOP_MODULE_sStripeCustomerEmailOverride' => 'Wenn diese Option aktiviert ist, überschreibt der Shop die Stripe-Kunden-E-Mail mit der im Konto des Shops angegebenen Adresse. Die Benachrichtigungen von Stripe werden an diese Adresse gesendet.', 'STRIPE_YES' => 'Ja', 'STRIPE_NO' => 'Nein', diff --git a/Application/views/admin_twig/en/stripe_lang.php b/Application/views/admin_twig/en/stripe_lang.php index 17e4efa..06022b8 100644 --- a/Application/views/admin_twig/en/stripe_lang.php +++ b/Application/views/admin_twig/en/stripe_lang.php @@ -38,6 +38,7 @@ 'SHOP_MODULE_sStripeCronSecureKey' => 'Cronjob secure key', 'SHOP_MODULE_GROUP_STRIPE_WEBHOOKS' => 'Webhooks', 'SHOP_MODULE_sStripeWebhookEndpoint' => 'Webhook Endpoint', + 'SHOP_MODULE_sStripeCustomerEmailOverride' => 'Replace customer email address with store address', 'HELP_SHOP_MODULE_sStripeTestKey' => 'Fill in your personal TEST private API key that will be used to set up the webhook endpoint.', 'HELP_SHOP_MODULE_sStripeLiveKey' => 'Fill in your personal LIVE private API key that will be used to set up the webhook endpoint.', @@ -52,6 +53,7 @@ 'HELP_SHOP_MODULE_sStripeCronSecondChanceActive' => 'For this cronjob to work, in addition to this checkbox you have to ensure that the Stripe cronjob is set up properly. You can find information on how to set up the cronjob in the README.md of this module.', 'HELP_SHOP_MODULE_sStripeCronOrderShipmentActive' => 'This cronjob is only needed if the shipping status in your shop is set by an external service and NOT by the "Ship Now" button. For this cronjob to work, in addition to this checkbox you have to ensure that the Stripe cronjob is set up properly. You can find information on how to set up the cronjob in the README.md of this module.', 'HELP_SHOP_MODULE_sStripeCronSecureKey' => 'This option is only needed if you have to call the cronjob via URL instead of the php cli. Configure your secure key here, which you have to add to the cronjob call as the GET parameter "secureKey". Example: https://YOUR-SHOP-URL-HERE/modules/fc/stripe/cron.php?secureKey=YOUR-SECURE-KEY', + 'HELP_SHOP_MODULE_sStripeCustomerEmailOverride' => 'With this option enabled the Shop will override the Stripe customer email with the address given in the shop\'s account. The notifications from Stripe will be sent to that address.', 'STRIPE_YES' => 'Yes', 'STRIPE_NO' => 'No', diff --git a/metadata.php b/metadata.php index 7cfb03c..06c10d5 100644 --- a/metadata.php +++ b/metadata.php @@ -64,6 +64,7 @@ ['group' => 'STRIPE_GENERAL', 'name' => 'blStripeLogTransactionInfo', 'type' => 'bool', 'value' => '1', 'position' => 34], ['group' => 'STRIPE_GENERAL', 'name' => 'blStripeRemoveByBillingCountry', 'type' => 'bool', 'value' => '1', 'position' => 35], ['group' => 'STRIPE_GENERAL', 'name' => 'blStripeRemoveByBasketCurrency', 'type' => 'bool', 'value' => '1', 'position' => 36], + ['group' => 'STRIPE_GENERAL', 'name' => 'sStripeCustomerEmailOverride', 'type' => 'bool', 'value' => '0', 'position' => 37], ['group' => 'STRIPE_STATUS_MAPPING', 'name' => 'sStripeStatusPending', 'type' => 'select', 'value' => '', 'position' => 50], ['group' => 'STRIPE_STATUS_MAPPING', 'name' => 'sStripeStatusProcessing', 'type' => 'select', 'value' => '', 'position' => 60], ['group' => 'STRIPE_STATUS_MAPPING', 'name' => 'sStripeStatusCancelled', 'type' => 'select', 'value' => '', 'position' => 70],