Prefilling Application Data
Reduce friction for your users by providing data you already have to pre-populate the Embedded Journey application form.
Reduce friction for your users by providing data you already have to pre-populate the Embedded Journey application form.
Partners typically already hold data about their customers — email addresses, company names, country of incorporation, and more. The Embedded Journey allows partners to pass this data via a prefill callback, so users do not have to re-enter information you already have.
Prefilling data:
When the user opens the Embedded Journey panel, the SDK invokes a callback function provided by the partner. This callback can return an EmbeddedJourneyPrefill object containing any known data. The SDK uses this data to pre-populate the corresponding fields in the application form.
The callback is:
void is valid if no data is available.Pass the prefill callback as the second argument to mountCta:
import {
WayflyerUiSdk,
type EmbeddedJourneyPrefillCallback,
type EmbeddedJourneyPrefill,
} from '@wf-financing/ui-sdk';
const wayflyerUiSdk = await WayflyerUiSdk.loadSdk(companyToken);
const prefillCallback: EmbeddedJourneyPrefillCallback = async () => {
const prefill: EmbeddedJourneyPrefill = {
email: 'merchant@example.com',
companyName: 'Acme Ltd',
country: 'IE',
monthlyRevenue: 50000,
primaryStoreUrl: 'https://acme.com',
};
return prefill;
};
wayflyerUiSdk.mountCta('wayflyer-cta', prefillCallback);
The callback supports asynchronous operations. You can fetch data from your backend before returning:
const prefillCallback: EmbeddedJourneyPrefillCallback = async () => {
const customerData = await fetch('/api/current-customer');
const data = await customerData.json();
return {
email: data.email,
companyName: data.businessName,
country: data.countryCode,
monthlyRevenue: data.revenue,
};
};
All fields are optional. Provide whichever fields you have available.
| Field | Type | Description | Example |
|---|---|---|---|
email | string | User's email address | "merchant@example.com" |
phoneNumber | { number: string, regionCode: string } | User's phone number with region code | { number: "+353861234567", regionCode: "IE" } |
country | string | ISO 3166-1 alpha-2 country code | "IE" |
stateOrProvince | string | ISO 3166-2 state/province code. Only required for US and Canada. | "US-CA" |
monthlyRevenue | number | Average monthly revenue over the last 6 months, in the company's local currency. If an exact figure is not available, an approximation is fine. | 50000 |
companyName | string | Business name | "Acme Ltd" |
primaryStoreUrl | string | Primary website or online store URL | "https://acme.com" |
dateOfIncorporation | string | Date the business was incorporated | "2020-01-15" |
The prefill callback is a UI SDK concept. If you are using the Headless SDK to build your own UI, you already have full control over the data you pass to updateUserDetails() and updateCompanyDetails() — you can pre-populate your own form fields directly from your data sources.