Skip to content

Commit

Permalink
Merge pull request #34 from OXID-eSales/STRIP-45-erros-rendering-ench…
Browse files Browse the repository at this point in the history
…anced

Enhanced declined processing payment errors. Handling types:
  • Loading branch information
mariolorenz authored Nov 21, 2024
2 parents b451d46 + d86b74e commit 2b79f82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Application/translations/de/stripe_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
'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_ERROR_CARD_EXPIRED' => 'Die Zahlung ist fehlgeschlagen, da Ihre Karte abgelaufen ist. Bitte verwenden Sie eine andere Karte oder Zahlungsmethode.',
'STRIPE_ERROR_INCORRECT_CVC' => 'Die Zahlung ist fehlgeschlagen, da der CVC-Code inkorrekt ist. Bitte korrigieren Sie den Code und versuchen Sie es erneut oder nutzen Sie eine andere Karte bzw. Zahlungsmethode.',
'STRIPE_ERROR_PROCESSING_ERROR' => 'Die Zahlung ist fehlgeschlagen. Bitte versuchen Sie es mit einer anderen Karte oder Zahlungsmethode.',
'STRIPE_ERROR_INCORRECT_NUMBER' => 'Die Zahlung ist fehlgeschlagen, da Ihre Kartennummer inkorrekt ist. Bitte verwenden Sie eine andere Karte oder Zahlungsmethode.',
'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
4 changes: 4 additions & 0 deletions Application/translations/en/stripe_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
'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_ERROR_CARD_EXPIRED' => 'The payment failed because your card is expired. Please try with a different card or payment method.',
'STRIPE_ERROR_INCORRECT_CVC' => 'The payment failed because CVC code is incorrect. Please correct and try again or use different card or payment method.',
'STRIPE_ERROR_PROCESSING_ERROR' => 'The payment failed. Please try with a different card or payment method.',
'STRIPE_ERROR_INCORRECT_NUMBER' => 'The payment failed because your card number is incorrect. 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
17 changes: 12 additions & 5 deletions extend/Application/Controller/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,19 @@ public function validatepayment()
}
}
catch (CardException $stripeCardException){
$errors = [
'card_declined' => 'STRIPE_ERROR_CARD_DECLINED',
'expired_card' => 'STRIPE_ERROR_CARD_EXPIRED',
'incorrect_cvc' => 'STRIPE_ERROR_INCORRECT_CVC',
'processing_error' => 'STRIPE_ERROR_PROCESSING_ERROR',
'incorrect_number' => 'STRIPE_ERROR_INCORRECT_NUMBER'
];
//use specific error translation ident or card_declined as default
$errorTranslationIdent = isset($errors[$stripeCardException->getStripeCode()]) ?
$errors[$stripeCardException->getStripeCode()] : $errors['card_declined'];

Registry::getUtilsView()->addErrorToDisplay($errorTranslationIdent);
Registry::getLogger()->error($stripeCardException->getTraceAsString());

if("card_declined" === $stripeCardException->getStripeCode()){
Registry::getUtilsView()->addErrorToDisplay('STRIPE_ERROR_CARD_DECLINED');
}

$mRet = 'payment';
}
catch (\Exception $oEx) {
Expand Down

0 comments on commit 2b79f82

Please sign in to comment.