mirror of
https://github.com/valitydev/checkout.git
synced 2024-11-06 10:35:20 +00:00
APM-13: Add online banking account form (#91)
This commit is contained in:
parent
453fa4fb51
commit
4d4f1a8315
@ -4,10 +4,18 @@ import { Method } from '../method';
|
||||
import { Title } from '../title';
|
||||
import { Text } from '../text';
|
||||
import { Icon } from '../icon/icon';
|
||||
import { FormName, KnownProviderCategories, OnlineBankingFormInfo, PaymentTerminalPaymentMethod } from 'checkout/state';
|
||||
import {
|
||||
FormName,
|
||||
KnownProviderCategories,
|
||||
OnlineBankingAccountFormInfo,
|
||||
OnlineBankingFormInfo,
|
||||
PaymentTerminalPaymentMethod
|
||||
} from 'checkout/state';
|
||||
import { Locale } from 'checkout/locale';
|
||||
import { PayAction, SetFormInfoAction } from './types';
|
||||
import { payWithPaymentTerminal } from './pay-with-payment-terminal';
|
||||
import { getMetadata } from 'checkout/components/ui';
|
||||
import { ServiceProvider } from 'checkout/backend';
|
||||
|
||||
interface OnlineBankingProps {
|
||||
method: PaymentTerminalPaymentMethod;
|
||||
@ -19,14 +27,23 @@ interface OnlineBankingProps {
|
||||
const toOnlineBanking = (category: KnownProviderCategories, setFormInfo: SetFormInfoAction) =>
|
||||
setFormInfo(new OnlineBankingFormInfo(category, FormName.paymentMethods));
|
||||
|
||||
const toOnlineBankingAccount = (serviceProvider: ServiceProvider, setFormInfo: SetFormInfoAction) =>
|
||||
setFormInfo(new OnlineBankingAccountFormInfo(serviceProvider));
|
||||
|
||||
const provideMethod = (
|
||||
{ serviceProviders, category }: PaymentTerminalPaymentMethod,
|
||||
pay: PayAction,
|
||||
setFormInfo: SetFormInfoAction
|
||||
) =>
|
||||
serviceProviders.length === 1
|
||||
? payWithPaymentTerminal(serviceProviders[0].id, pay)
|
||||
: toOnlineBanking(category, setFormInfo);
|
||||
) => {
|
||||
if (serviceProviders.length === 1) {
|
||||
const provider = serviceProviders[0];
|
||||
const { form } = getMetadata(provider);
|
||||
return form
|
||||
? toOnlineBankingAccount(provider, setFormInfo)
|
||||
: payWithPaymentTerminal(serviceProviders[0].id, pay);
|
||||
}
|
||||
return toOnlineBanking(category, setFormInfo);
|
||||
};
|
||||
|
||||
const getTitle = (l: Locale, category: KnownProviderCategories) => l[`form.payment.method.name.${category}.label`];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user