FE-540: added qiwi support (#188)

This commit is contained in:
Alexandra Usacheva 2018-02-14 18:07:48 +03:00 committed by GitHub
parent c3a6fbf69a
commit f93c6c30ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 74 additions and 33 deletions

View File

@ -1,4 +1,5 @@
export const PAYMENT_METHOD = {
bankCard: 'bankCard',
paymentTerminal: 'paymentTerminal'
paymentTerminal: 'paymentTerminal',
digitalWallet: 'digitalWallet'
};

View File

@ -1,3 +1,4 @@
export * from './payment-method';
export * from './payment-method-bank-card';
export * from './payment-method-terminal';
export * from './payment-method-wallets';

View File

@ -0,0 +1,11 @@
import { PaymentMethod } from './payment-method';
export class PaymentMethodWallets extends PaymentMethod {
public providers: string[];
constructor() {
super();
this.method = 'DigitalWallet';
}
}

View File

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

View File

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

View File

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

View File

@ -14,4 +14,5 @@ export class PaymentLinkArguments {
public paymentFlowHold?: boolean;
public holdExpiration?: string;
public terminals?: boolean;
public wallets?: boolean;
}

View File

@ -92,6 +92,7 @@ export class PaymentLinkService {
args.applePayTest = true;
}
args.terminals = formValue.terminals;
args.wallets = formValue.wallets;
return args;
}

View File

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

View File

@ -7,7 +7,8 @@ export class PaymentToolDetailsTypePipe implements PipeTransform {
private names = {
PaymentToolDetailsPaymentTerminal: 'Терминал',
PaymentToolDetailsBankCard: 'Банковская карта'
PaymentToolDetailsBankCard: 'Банковская карта',
PaymentToolDetailsDigitalWallet: 'Электронный кошелек'
};
public transform(input: string): string {

View File

@ -7,6 +7,7 @@ export class ProviderNamePipe implements PipeTransform {
private names = {
euroset: 'Евросеть',
DigitalWalletDetailsQIWI: 'QIWI'
};
public transform(input: string): string {

View File

@ -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]: 'Электронный кошелек'
};

View File

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