Socket
Book a DemoInstallSign in
Socket

@wf-financing/headless-sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wf-financing/headless-sdk

Wayflyer provides a `@wf-financing/headless-sdk` package that can be used as a client-side headless SDK to interact with the Embedded Finance API.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Wayflyer Financing Headless SDK

Wayflyer provides a @wf-financing/headless-sdk package that can be used as a client-side headless SDK to interact with the Embedded Finance API.

Installation

Install the package directly from NPM with npm install @wf-financing/headless-sdk.
To minimize bundle size and reduce the impact on partners' page load times, the SDK uses dynamic imports to load main part of functionality.

Instantiation

Initialize the Wayflyer headless SDK by passing the companyToken and a pointer that specifies whether the SDK should work in mocked mode.

import { type IHeadlessWayflyerSdk, WayflyerHeadlessSdk } from '@wf-financing/headless-sdk';

const wayflyerSdk = (await WayflyerHeadlessCtaSdk.loadSdk('token')) as IHeadlessWayflyerSdk;

Note: The companyToken should be minted using the Company Token endpoint on the partner's backend. See the Authentication section here for more details.

SDK methods

getCta()

Returns the configuration for the CTA to show to the user.

import type { CtaResponseType } from '@wf-financing/headless-sdk';

const cta: CtaResponseType = await wayflyerSdk.getCta();

startHostedApplication(applicationRequest)

Returns a URL to the Wayflyer landing page after the user has given consent for sharing personal data.

import type { StartHostedApplicationRequestType, StartHostedApplicationResponseType } from '@wf-financing/headless-sdk';

const merchantData: StartHostedApplicationRequestType = {
  company_data: {},
  user_data: {},
  partner_data: {},
};

const startHostedApplication: StartHostedApplicationResponseType = await wayflyerSdk.startHostedApplication(merchantData);

continueHostedApplication()

Returns a URL to the Wayflyer landing page after the submission of the merchant funding application.

import type { ContinueHostedApplicationResponseType } from '@wf-financing/headless-sdk';

const startHostedApplication: ContinueHostedApplicationResponseType = await wayflyerSdk.startHostedApplication(merchantData);

Mocked mode

To simplify the testing process, the SDK can be initialized in mock mode. To do so, pass a second argument with the value true.

import { WayflyerHeadlessCtaSdk } from '@wf-financing/headless-sdk';

const wayflyerSdk = (await WayflyerHeadlessCtaSdk.loadSdk('token', true)) as IHeadlessWayflyerSdk;

In mock mode, partner can manually set responses for SDK methods via additional methods:

  • setCtaResponse(responseType: CtaResponseTypes)
  • setStartHostedApplicationResponse(responseType: StartHostedApplicationResponseTypes)
  • setContinueHostedApplicationResponse(responseType: ContinueHostedApplicationResponseTypes)
  • setSdkScenario(sdkScenario: SdkScenarios)

setCtaResponse(responseType: CtaResponseTypes)

Sets a mocked response for the getCta() method.

import { CtaResponseTypes } from '@wf-financing/headless-sdk';

wayflyerSdk.setCtaResponse(CtaResponseTypes.GENERIC_OFFER);
wayflyerSdk.setCtaResponse(CtaResponseTypes.INDICATIVE_OFFER);
wayflyerSdk.setCtaResponse(CtaResponseTypes.CONTINUE_HOSTED_APPLICATION);
wayflyerSdk.setCtaResponse(CtaResponseTypes.NO_CTA);
wayflyerSdk.setCtaResponse(CtaResponseTypes.INVALID_TOKEN);

setCtaResponse(responseType: CtaResponseTypes)

Sets a mocked response for the startHostedApplication(applicationRequest: StartHostedApplicationRequestType) method.

import { StartHostedApplicationResponseTypes } from '@wf-financing/headless-sdk';

wayflyerSdk.setStartHostedApplicationResponse(StartHostedApplicationResponseTypes.REDIRECT_URL);
wayflyerSdk.setStartHostedApplicationResponse(StartHostedApplicationResponseTypes.BAD_REQUEST);
wayflyerSdk.setStartHostedApplicationResponse(StartHostedApplicationResponseTypes.INVALID_TOKEN);

setContinueHostedApplicationResponse(responseType: ContinueHostedApplicationResponseTypes)

Sets a mocked response for the continueHostedApplication() method.

import { ContinueHostedApplicationResponseTypes } from '@wf-financing/headless-sdk';

wayflyerSdk.setContinueHostedApplicationResponse(ContinueHostedApplicationResponseTypes.REDIRECT_URL);
wayflyerSdk.setContinueHostedApplicationResponse(ContinueHostedApplicationResponseTypes.BAD_REQUEST);
wayflyerSdk.setContinueHostedApplicationResponse(ContinueHostedApplicationResponseTypes.INVALID_TOKEN);

setSdkScenario(sdkScenario: SdkScenarios)

Provides complex mocked scenarios for complete E2E testing. This ensures that partners do not encounter incompatible responses for different methods, such as startHostedApplication(applicationRequest: StartHostedApplicationRequestType) and continueHostedApplication(), which cannot return valid responses at the same time.

import { SdkScenarios } from '@wf-financing/headless-sdk';

wayflyerSdk.setSdkScenario(SdkScenarios.INDICATIVE_NEW_APPLICATION);
wayflyerSdk.setSdkScenario(SdkScenarios.GENERIC_NEW_APPLICATION);
wayflyerSdk.setSdkScenario(SdkScenarios.CONTINUE_APPLICATION);
wayflyerSdk.setSdkScenario(SdkScenarios.NO_CTA);

Note: After calling setSdkScenario(sdkScenario: SdkScenarios), other methods for setting manual responses will no longer have any effect.

Next Steps

For further details on using the SDK, troubleshooting, or expanding on these examples, check out our full documentation.

FAQs

Package last updated on 01 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.