Skip to content

Commit

Permalink
Display error when card is declined
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Sosnowski committed Nov 12, 2024
1 parent 703bf8d commit 2499833
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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' => '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.',
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' => '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.',
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

0 comments on commit 2499833

Please sign in to comment.