Deep link test (#355)

This commit is contained in:
Ildar Galeev 2024-10-22 19:17:29 +07:00 committed by GitHub
parent 053324b44a
commit 32e8cc4092
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 19 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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