Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display error when card is declined #31

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Application/translations/de/stripe_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '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.',
Expand Down
1 change: 1 addition & 0 deletions Application/translations/en/stripe_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '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.',
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion extend/Application/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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';
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
Expand Down