
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@wf-financing/headless-sdk
Advanced tools
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.
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.
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.
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.
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);
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.
For further details on using the SDK, troubleshooting, or expanding on these examples, check out our full documentation.
FAQs
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.
We found that @wf-financing/headless-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.