From 2e6ff466c5221220b90a08911d204025001f9793 Mon Sep 17 00:00:00 2001
From: PJaneta
Date: Thu, 19 Sep 2024 11:17:34 +0200
Subject: [PATCH] AD-282 Improve Error Handling and User Guidance for Payment
Transactions - fixes
---
.../assets/translations/en/payment-errors.ts | 51 +++++++++++--------
.../lib/assets/translations/translations.ts | 5 +-
.../src/lib/service/adyen-order.service.ts | 6 ++-
3 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/projects/adyen-payments/src/lib/assets/translations/en/payment-errors.ts b/projects/adyen-payments/src/lib/assets/translations/en/payment-errors.ts
index 1d4aa66..9548c7d 100644
--- a/projects/adyen-payments/src/lib/assets/translations/en/payment-errors.ts
+++ b/projects/adyen-payments/src/lib/assets/translations/en/payment-errors.ts
@@ -1,27 +1,38 @@
export const paymentErrors = {
- "checkout": {
- "error": {
- "authorization": {
- "payment": {
- "refused": "The payment is REFUSED.",
- "detail": {
- "not": {
- "found": "The payment is REFUSED because the saved card is removed. Please try an other payment method."
+ "adyenPlaceOrderError":{
+ "checkout": {
+ "error": {
+ "authorization": {
+ "payment": {
+ "refused": "The payment is REFUSED.",
+ "detail": {
+ "not": {
+ "found": "The payment is REFUSED because the saved card is removed. Please try an other payment method."
+ }
+ }
+ },
+ "restricted": {
+ "card": "The card is restricted."
+ },
+ "failed": "There was an internal technical error, please choose any other payment method to place your order. If the error persist, please contact us.",
+ "cvc": {
+ "declined": "The payment is REFUSED. Please check your Card details."
+ },
+ "pos": {
+ "configuration": "Error reaching POS terminal. Check the terminal connection/configuration and try again."
+ },
+ "transaction": {
+ "not": {
+ "permitted": "The transaction is not permitted."
+ }
+ }
+ },
+ "paymentethod": {
+ "formentry": {
+ "invalid": "Please check your payment details are correct or provide a different payment method."
}
- }
- },
- "restricted": {
- "card": "The card is restricted."
- },
- "cvc": {
- "declined": "The payment is REFUSED. Please check your Card details."
- },
- "transaction": {
- "not": {
- "permitted": "The transaction is not permitted."
}
}
}
}
}
-}
diff --git a/projects/adyen-payments/src/lib/assets/translations/translations.ts b/projects/adyen-payments/src/lib/assets/translations/translations.ts
index 93c6443..c5070b3 100644
--- a/projects/adyen-payments/src/lib/assets/translations/translations.ts
+++ b/projects/adyen-payments/src/lib/assets/translations/translations.ts
@@ -1,6 +1,9 @@
import {TranslationChunksConfig, TranslationResources} from "@spartacus/core";
import {en} from "./en";
+export const errorCodePrefix: string = "adyenPlaceOrderError";
+
+
export const adyenCheckoutTranslations: TranslationResources = {
en,
};
@@ -10,6 +13,6 @@ export const adyenCheckoutTranslationChunksConfig: TranslationChunksConfig = {
'adyenCheckout'
],
paymentErrors: [
- 'checkout'
+ errorCodePrefix
]
}
diff --git a/projects/adyen-payments/src/lib/service/adyen-order.service.ts b/projects/adyen-payments/src/lib/service/adyen-order.service.ts
index 9ef4802..19b86a5 100644
--- a/projects/adyen-payments/src/lib/service/adyen-order.service.ts
+++ b/projects/adyen-payments/src/lib/service/adyen-order.service.ts
@@ -18,11 +18,13 @@ import {ActiveCartFacade} from '@spartacus/cart/base/root';
import {AddressData, PlaceOrderRequest, PlaceOrderResponse} from "../core/models/occ.order.models";
import {HttpErrorResponse} from "@angular/common/http";
import {AdditionalDetailsConnector} from "../core/connectors/additional-details.connector";
+import {errorCodePrefix} from "../assets/translations/translations";
@Injectable()
export class AdyenOrderService extends OrderService {
private messageTimeout: number = 20000;
+ private placeOrderErrorCodePrefix: string = errorCodePrefix + '.';
constructor(protected placeOrderConnector: PlaceOrderConnector,
protected additionalDetailsConnector: AdditionalDetailsConnector,
@@ -61,7 +63,7 @@ export class AdyenOrderService extends OrderService {
return {...response, success: true}
}),
catchError((error: HttpErrorResponse) => {
- this.translationService.translate(error.error.errorCode).subscribe((message) => {
+ this.translationService.translate(this.placeOrderErrorCodePrefix + error.error.errorCode).subscribe((message) => {
this.globalMessageService.add(message, GlobalMessageType.MSG_TYPE_ERROR, this.messageTimeout);
})
@@ -108,7 +110,7 @@ export class AdyenOrderService extends OrderService {
return {...response, success: true}
}),
catchError((error: HttpErrorResponse) => {
- this.translationService.translate(error.error.errorCode).subscribe((message) => {
+ this.translationService.translate(this.placeOrderErrorCodePrefix + error.error.errorCode).subscribe((message) => {
this.globalMessageService.add(message, GlobalMessageType.MSG_TYPE_ERROR, this.messageTimeout);
})