Prerequisites
CORS configuration
Since the embedded Web Form works as a part of your web page, but still has to communicate with *.finapi.io domains, all modern web browsers will apply Cross-Origin Resource Sharing (CORS) policies to all requests triggered by the Web Form scripts. finAPI Web Form 2.0 backend takes care of it and makes sure to only process requests from domains you allow. By default, no domains are allowed for customers, and they must be explicitly configured.
If you try to use the embedded Web Form, but it apparently fails, and you see “CORS error” in the Network tab of DevTools in the browser, it means CORS configuration is missing for your mandator.
To eliminate this issue, you need to provide us with all domains where you are going to use the embedded Web Form. For that, please raise a request to our support team, and they will take care of the rest.
Please note that due to security requirements, it is not allowed to use any local domains (e.g. localhost or 127.0.0.1) in the CORS configuration. If you want to test your application running on a local machine, consider using public services that can route your local traffic to a domain available on the Internet.
Web Form Loader
Web Form is bundled as a Web Component.
Web Components is a suite of different technologies allowing you to create reusable custom elements - with their functionality encapsulated away from the rest of your code - and utilize them in your web apps. (source)
This means you can attach a Web Form as a custom DOM element to your web page. Web Form is rendered under Shadow root which prevents conflicts with your host application (e.g. CSS styling issues). To make things even easier, we provide you with a Web Form Loader.
Web Form Loader is a small JavaScript library that takes care of loading and unloading Web Form to and from your page.
Type definitions as well as all options supported by the Web Form Loader can always be found here: https://webform-dist.finapi.io/latest/docs/modules.html
Usage
Usage via script
To use Web Form in simple HTML code, one could do it like this:
<div id="webFormContainer"></div>
<script src="https://webform-dist.finapi.io/2.48.0/dist/web-form.min.js"></script>
<script>
const createWebForm = async function () {
// Replace the following line with a real HTTP request to one of the services that create a web form
// ("Import a bank connection", "Update a bank connection", and others).
// Use the `id` field's value of the created web form as the value for the `token` then.
const token = await Promise.resolve("<token>");
FinApiWebForm.load(
document.querySelector("#webFormContainer"),
{
token: token,
// these are examples of how optional properties can be set:
targetUrl: "https://webform-live.finapi.io",
layoutConfig: "xs",
backToAppUrl: "https://customer.app",
customerSupportUrl: "https://finapi.io",
language: "de"
},
{
onLoaded: function() {
// handle "onLoaded" event
},
onComplete: function() {
// handle "onComplete" event
},
onFail: function() {
// handle "onFail" event
},
onAbort: function() {
// handle "onAbort" event
},
onLoadError: function() {
// handle "onLoadError" event
}
}
);
};
document.addEventListener("DOMContentLoaded", function() {
createWebForm();
});
</script>
Before you can load a web form, you will need to first obtain a valid token - more info in Web Form Basics. For each next load, a new token should be provided.
web-form.min.js contains an IIFE - immediately invoked function expression, which will create a globally-scoped variable FinApiWebForm. This variable name is therefore reserved.
The URL contains the version of the Web Form Loader (2.48.0 in the example above). Replace it with the most recent version listed in the NPM version history. Only versions released on NPM are available. Please read Versions and updates below before using the loader in production.
Usage as a module
Web Form Loader can also be installed as an NPM package:
npm install @finapi/web-form
This package exports functions load() and unload(). It also provides TypeScript type declarations.
An example of usage in React framework could look like this:
import React, { useCallback } from "react";
import { load } from "@finapi/web-form";
function App() {
return <FinApiWebForm />;
}
function FinApiWebForm() {
const createWebForm = useCallback(async (target: HTMLElement) => {
// Replace the following line with a real HTTP request to one of the services that create a web form
// ("Import a bank connection", "Update a bank connection", and others).
// Use the `id` field's value of the created web form as the value for the `token` then.
const token = await Promise.resolve("<token>");
load(
target,
{
token: token,
// these are examples of how optional properties can be set:
targetUrl: "https://webform-live.finapi.io",
layoutConfig: "xs",
backToAppUrl: "https://customer.app",
customerSupportUrl: "https://finapi.io",
language: "de"
},
{
onLoaded: function() {
// handle "onLoaded" event
},
onComplete: function() {
// handle "onComplete" event
},
onFail: function() {
// handle "onFail" event
},
onAbort: function() {
// handle "onAbort" event
},
onLoadError: function() {
// handle "onLoadError" event
}
}
);
}, []);
const containerRef = (container: HTMLDivElement) => {
if (container) {
createWebForm(container);
}
};
return <div ref={containerRef}></div>;
}
export default App;
Web Form Loader module requires minimum ES5 support.
Your package manager's lock file keeps the installed version fixed. The recommendations in Versions and updates below still apply to how you update it.
Versions and updates
What the version applies to
The Web Form Loader is a small script that places the Web Form into your page. It does not contain the Web Form itself. The Web Form (its screens, bank flows, and translations) is always delivered by the finAPI environment you are connected to and is updated by finAPI continuously, independently of the loader version you use.
The loader version therefore determines only the integration interface: the load() / unload() functions, the supported properties, and the callbacks.
Use a fixed version in production
We strongly recommend referencing an exact loader version in production code, e.g. https://webform-dist.finapi.io/2.48.0/dist/web-form.min.js:
-
No unplanned changes. A new loader release does not reach your production application until you decide to update and have tested it.
-
Consistent behavior for all your users. Fixed versions never change. Files behind a tag (see below) are cached by browsers and networks, so after a release different users may receive different loader versions for some time.
-
Reproducible issues. When you report a problem to our support, the exact loader version you use helps us reproduce it.
When installing via NPM, the lock file takes care of this.
Tags
Besides fixed versions, the loader is available under these tags:
-
latest- the most recent stable release, tested and synced with the Live environment. -
alpha- an unstable pre-release that might be out of sync with the Live environment.
A tag always points to the most recent release of its kind, so the code behind a tagged URL (e.g. https://webform-dist.finapi.io/latest/dist/web-form.min.js) changes with every release, without any action on your side.
Do not use tags in production. latest is convenient for prototyping and quick evaluation, but a new release would reach your production application untested. alpha is meant only for early testing of upcoming changes and must never be used in production.
Keep the loader up to date
Using a fixed version does not mean using it forever. Since the Web Form keeps evolving, an old loader falls further behind over time:
-
New features and integration options are added only to new loader versions.
-
Fixes in the loader (e.g. browser compatibility) reach you only when you update.
-
The longer you wait, the more changes accumulate between your version and the current one, and the bigger the update becomes.
We recommend checking the NPM version history regularly and updating as part of your normal maintenance:
-
Update the version in your development or test environment first (connected to our Sandbox environment).
-
Verify your integration, in particular the callbacks your application relies on.
-
Roll the new version out to production.
Configuring the Web Form Loader
Docs
Web Form Loader typedoc can be found here: https://webform-dist.finapi.io/latest/docs/modules.html.
This documentation always describes the most recent release. The documentation of a specific version is available at https://webform-dist.finapi.io/<version>/docs/modules.html, e.g. 2.48.0.
Working with custom environments
The loader works by default with the Live environment (https://webform-live.finapi.io), but it might happen that you have a custom environment working on another subdomain, e.g. https://custom-webform.finapi.io. In such cases, please use the targetUrl parameter provided by the loader in order to overwrite the default behavior. You can always clarify with our Customer Support team if it applies to your setup.
Adjusting the layout of the web form
By default, the embedded web form will choose its layout config based on the current viewport size. Due to technical limitations, only the size of the “main” viewport is taken into consideration and the size of the actual web form component is ignored. That sometimes might lead to an undesired “look and feel” of the web page. In such cases, the default layout config can be overridden via the Loader property layoutConfig, where you can either use one of the predefined values (xs, sm, md, and lg) or provide your custom breakpoints. For the type definition of the property, check the typedoc.
Frontend callbacks
When embedding a web form in either way described above, callback functions can be passed directly to the web form loader during the initialization phase. These functions, if provided, will be triggered when the corresponding event occurs, e.g., when the web form is completed. In that way, you can either avoid using our “server” callbacks (listed in this section) or combine both approaches in order to provide the best user experience.
Find the full list of supported callbacks, as well as more details about how they function in the typedoc.
Demo
We have prepared mini-DEMO(s) on how standalone and embeddable Web Forms could look. Please feel free to take a look.
00:00 General Introduction
01:45 Explanation of how standalone Web Form works
05:14 Demo
12:05 Explanation on how to embed the Web Form into a customer web page
15:00 Demo
19:42 Explanation on how to integrate the Web Form into an Android app
21:51 Demo