FE-588: error mapping (#231)

This commit is contained in:
Alexandra Usacheva 2018-04-09 19:31:29 +03:00 committed by GitHub
parent ccc5a0c374
commit 1625ea68ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 34 additions and 18 deletions

View File

@ -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;
}

View File

@ -22,3 +22,4 @@ export * from './payment';
export * from './payment-params';
export * from './event/user-interaction';
export * from './logic-error';
export * from './payment-error';

View File

@ -0,0 +1,4 @@
export class PaymentError {
code: string;
subError?: PaymentError;
}

View File

@ -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;
}

View File

@ -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 <p className={styles.text}>{localized ? localized : message}</p>;
return <p className={styles.text}>{localized ? localized : e.code}</p>;
};

View File

@ -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);

View File

@ -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'],

View File

@ -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 {

View File

@ -86,5 +86,11 @@
"form.pay.terminals.step.four.text": "Pay with cash",
"form.pay.terminals.step.five.text": "Dont forget the receipt",
"form.pay.terminals.info.text": "An account number will be generated for payment through the payment kiosks",
"brand.euroset": "Euroset"
"brand.euroset": "Euroset",
"InvalidPaymentTool": "Invalid payment tool",
"AccountLimitsExceeded": "Account limits exceeded",
"InsufficientFunds": "Insufficient funds",
"PreauthorizationFailed": "Preauthorization failed",
"RejectedByIssuer": "Rejected by issuer",
"PaymentRejected": "Payment rejected"
}

View File

@ -86,5 +86,11 @@
"form.pay.terminals.step.four.text": "Внесите наличные",
"form.pay.terminals.step.five.text": "Обязательно возьмите чек",
"form.pay.terminals.info.text": "Будет сформирован номер счета для оплаты через платежный терминал",
"brand.euroset": "Евросеть"
"brand.euroset": "Евросеть",
"InvalidPaymentTool": "Недопустимое средство оплаты",
"AccountLimitsExceeded": "Превышен лимит",
"InsufficientFunds": "Недостаточно средств",
"PreauthorizationFailed": "Неудачная преавторизиция",
"RejectedByIssuer": "Отклонено эмитентом",
"PaymentRejected": "Платёж отклонен"
}