From 24998335e6750167ce62f81cf0b8ff537809bea4 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 12 Nov 2024 12:25:02 +0100 Subject: [PATCH 1/3] Display error when card is declined --- Application/translations/de/stripe_lang.php | 1 + Application/translations/en/stripe_lang.php | 1 + extend/Application/Controller/PaymentController.php | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Application/translations/de/stripe_lang.php b/Application/translations/de/stripe_lang.php index c6ba11c..7a393a9 100644 --- a/Application/translations/de/stripe_lang.php +++ b/Application/translations/de/stripe_lang.php @@ -36,6 +36,7 @@ 'STRIPE_ERROR_SOMETHING_WENT_WRONG' => 'Ein unbekannter Fehler ist aufgetreten', 'STRIPE_ERROR_ORDER_CANCELED' => 'Die Bezahlung wurde storniert, bitte versuchen Sie es erneut', 'STRIPE_ERROR_ORDER_FAILED' => 'Die Bezahlung ist fehlgeschlagen, bitte versuchen Sie es erneut', + 'STRIPE_ERROR_CARD_DECLINED' => 'Kartenzahlung abgelehnt', 'STRIPE_SECOND_CHANCE_MAIL_SUBJECT' => 'Abschluss Ihrer Bestellung bei', 'STRIPE_ERROR_ORDER_CONFIG_PUBKEY' => 'Bitte konfigurieren Sie den veröffentlichbaren Stripe-Schlüssel, um diese Zahlungsmethode zu verwenden.', 'STRIPE_WEBHOOK_CREATE_ERROR' => 'Der Webhook-Endpunkt konnte nicht erstellt werden.', diff --git a/Application/translations/en/stripe_lang.php b/Application/translations/en/stripe_lang.php index ddce621..792b006 100644 --- a/Application/translations/en/stripe_lang.php +++ b/Application/translations/en/stripe_lang.php @@ -36,6 +36,7 @@ 'STRIPE_ERROR_SOMETHING_WENT_WRONG' => 'An unknown error occured', 'STRIPE_ERROR_ORDER_CANCELED' => 'Payment was canceled, please try again', 'STRIPE_ERROR_ORDER_FAILED' => 'Payment failed, please try again', + 'STRIPE_ERROR_CARD_DECLINED' => 'Payment failed, card was declined', 'STRIPE_SECOND_CHANCE_MAIL_SUBJECT' => 'Completion of your order at', 'STRIPE_ERROR_ORDER_CONFIG_PUBKEY' => 'Please configure Stripe publishable key to use this payment method.', 'STRIPE_WEBHOOK_CREATE_ERROR' => 'The Webhook Endpoint could not be created.', diff --git a/extend/Application/Controller/PaymentController.php b/extend/Application/Controller/PaymentController.php index 1a1f470..7152ee3 100644 --- a/extend/Application/Controller/PaymentController.php +++ b/extend/Application/Controller/PaymentController.php @@ -11,6 +11,7 @@ use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Core\Registry; +use Stripe\Exception\CardException; class PaymentController extends PaymentController_parent { @@ -145,7 +146,17 @@ public function validatepayment() Registry::getSession()->setVariable('stripe_current_payment_method_id', $oPaymentMethod->id); } } - } catch (\Exception $oEx) { + } + catch (CardException $stripeCardException){ + Registry::getLogger()->error($stripeCardException->getTraceAsString()); + + if("card_declined" === $stripeCardException->getStripeCode()){ + Registry::getUtilsView()->addErrorToDisplay('STRIPE_ERROR_CARD_DECLINED'); + } + + $mRet = 'payment'; + } + catch (\Exception $oEx) { Registry::getLogger()->error($oEx->getTraceAsString()); $mRet = 'payment'; } From db318ff4cdf1ed51dd10adc469bc1bfdd64dc41d Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 14 Nov 2024 13:11:28 +0100 Subject: [PATCH 2/3] optimize translation --- Application/translations/de/stripe_lang.php | 2 +- Application/translations/en/stripe_lang.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Application/translations/de/stripe_lang.php b/Application/translations/de/stripe_lang.php index 7a393a9..fe92630 100644 --- a/Application/translations/de/stripe_lang.php +++ b/Application/translations/de/stripe_lang.php @@ -36,7 +36,7 @@ 'STRIPE_ERROR_SOMETHING_WENT_WRONG' => 'Ein unbekannter Fehler ist aufgetreten', 'STRIPE_ERROR_ORDER_CANCELED' => 'Die Bezahlung wurde storniert, bitte versuchen Sie es erneut', 'STRIPE_ERROR_ORDER_FAILED' => 'Die Bezahlung ist fehlgeschlagen, bitte versuchen Sie es erneut', - 'STRIPE_ERROR_CARD_DECLINED' => 'Kartenzahlung abgelehnt', + 'STRIPE_ERROR_CARD_DECLINED' => 'Die Zahlung ist fehlgeschlagen, da Ihre Karte abgelehnt wurde. Bitte versuchen Sie es mit einer anderen Karte oder einer anderen Zahlart.', 'STRIPE_SECOND_CHANCE_MAIL_SUBJECT' => 'Abschluss Ihrer Bestellung bei', 'STRIPE_ERROR_ORDER_CONFIG_PUBKEY' => 'Bitte konfigurieren Sie den veröffentlichbaren Stripe-Schlüssel, um diese Zahlungsmethode zu verwenden.', 'STRIPE_WEBHOOK_CREATE_ERROR' => 'Der Webhook-Endpunkt konnte nicht erstellt werden.', diff --git a/Application/translations/en/stripe_lang.php b/Application/translations/en/stripe_lang.php index 792b006..fd2a44e 100644 --- a/Application/translations/en/stripe_lang.php +++ b/Application/translations/en/stripe_lang.php @@ -36,7 +36,7 @@ 'STRIPE_ERROR_SOMETHING_WENT_WRONG' => 'An unknown error occured', 'STRIPE_ERROR_ORDER_CANCELED' => 'Payment was canceled, please try again', 'STRIPE_ERROR_ORDER_FAILED' => 'Payment failed, please try again', - 'STRIPE_ERROR_CARD_DECLINED' => 'Payment failed, card was declined', + 'STRIPE_ERROR_CARD_DECLINED' => 'The payment failed because your card was declined. Please try with a different card or payment method.', 'STRIPE_SECOND_CHANCE_MAIL_SUBJECT' => 'Completion of your order at', 'STRIPE_ERROR_ORDER_CONFIG_PUBKEY' => 'Please configure Stripe publishable key to use this payment method.', 'STRIPE_WEBHOOK_CREATE_ERROR' => 'The Webhook Endpoint could not be created.', From 9e9abaf5a9317490552a047a14426719721b5964 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 14 Nov 2024 13:11:49 +0100 Subject: [PATCH 3/3] changelog & Version --- CHANGELOG.md | 6 ++++++ metadata.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b9f0ef..cf6aa2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.0.6] - 2024-11-15 + +### Fixed + +- [0007731](https://bugs.oxid-esales.com/view.php?id=7731): If a credit card is declined, the payment page throws now a error-message instead of only reload the page + ## [1.0.5] - 2024-09-20 ### Fixed diff --git a/metadata.php b/metadata.php index 06d48fd..36df01c 100644 --- a/metadata.php +++ b/metadata.php @@ -57,7 +57,7 @@ 'en' => 'This module integrates STRIPE as payment provider in your OXID Shop.', ], 'thumbnail' => 'stripe_logo.png', - 'version' => '1.0.5', + 'version' => '1.0.6', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com',