mirror of
https://github.com/valitydev/koffing.git
synced 2024-11-06 09:15:20 +00:00
FE-589: added error mapping for payments (#201)
This commit is contained in:
parent
b543b0bd38
commit
92c8e39bb4
@ -33,6 +33,7 @@ export * from './payment-method-stat';
|
|||||||
export * from './payment-rate-stat';
|
export * from './payment-rate-stat';
|
||||||
export * from './payment-revenue-stat';
|
export * from './payment-revenue-stat';
|
||||||
export * from './payment-search-result';
|
export * from './payment-search-result';
|
||||||
|
export * from './payment-error';
|
||||||
export * from './payout';
|
export * from './payout';
|
||||||
export * from './report';
|
export * from './report';
|
||||||
export * from './revenue';
|
export * from './revenue';
|
||||||
|
4
src/app/backend/model/payment-error.ts
Normal file
4
src/app/backend/model/payment-error.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export class PaymentError {
|
||||||
|
public code: string;
|
||||||
|
public subError?: PaymentError;
|
||||||
|
}
|
42
src/app/invoice/payments/payment-details/errors.json
Normal file
42
src/app/invoice/payments/payment-details/errors.json
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"rejected_by_inspector": "Отклонено сервисом противодействия мошенничеству",
|
||||||
|
"preauthorization_failed": "Ошибка предавторизации (3DS)",
|
||||||
|
"authorization_failed": {
|
||||||
|
"message": "Ошибка авторизации платежа у провайдера",
|
||||||
|
"unknown": "Неизвестная ошибка авторизации",
|
||||||
|
"merchant_blocked": "Мерчант заблокирован",
|
||||||
|
"operation_blocked": "Операция платежа заблокирована",
|
||||||
|
"account_not_found": "Аккаунт не найден",
|
||||||
|
"account_blocked": "Аккаунт заблокирован",
|
||||||
|
"account_stolen": "Аккаунт украден",
|
||||||
|
"insufficient_funds": "Не хватает средств",
|
||||||
|
"account_limit_exceeded": {
|
||||||
|
"message": "Превышен лимит на счете плательщика",
|
||||||
|
"unknown": "Объект лимита неизвестен",
|
||||||
|
"amount": "Лимит на сумму",
|
||||||
|
"number": "Лимит на количество попыток"
|
||||||
|
},
|
||||||
|
"provider_limit_exceeded": {
|
||||||
|
"message": "Превышен лимит на мерчанта у провайдера (вас или платформы RBKmoney)",
|
||||||
|
"unknown": "Объект лимита неизвестен",
|
||||||
|
"amount": "Лимит на сумму",
|
||||||
|
"number": "Лимит на количество попыток"
|
||||||
|
},
|
||||||
|
"payment_tool_rejected": {
|
||||||
|
"message": "Платёжный интрумент отклонён",
|
||||||
|
"unknown": "Неизвестный платёжный интрумент",
|
||||||
|
"bank_card_rejected": {
|
||||||
|
"message": "Банковская карта отклонена",
|
||||||
|
"unknown": "Причина неизвестна",
|
||||||
|
"card_number_invalid": "Неверный номер карты",
|
||||||
|
"card_expired": "Истёк срок действия карты",
|
||||||
|
"card_holder_invalid": "Неверный владелец карты",
|
||||||
|
"cvv_invalid": "Неверный CVV код",
|
||||||
|
"issuer_not_found": "Эмитент не найден"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"security_policy_violated": "Нарушения политики безопасности",
|
||||||
|
"temporarily_unavailable": "Временная недоступность третьих сторон",
|
||||||
|
"rejected_by_issuer": "Отклонено эмитентом"
|
||||||
|
}
|
||||||
|
}
|
@ -36,7 +36,7 @@ form.form-horizontal.form-label-left.css-form
|
|||||||
.form-group
|
.form-group
|
||||||
label.col-sm-5 Сообщение об ошибке:
|
label.col-sm-5 Сообщение об ошибке:
|
||||||
.col-sm-7
|
.col-sm-7
|
||||||
div {{payment.error?.message}}
|
div {{getMessage(payment.error)}}
|
||||||
div(*ngIf="isFlowInformationAvailable(payment)")
|
div(*ngIf="isFlowInformationAvailable(payment)")
|
||||||
.row
|
.row
|
||||||
.col-xs-12
|
.col-xs-12
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
import { Component, Input, OnChanges } from '@angular/core';
|
import { Component, Input, OnChanges } from '@angular/core';
|
||||||
|
import { get } from 'lodash';
|
||||||
|
|
||||||
import { Payment } from 'koffing/backend/model/payment/payment';
|
|
||||||
import { PAYMENT_STATUS } from 'koffing/backend';
|
|
||||||
import { CustomerService } from 'koffing/backend/customer.service';
|
import { CustomerService } from 'koffing/backend/customer.service';
|
||||||
import { Customer } from 'koffing/backend/model/customer';
|
import {
|
||||||
import { CustomerPayer } from 'koffing/backend/model/payer/customer-payer';
|
PAYMENT_STATUS,
|
||||||
|
Customer,
|
||||||
|
CustomerPayer,
|
||||||
|
PaymentError,
|
||||||
|
Payment
|
||||||
|
} from 'koffing/backend';
|
||||||
|
import * as errors from './errors.json';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'kof-payment-details',
|
selector: 'kof-payment-details',
|
||||||
@ -17,7 +22,8 @@ export class PaymentDetailsComponent implements OnChanges {
|
|||||||
|
|
||||||
public customer: Customer;
|
public customer: Customer;
|
||||||
|
|
||||||
constructor(private customerService: CustomerService) {}
|
constructor(private customerService: CustomerService) {
|
||||||
|
}
|
||||||
|
|
||||||
public ngOnChanges() {
|
public ngOnChanges() {
|
||||||
if (this.payment && this.payment.payer.payerType === 'CustomerPayer') {
|
if (this.payment && this.payment.payer.payerType === 'CustomerPayer') {
|
||||||
@ -37,4 +43,19 @@ export class PaymentDetailsComponent implements OnChanges {
|
|||||||
'label-danger': status === PAYMENT_STATUS.failed
|
'label-danger': status === PAYMENT_STATUS.failed
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getMessage(paymentError: PaymentError) {
|
||||||
|
return this.mapErrors(paymentError, errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapErrors(error: PaymentError, dictionary: any, acc: string = ''): string {
|
||||||
|
const {code} = error;
|
||||||
|
const key = dictionary ? dictionary[code] : code;
|
||||||
|
if (error.subError) {
|
||||||
|
const message = get(key, 'message') ? key.message : code;
|
||||||
|
return this.mapErrors(error.subError, key, acc.concat(acc === '' ? message : ` -> ${message}`));
|
||||||
|
} else {
|
||||||
|
return acc === '' ? key : `${acc} -> ${key}.`;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
4
src/app/invoice/payments/payment-details/typings.d.ts
vendored
Normal file
4
src/app/invoice/payments/payment-details/typings.d.ts
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
declare module '*.json' {
|
||||||
|
const value: any;
|
||||||
|
export default value;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user