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

Enhanced declined processing payment errors. Handling types: #34

Merged
merged 1 commit into from
Nov 21, 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
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