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,
theme: null,
paymentFlow: null,
deepLink: null,
};
expect(actual).toEqual(expected);
});

View File

@ -33,6 +33,7 @@ export const resolveInitConfig = (userConfig: Partial<InitConfig>): InitConfig =
isExternalIDIncluded,
theme,
paymentFlow,
deepLink,
} = userConfig;
return {
...resolvedIntegrationType,
@ -52,5 +53,6 @@ export const resolveInitConfig = (userConfig: Partial<InitConfig>): InitConfig =
isExternalIDIncluded: setDefault(resolveBoolean(isExternalIDIncluded), true),
theme: resolveString(theme),
paymentFlow: resolveObject(paymentFlow),
deepLink: resolveString(deepLink),
};
};

View File

@ -20,6 +20,7 @@ export type InitConfig = {
skipUserInteraction?: boolean;
isExternalIDIncluded?: boolean;
paymentFlow?: object;
deepLink?: string;
};
export type ThemeConfig = Record<string, any>;

View File

@ -43,4 +43,5 @@ export const toInitContext = (initConfig: InitConfig): InitContext => ({
metadata: initConfig.metadata,
recurring: initConfig.recurring,
paymentFlow: toPaymentFlow(initConfig.paymentFlow),
deepLink: initConfig.deepLink,
});

View File

@ -49,6 +49,7 @@ export type InitContext = {
readonly cancelUrl?: string;
readonly metadata?: Record<string, any>;
readonly recurring?: boolean;
readonly deepLink?: string;
};
export type CommonPaymentModel = {

View File

@ -10,6 +10,7 @@ import {
PaymentModelContext,
ViewModelContext,
} from 'checkout/contexts';
import { isNil } from 'checkout/utils';
import { CardHolderFormControl } from './CardHolderFormControl';
import { CardNumberFormControl } from './CardNumberFormControl';
@ -44,6 +45,8 @@ export function CardForm() {
const isSecureCode = isSecureCodeAvailable(watch('cardNumber'));
const deepLink = initContext?.deepLink;
return (
<form onSubmit={handleSubmit(onSubmit)}>
<VStack align="stretch" spacing={5}>
@ -72,6 +75,16 @@ export function CardForm() {
{l['form.button.pay.label']} {viewAmount}
</Button>
</LightMode>
{!isNil(deepLink) && (
<Button
onClick={() => {
// window.open(deepLink, '_self');
window.location.replace(deepLink);
}}
>
Go to deep link
</Button>
)}
</VStack>
</form>
);