Skip to content

Commit

Permalink
AD-282
Browse files Browse the repository at this point in the history
Improve Error Handling and User Guidance for Payment Transactions - fixes
  • Loading branch information
pjaneta committed Sep 19, 2024
1 parent 829a17c commit 2e6ff46
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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."
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {TranslationChunksConfig, TranslationResources} from "@spartacus/core";
import {en} from "./en";

export const errorCodePrefix: string = "adyenPlaceOrderError";


export const adyenCheckoutTranslations: TranslationResources = {
en,
};
Expand All @@ -10,6 +13,6 @@ export const adyenCheckoutTranslationChunksConfig: TranslationChunksConfig = {
'adyenCheckout'
],
paymentErrors: [
'checkout'
errorCodePrefix
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
})

Expand Down Expand Up @@ -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);
})

Expand Down

0 comments on commit 2e6ff46

Please sign in to comment.