From 1625ea68ec98142d8b7f5abb60e1dd3f85ce92c7 Mon Sep 17 00:00:00 2001 From: Alexandra Usacheva Date: Mon, 9 Apr 2018 19:31:29 +0300 Subject: [PATCH] FE-588: error mapping (#231) --- src/app/backend/model/event/payment-status-changed.ts | 4 ++-- src/app/backend/model/index.ts | 1 + src/app/backend/model/payment-error.ts | 4 ++++ src/app/backend/model/payment.ts | 4 ++-- .../make-content/get-failed-description.tsx | 9 ++++----- .../result-form/make-content/make-content-error.ts | 4 ++-- .../make-content/make-from-payment-change.tsx | 4 ++-- .../form-container/result-form/result-form-props.ts | 2 +- src/locale/en.json | 10 ++++++++-- src/locale/ru.json | 10 ++++++++-- 10 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 src/app/backend/model/payment-error.ts diff --git a/src/app/backend/model/event/payment-status-changed.ts b/src/app/backend/model/event/payment-status-changed.ts index ebcef8b7..5e609fc9 100644 --- a/src/app/backend/model/event/payment-status-changed.ts +++ b/src/app/backend/model/event/payment-status-changed.ts @@ -1,6 +1,6 @@ import { InvoiceChange } from './invoice-change'; -import { LogicError } from '../logic-error'; import { InvoiceChangeType } from './invoice-change-type'; +import { PaymentError } from 'checkout/backend'; export enum PaymentStatuses { processed = 'processed', @@ -15,5 +15,5 @@ export class PaymentStatusChanged extends InvoiceChange { changeType = InvoiceChangeType.PaymentStatusChanged; status: PaymentStatuses; paymentID: string; - error: LogicError; + error: PaymentError; } diff --git a/src/app/backend/model/index.ts b/src/app/backend/model/index.ts index 69ee824a..5844f15c 100644 --- a/src/app/backend/model/index.ts +++ b/src/app/backend/model/index.ts @@ -22,3 +22,4 @@ export * from './payment'; export * from './payment-params'; export * from './event/user-interaction'; export * from './logic-error'; +export * from './payment-error'; diff --git a/src/app/backend/model/payment-error.ts b/src/app/backend/model/payment-error.ts new file mode 100644 index 00000000..972f9b11 --- /dev/null +++ b/src/app/backend/model/payment-error.ts @@ -0,0 +1,4 @@ +export class PaymentError { + code: string; + subError?: PaymentError; +} diff --git a/src/app/backend/model/payment.ts b/src/app/backend/model/payment.ts index d03ef825..eea7e1fb 100644 --- a/src/app/backend/model/payment.ts +++ b/src/app/backend/model/payment.ts @@ -1,7 +1,7 @@ import { PaymentFlow } from './payment-flow'; import { Payer } from './payer'; -import { LogicError } from './logic-error'; import { PaymentStatus } from './payment-status'; +import { PaymentError } from 'checkout/backend'; export class Payment { id: string; @@ -12,5 +12,5 @@ export class Payment { flow: PaymentFlow; payer: Payer; status: PaymentStatus; - error: LogicError; + error: PaymentError; } diff --git a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/get-failed-description.tsx b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/get-failed-description.tsx index 13722032..3f4e9a7c 100644 --- a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/get-failed-description.tsx +++ b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/get-failed-description.tsx @@ -1,13 +1,12 @@ import * as React from 'react'; import { Locale } from 'checkout/locale'; import * as styles from '../result-form.scss'; -import { LogicError } from 'checkout/backend/model'; +import { PaymentError } from 'checkout/backend'; -export const getFailedDescription = (l: Locale, e: LogicError): JSX.Element => { - if (!e && !(e.code || e.message)) { +export const getFailedDescription = (l: Locale, e: PaymentError): JSX.Element => { + if (!e && !e.code) { return; } const localized = l[e.code]; - const message = e.message ? e.message : l['Unknown Failure']; - return

{localized ? localized : message}

; + return

{localized ? localized : e.code}

; }; diff --git a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-content-error.ts b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-content-error.ts index c996c551..01e79e1e 100644 --- a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-content-error.ts +++ b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-content-error.ts @@ -1,6 +1,6 @@ import { Locale } from 'checkout/locale'; import { failed } from './make-from-payment-change'; -import { LogicError } from 'checkout/backend'; +import { PaymentError } from 'checkout/backend'; import { ResultFormContent } from './result-form-content'; -export const makeContentError = (l: Locale, error: LogicError): ResultFormContent => failed(l, error); +export const makeContentError = (l: Locale, error: PaymentError): ResultFormContent => failed(l, error); diff --git a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-from-payment-change.tsx b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-from-payment-change.tsx index 8509bd7d..6d7c8424 100644 --- a/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-from-payment-change.tsx +++ b/src/app/components/app/modal-container/modal/form-container/result-form/make-content/make-from-payment-change.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import { Locale } from 'checkout/locale'; -import { Event, LogicError, PaymentStatusChanged, PaymentStatuses } from 'checkout/backend'; +import { Event, LogicError, PaymentError, PaymentStatusChanged, PaymentStatuses } from 'checkout/backend'; import { ResultFormContent } from './result-form-content'; import { getFailedDescription } from './get-failed-description'; import { getSuccessDescription } from './get-success-description'; import { Checkmark, Cross } from '../result-icons'; import { getLastChange } from 'checkout/utils'; -export const failed = (l: Locale, e: LogicError): ResultFormContent => ({ +export const failed = (l: Locale, e: PaymentError | LogicError): ResultFormContent => ({ hasActions: true, hasDone: false, header: l['form.header.final.failed.label'], diff --git a/src/app/components/app/modal-container/modal/form-container/result-form/result-form-props.ts b/src/app/components/app/modal-container/modal/form-container/result-form/result-form-props.ts index 17654fe3..60160b70 100644 --- a/src/app/components/app/modal-container/modal/form-container/result-form/result-form-props.ts +++ b/src/app/components/app/modal-container/modal/form-container/result-form/result-form-props.ts @@ -1,6 +1,6 @@ import { Locale } from 'checkout/locale'; import { ModelState, ResultState, ResultFormInfo } from 'checkout/state'; -import { LogicError } from 'checkout/backend'; +import { LogicError, PaymentError } from 'checkout/backend'; import { IntegrationType } from 'checkout/config'; export interface ResultFormProps { diff --git a/src/locale/en.json b/src/locale/en.json index bc844c0a..8f4b4a45 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -86,5 +86,11 @@ "form.pay.terminals.step.four.text": "Pay with cash", "form.pay.terminals.step.five.text": "Don’t forget the receipt", "form.pay.terminals.info.text": "An account number will be generated for payment through the payment kiosks", - "brand.euroset": "Euroset" -} \ No newline at end of file + "brand.euroset": "Euroset", + "InvalidPaymentTool": "Invalid payment tool", + "AccountLimitsExceeded": "Account limits exceeded", + "InsufficientFunds": "Insufficient funds", + "PreauthorizationFailed": "Preauthorization failed", + "RejectedByIssuer": "Rejected by issuer", + "PaymentRejected": "Payment rejected" +} diff --git a/src/locale/ru.json b/src/locale/ru.json index 18e81bcc..8af0c78d 100644 --- a/src/locale/ru.json +++ b/src/locale/ru.json @@ -86,5 +86,11 @@ "form.pay.terminals.step.four.text": "Внесите наличные", "form.pay.terminals.step.five.text": "Обязательно возьмите чек", "form.pay.terminals.info.text": "Будет сформирован номер счета для оплаты через платежный терминал", - "brand.euroset": "Евросеть" -} \ No newline at end of file + "brand.euroset": "Евросеть", + "InvalidPaymentTool": "Недопустимое средство оплаты", + "AccountLimitsExceeded": "Превышен лимит", + "InsufficientFunds": "Недостаточно средств", + "PreauthorizationFailed": "Неудачная преавторизиция", + "RejectedByIssuer": "Отклонено эмитентом", + "PaymentRejected": "Платёж отклонен" +}