mirror of
https://github.com/valitydev/checkout.git
synced 2024-11-06 02:25:18 +00:00
Deep link test (#355)
This commit is contained in:
parent
053324b44a
commit
32e8cc4092
@ -32,6 +32,7 @@ it('should return resolved init config', () => {
|
|||||||
skipUserInteraction: false,
|
skipUserInteraction: false,
|
||||||
theme: null,
|
theme: null,
|
||||||
paymentFlow: null,
|
paymentFlow: null,
|
||||||
|
deepLink: null,
|
||||||
};
|
};
|
||||||
expect(actual).toEqual(expected);
|
expect(actual).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,7 @@ export const resolveInitConfig = (userConfig: Partial<InitConfig>): InitConfig =
|
|||||||
isExternalIDIncluded,
|
isExternalIDIncluded,
|
||||||
theme,
|
theme,
|
||||||
paymentFlow,
|
paymentFlow,
|
||||||
|
deepLink,
|
||||||
} = userConfig;
|
} = userConfig;
|
||||||
return {
|
return {
|
||||||
...resolvedIntegrationType,
|
...resolvedIntegrationType,
|
||||||
@ -52,5 +53,6 @@ export const resolveInitConfig = (userConfig: Partial<InitConfig>): InitConfig =
|
|||||||
isExternalIDIncluded: setDefault(resolveBoolean(isExternalIDIncluded), true),
|
isExternalIDIncluded: setDefault(resolveBoolean(isExternalIDIncluded), true),
|
||||||
theme: resolveString(theme),
|
theme: resolveString(theme),
|
||||||
paymentFlow: resolveObject(paymentFlow),
|
paymentFlow: resolveObject(paymentFlow),
|
||||||
|
deepLink: resolveString(deepLink),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,7 @@ export type InitConfig = {
|
|||||||
skipUserInteraction?: boolean;
|
skipUserInteraction?: boolean;
|
||||||
isExternalIDIncluded?: boolean;
|
isExternalIDIncluded?: boolean;
|
||||||
paymentFlow?: object;
|
paymentFlow?: object;
|
||||||
|
deepLink?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ThemeConfig = Record<string, any>;
|
export type ThemeConfig = Record<string, any>;
|
||||||
|
@ -43,4 +43,5 @@ export const toInitContext = (initConfig: InitConfig): InitContext => ({
|
|||||||
metadata: initConfig.metadata,
|
metadata: initConfig.metadata,
|
||||||
recurring: initConfig.recurring,
|
recurring: initConfig.recurring,
|
||||||
paymentFlow: toPaymentFlow(initConfig.paymentFlow),
|
paymentFlow: toPaymentFlow(initConfig.paymentFlow),
|
||||||
|
deepLink: initConfig.deepLink,
|
||||||
});
|
});
|
||||||
|
@ -49,6 +49,7 @@ export type InitContext = {
|
|||||||
readonly cancelUrl?: string;
|
readonly cancelUrl?: string;
|
||||||
readonly metadata?: Record<string, any>;
|
readonly metadata?: Record<string, any>;
|
||||||
readonly recurring?: boolean;
|
readonly recurring?: boolean;
|
||||||
|
readonly deepLink?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CommonPaymentModel = {
|
export type CommonPaymentModel = {
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
PaymentModelContext,
|
PaymentModelContext,
|
||||||
ViewModelContext,
|
ViewModelContext,
|
||||||
} from 'checkout/contexts';
|
} from 'checkout/contexts';
|
||||||
|
import { isNil } from 'checkout/utils';
|
||||||
|
|
||||||
import { CardHolderFormControl } from './CardHolderFormControl';
|
import { CardHolderFormControl } from './CardHolderFormControl';
|
||||||
import { CardNumberFormControl } from './CardNumberFormControl';
|
import { CardNumberFormControl } from './CardNumberFormControl';
|
||||||
@ -44,6 +45,8 @@ export function CardForm() {
|
|||||||
|
|
||||||
const isSecureCode = isSecureCodeAvailable(watch('cardNumber'));
|
const isSecureCode = isSecureCodeAvailable(watch('cardNumber'));
|
||||||
|
|
||||||
|
const deepLink = initContext?.deepLink;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<VStack align="stretch" spacing={5}>
|
<VStack align="stretch" spacing={5}>
|
||||||
@ -72,6 +75,16 @@ export function CardForm() {
|
|||||||
{l['form.button.pay.label']} {viewAmount}
|
{l['form.button.pay.label']} {viewAmount}
|
||||||
</Button>
|
</Button>
|
||||||
</LightMode>
|
</LightMode>
|
||||||
|
{!isNil(deepLink) && (
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
// window.open(deepLink, '_self');
|
||||||
|
window.location.replace(deepLink);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Go to deep link
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</VStack>
|
</VStack>
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user