From f93c6c30ad2513151ae385e03b3d157cd5ce8450 Mon Sep 17 00:00:00 2001 From: Alexandra Usacheva Date: Wed, 14 Feb 2018 18:07:48 +0300 Subject: [PATCH] FE-540: added qiwi support (#188) --- src/app/backend/constants/payment-method.ts | 3 +- src/app/backend/model/payment-method/index.ts | 1 + .../payment-method/payment-method-wallets.ts | 11 ++++++ .../checkout-config-form.component.pug | 22 +++--------- .../checkout-config-form.component.ts | 36 ++++++++++++++----- .../checkout-config-form.service.ts | 7 ++-- .../payment-link/payment-link-arguments.ts | 1 + .../payment-link/payment-link.service.ts | 1 + .../payment-details.component.pug | 15 ++++++++ .../payment-tool-details-type.pipe.ts | 3 +- .../payment-details/provider-name.pipe.ts | 1 + src/app/invoices/payment-method-label.ts | 3 +- tslint.json | 3 +- 13 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 src/app/backend/model/payment-method/payment-method-wallets.ts diff --git a/src/app/backend/constants/payment-method.ts b/src/app/backend/constants/payment-method.ts index 1691e09..c3bcd39 100644 --- a/src/app/backend/constants/payment-method.ts +++ b/src/app/backend/constants/payment-method.ts @@ -1,4 +1,5 @@ export const PAYMENT_METHOD = { bankCard: 'bankCard', - paymentTerminal: 'paymentTerminal' + paymentTerminal: 'paymentTerminal', + digitalWallet: 'digitalWallet' }; diff --git a/src/app/backend/model/payment-method/index.ts b/src/app/backend/model/payment-method/index.ts index b1c65b8..6db268f 100644 --- a/src/app/backend/model/payment-method/index.ts +++ b/src/app/backend/model/payment-method/index.ts @@ -1,3 +1,4 @@ export * from './payment-method'; export * from './payment-method-bank-card'; export * from './payment-method-terminal'; +export * from './payment-method-wallets'; diff --git a/src/app/backend/model/payment-method/payment-method-wallets.ts b/src/app/backend/model/payment-method/payment-method-wallets.ts new file mode 100644 index 0000000..0fa0587 --- /dev/null +++ b/src/app/backend/model/payment-method/payment-method-wallets.ts @@ -0,0 +1,11 @@ +import { PaymentMethod } from './payment-method'; + +export class PaymentMethodWallets extends PaymentMethod { + + public providers: string[]; + + constructor() { + super(); + this.method = 'DigitalWallet'; + } +} diff --git a/src/app/checkout/checkout-config-form/checkout-config-form.component.pug b/src/app/checkout/checkout-config-form/checkout-config-form.component.pug index 9badf8a..2aeb2a6 100644 --- a/src/app/checkout/checkout-config-form/checkout-config-form.component.pug +++ b/src/app/checkout/checkout-config-form/checkout-config-form.component.pug @@ -11,18 +11,6 @@ form([formGroup]="form", novalidate) label.text-left Описание вашего продукта или сервиса: .col-xs-12.col-sm-7 input.form-control(type="text", formControlName="description") - .form-group - .row - .col-xs-12.col-sm-5 - label.text-left Текст кнопки оплаты: - .col-xs-12.col-sm-7 - input.form-control(type="text", formControlName="payButtonLabel") - .form-group - .row - .col-xs-12.col-sm-5 - label.text-left URL для задания логотипа: - .col-xs-12.col-sm-7 - input.form-control(type="text", formControlName="logo", placeholder="http(s)://example.com/image.png") .form-group .row .col-xs-12.col-sm-5 @@ -37,13 +25,13 @@ form([formGroup]="form", novalidate) input.form-control(type="text", formControlName="redirectUrl", placeholder="http(s)://example.com") .form-group(*ngIf="additionalMethods") .row - .col-xs-12.col-sm-5 + .col-xs-12 label.text-left Дополнительные методы оплаты: - .col-xs-12.col-sm-5 + .col-xs-12.col-sm-6.col-md-4(*ngFor="let method of configurableMethods") label.text-left - input(type="checkbox", formControlName="terminals", (click)="toggleTerminals()") - |  Терминалы "Евросеть" - div(*ngIf="!form.value.terminals") + input(type="checkbox", formControlName="{{getInfo(method.method).formControlName}}", (click)="toggleHolds()") + |  {{getInfo(method.method).label}} + div(*ngIf="!form.value.terminals && !form.value.wallets") .ln_solid .form-group .row diff --git a/src/app/checkout/checkout-config-form/checkout-config-form.component.ts b/src/app/checkout/checkout-config-form/checkout-config-form.component.ts index b6b9bdc..752cb58 100644 --- a/src/app/checkout/checkout-config-form/checkout-config-form.component.ts +++ b/src/app/checkout/checkout-config-form/checkout-config-form.component.ts @@ -5,7 +5,11 @@ import { SelectItem } from 'koffing/common/select/select-item'; import { HOLD_EXPIRATION } from 'koffing/backend/constants/hold-expiration'; import { CheckoutConfigFormService } from './checkout-config-form.service'; import { PaymentMethod } from 'koffing/backend/model/payment-method/payment-method'; -import { PaymentMethodTerminal } from 'koffing/backend/model/payment-method/payment-method-terminal'; + +interface ConfigurablePaymentMethodInfo { + label: string; + formControlName: string; +} @Component({ selector: 'kof-checkout-config-form', @@ -17,6 +21,8 @@ export class CheckoutConfigFormComponent implements OnInit, OnChanges { @Input() public methods: PaymentMethod[]; + public configurableMethods: PaymentMethod[]; + public form: FormGroup; public holdExpirationItems: SelectItem[]; @@ -31,14 +37,13 @@ export class CheckoutConfigFormComponent implements OnInit, OnChanges { new SelectItem(HOLD_EXPIRATION.capture, 'в пользу мерчанта') ]; this.form = this.checkoutConfigFormService.form; + } public ngOnChanges() { if (this.methods) { - const terminal = this.methods.find((method) => method.method === 'PaymentTerminal') as PaymentMethodTerminal; - if (terminal) { - this.additionalMethods = !!terminal.providers.find((provider) => provider === 'euroset'); - } + this.configurableMethods = this.methods.filter((method) => method.method !== 'BankCard'); + this.additionalMethods = this.methods.length > 1; } } @@ -46,10 +51,25 @@ export class CheckoutConfigFormComponent implements OnInit, OnChanges { return this.form.value.holdExpiration === holdExpiration; } - public toggleTerminals() { + public getInfo(methodName: string): ConfigurablePaymentMethodInfo { + switch (methodName) { + case 'PaymentTerminal': + return { + label: 'Терминалы "Евросеть"', + formControlName: 'terminals' + }; + case 'DigitalWallet': + return { + label: 'QIWI кошелек', + formControlName: 'wallets' + }; + } + } + + public toggleHolds() { this.form.patchValue({ - paymentFlowHold: false, - terminals: !this.form.value.terminals + paymentFlowHold: false }); } + } diff --git a/src/app/checkout/checkout-config-form/checkout-config-form.service.ts b/src/app/checkout/checkout-config-form/checkout-config-form.service.ts index 1410ef6..e728052 100644 --- a/src/app/checkout/checkout-config-form/checkout-config-form.service.ts +++ b/src/app/checkout/checkout-config-form/checkout-config-form.service.ts @@ -15,14 +15,13 @@ export class CheckoutConfigFormService { private initForm(): FormGroup { return this.fb.group({ name: ['', [Validators.maxLength(30)]], - description: ['', [Validators.maxLength(30)]], - payButtonLabel: ['', [Validators.maxLength(30)]], - logo: [''], + description: [''], email: [''], redirectUrl: [''], paymentFlowHold: [false, [Validators.required] ], holdExpiration: [HOLD_EXPIRATION.cancel, [Validators.required]], - terminals: false + terminals: true, + wallets: true }); } } diff --git a/src/app/checkout/payment-link/payment-link-arguments.ts b/src/app/checkout/payment-link/payment-link-arguments.ts index 093c507..3498912 100644 --- a/src/app/checkout/payment-link/payment-link-arguments.ts +++ b/src/app/checkout/payment-link/payment-link-arguments.ts @@ -14,4 +14,5 @@ export class PaymentLinkArguments { public paymentFlowHold?: boolean; public holdExpiration?: string; public terminals?: boolean; + public wallets?: boolean; } diff --git a/src/app/checkout/payment-link/payment-link.service.ts b/src/app/checkout/payment-link/payment-link.service.ts index cccb8a9..5873fdb 100644 --- a/src/app/checkout/payment-link/payment-link.service.ts +++ b/src/app/checkout/payment-link/payment-link.service.ts @@ -92,6 +92,7 @@ export class PaymentLinkService { args.applePayTest = true; } args.terminals = formValue.terminals; + args.wallets = formValue.wallets; return args; } diff --git a/src/app/invoice/payments/payment-details/payment-details.component.pug b/src/app/invoice/payments/payment-details/payment-details.component.pug index f39cbd7..8498cbf 100644 --- a/src/app/invoice/payments/payment-details/payment-details.component.pug +++ b/src/app/invoice/payments/payment-details/payment-details.component.pug @@ -77,17 +77,32 @@ form.form-horizontal.form-label-left.css-form label.col-sm-5 Метод оплаты: .col-sm-7 div {{payment.payer?.paymentToolDetails?.detailsType | kofPaymentToolDetailsType}} + .row .col-xs-12(*ngIf="payment.payer?.paymentToolDetails?.detailsType === 'PaymentToolDetailsPaymentTerminal'") .form-group label.col-sm-5 Провайдер: .col-sm-7 div {{payment.payer?.paymentToolDetails?.provider | kofProviderName}} + + .col-xs-12(*ngIf="payment.payer?.paymentToolDetails?.detailsType === 'PaymentToolDetailsDigitalWallet'") + .form-group + label.col-sm-5 Провайдер: + .col-sm-7 + div {{payment.payer?.paymentToolDetails?.digitalWalletDetailsType | kofProviderName}} + .col-xs-12(*ngIf="payment.payer?.paymentToolDetails?.detailsType === 'PaymentToolDetailsBankCard'") .form-group label.col-sm-5 Данные карты: .col-sm-7 div **** **** **** {{payment.payer?.paymentToolDetails?.cardNumberMask}} ({{payment.payer?.paymentToolDetails?.paymentSystem}}) + + .col-xs-12(*ngIf="payment.payer?.paymentToolDetails?.detailsType === 'PaymentToolDetailsDigitalWallet'") + .form-group + label.col-sm-5 Данные кошелька: + .col-sm-7 + div {{payment.payer?.paymentToolDetails?.phoneNumberMask}} + div(*ngIf="payment.payer?.payerType === 'CustomerPayer'") .row .col-xs-12 diff --git a/src/app/invoice/payments/payment-details/payment-tool-details-type.pipe.ts b/src/app/invoice/payments/payment-details/payment-tool-details-type.pipe.ts index 4f7d3ca..1f050ca 100644 --- a/src/app/invoice/payments/payment-details/payment-tool-details-type.pipe.ts +++ b/src/app/invoice/payments/payment-details/payment-tool-details-type.pipe.ts @@ -7,7 +7,8 @@ export class PaymentToolDetailsTypePipe implements PipeTransform { private names = { PaymentToolDetailsPaymentTerminal: 'Терминал', - PaymentToolDetailsBankCard: 'Банковская карта' + PaymentToolDetailsBankCard: 'Банковская карта', + PaymentToolDetailsDigitalWallet: 'Электронный кошелек' }; public transform(input: string): string { diff --git a/src/app/invoice/payments/payment-details/provider-name.pipe.ts b/src/app/invoice/payments/payment-details/provider-name.pipe.ts index 1011951..db1ef41 100644 --- a/src/app/invoice/payments/payment-details/provider-name.pipe.ts +++ b/src/app/invoice/payments/payment-details/provider-name.pipe.ts @@ -7,6 +7,7 @@ export class ProviderNamePipe implements PipeTransform { private names = { euroset: 'Евросеть', + DigitalWalletDetailsQIWI: 'QIWI' }; public transform(input: string): string { diff --git a/src/app/invoices/payment-method-label.ts b/src/app/invoices/payment-method-label.ts index 54ece0c..0ed780c 100644 --- a/src/app/invoices/payment-method-label.ts +++ b/src/app/invoices/payment-method-label.ts @@ -2,5 +2,6 @@ import { PAYMENT_METHOD } from 'koffing/backend'; export const PAYMENT_METHOD_LABEL = { [PAYMENT_METHOD.bankCard]: 'Банковская карта', - [PAYMENT_METHOD.paymentTerminal]: 'Платежный терминал' + [PAYMENT_METHOD.paymentTerminal]: 'Платежный терминал', + // [PAYMENT_METHOD.digitalWallet]: 'Электронный кошелек' }; diff --git a/tslint.json b/tslint.json index 96c8d71..a2867c8 100644 --- a/tslint.json +++ b/tslint.json @@ -34,6 +34,7 @@ "pipe-naming": [true, "camelCase", "kof"], "component-class-suffix": true, "directive-class-suffix": true, - "pipe-impure": true + "pipe-impure": true, + "interface-name": false } }