Skip to content

Commit

Permalink
fix: display error message for duplicate payment instruments on check…
Browse files Browse the repository at this point in the history
…out payment page
  • Loading branch information
SGrueber committed Oct 27, 2020
1 parent 35c85ce commit 31cfbab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/core/configuration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { environment } from '../../environments/environment';

import * as injectionKeys from './configurations/injection-keys';
import { SPECIAL_HTTP_ERROR_HANDLER } from './interceptors/icm-error-mapper.interceptor';
import { createPaymentErrorHandler } from './utils/http-error/create-payment.error-handler';
import { editPasswordErrorHandler } from './utils/http-error/edit-password.error-handler';
import { LoginUserErrorHandler } from './utils/http-error/login-user.error-handler';
import { requestReminderErrorHandler } from './utils/http-error/request-reminder.error-handler';
Expand All @@ -30,6 +31,7 @@ import { updatePasswordErrorHandler } from './utils/http-error/update-password.e
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useClass: LoginUserErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: requestReminderErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: editPasswordErrorHandler, multi: true },
{ provide: SPECIAL_HTTP_ERROR_HANDLER, useValue: createPaymentErrorHandler, multi: true },
],
})
export class ConfigurationModule {}
10 changes: 10 additions & 0 deletions src/app/core/utils/http-error/create-payment.error-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { SpecialHttpErrorHandler } from 'ish-core/interceptors/icm-error-mapper.interceptor';

export const createPaymentErrorHandler: SpecialHttpErrorHandler = {
test: (error, request) => error.url.endsWith('/payments') && request.method === 'POST',
map: error => {
if (error?.error && error.error.includes('{') && error.error.includes('}')) {
return { code: error.error.slice(error.error.indexOf('{') + 1, error.error.lastIndexOf('}')) };
}
},
};
1 change: 1 addition & 0 deletions src/assets/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@
"order.number.label": "Bestellnummer:",
"order.tracking.error": "Leider konnte keine Bestellung mit Ihren Daten gefunden werden.",
"order_template.create.heading": "Bestellvorlage anlegen",
"payment.error.PaymentInstrumentAlreadyExists": "Ein Zahlungsmittel mit den angegebenen Parametern existiert bereits.",
"product.add_to_cart.link": "In den Warenkorb",
"product.add_to_cart.retailset.link": "Artikel in den Warenkorb legen",
"product.add_to_wishlist.link": "Auf die Wunschliste",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@
"order.number.label": "Order Number:",
"order.tracking.error": "Unfortunately, we could not locate an order with the information you provided.",
"order_template.create.heading": "Create Order Template",
"payment.error.PaymentInstrumentAlreadyExists": "A payment instrument with the given parameters already exists",
"product.add_to_cart.link": "Add to Cart",
"product.add_to_cart.retailset.link": "Add item(s) to Cart",
"product.add_to_wishlist.link": "Add to Wish List",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@
"order.number.label": "Numéro de commande :",
"order.tracking.error": "Malheureusement, nous n’avons pas pu localiser de commande avec les informations que vous nous avez fournies.",
"order_template.create.heading": "Créer un modèle de commande",
"payment.error.PaymentInstrumentAlreadyExists": "L’instrument de paiement avec les paramètres donnés existe déjà.",
"product.add_to_cart.link": "Ajouter au panier",
"product.add_to_cart.retailset.link": "Ajouter les articles au panier",
"product.add_to_wishlist.link": "Ajouter à la liste de souhaits",
Expand Down

0 comments on commit 31cfbab

Please sign in to comment.