This guide walks through the changes required to migrate from Finix Tokenization Library v1 to v2.
Our finix.js v2 is a major architectural improvement over v1.
While the migration path is intentionally minimal, v2 delivers significant enhancements in security, performance, and flexibility. The underlying tokenization model remains the same, but the delivery, initialization flow, and internal design are now optimized.
- Same tokenization flow
- Drop-in form component with no PCI exposure
- Same conceptual model of “embed → receive token”
- Cleaner initialization
- Simpler integration code
- Better separation of configuration vs. runtime behavior
- Improved form UI
- 10× smaller bundle size
- Fewer internal dependencies
- Improved security and fraud detection
- More resilient communication between parent + iframe
- Stronger isolation of sensitive payment fields
v2 is built for:
- Embedded payment experiences
- Component-based UI frameworks
- Shadow DOM use cases
- Web app environments where isolation, reliability, and performance are critical
By simplifying the integration API and optimizing the internal runtime, v2 enables customers to ship more secure and performant PCI-compliant payment experiences with less code.
The migration from v1 to v2 introduces a cleaner initialization model. Most of the library remains familiar, but a few key responsibilities have shifted.
Here are the primary differences:
You'll load v2 instead of v1:
- v1:
https://js.finix.com/v/1/finix.js - v2:
https://js.finix.com/v/2/finix.js
The entry point for embedding changes:
- Finix.TokenForm(...)
+ Finix.PaymentForm(...)In v1 these values were passed into .submit():
form.submit("sandbox", "APP_ID", ...)In v2, they become part of initialization:
Finix.PaymentForm(..., "sandbox", "APP_ID", ...)In v1, your onSubmit handler existed, but it was only a trigger — you still had to call form.submit() from inside it, and you needed to pass both the environment and the Application ID at that moment.
Example v1 flow:
onSubmit(...) {
form.submit("sandbox", "APP_ID", (error, response) => { ... });
}In v2, the form takes care of all submit logic internally, as long as you provide an onSubmit callback upfront. The environment and application are already bound during initialization, so your callback is now just a response handler — much simpler and much safer.
v2 usage:
Finix.PaymentForm(..., {
onSubmit: (error, response) => {
// Your callback logic
}
});You can still invoke form.submit() in v2.
However, the behavior has changed in a meaningful way:
- You no longer pass environment and application parameters
- You do still pass a callback function (just like v1)
In v1, a manual submission looked like:
form.submit("sandbox", "APP_ID", (error, response) => {
// your code
});In v2, a manual submission looks like:
form.submit((error, response) => {
// your callback logic
});This callback receives:
error— any validation or network errorsresponse— the tokenization response
Manual submission is useful when:
- You want to control precisely when a submission occurs
- You want to implement custom UI flows
- You want to handle additional validation or analytics
- You want to prevent auto-submit and only submit manually
- v1 required you to call submit manually and pass the environment and application ID parameters every time.
- v2 only requires passing onSubmit once, and Finix handles submission automatically.
- You can still call
.submit()manually, but it is now fully context-aware and requires no additional arguments.
The result is a drastically simpler and safer integration model, especially for larger or event-driven applications.
Before (v1):
<script src="https://js.finix.com/v/1/finix.js"></script>After (v2):
<script src="https://js.finix.com/v/2/finix.js"></script>Before:
Finix.TokenForm(...)After:
Finix.PaymentForm(...)v1:
form.submit("sandbox", "APP_ID", ...)v2:
Finix.PaymentForm("finix-form", "sandbox", "APP_ID", options);v1:
form.submit(..., (error, response) => { ... })v2:
Finix.PaymentForm("finix-form", "sandbox", "APP_ID", {
onSubmit: (error, response) => { ... }
});<script src="https://js.finix.com/v/1/finix.js"></script>
<div id="finix-form"></div>
<script>
const onSubmit = () => {
form.submit("sandbox", "APgPDQrLD52TYvqazjHJJchM", (error, response) => {
const tokenData = response.data || {};
console.log(tokenData);
});
};
const form = Finix.TokenForm("finix-form", {
onSubmit,
});
</script><script src="https://js.finix.com/v/2/finix.js"></script>
<div id="finix-form"></div>
<script>
Finix.PaymentForm("finix-form", "sandbox", "APgPDQrLD52TYvqazjHJJchM", {
onSubmit: (error, response) => {
const tokenData = response.data || {};
console.log("Generated token:", tokenData.id);
}
});
</script>Finix.PaymentForm(
element, // required: DOM ID string OR HTMLElement reference
environment, // required: "sandbox" | "prod"
applicationId, // required: must belong to chosen environment
options // optional: behavior customization, including onSubmit
);You may pass either:
Finix.PaymentForm("finix-form", "sandbox", "APP_ID");const container = document.getElementById("finix-form");
Finix.PaymentForm(container, "sandbox", "APP_ID");DOM references improve compatibility with:
- Shadow DOM
- Web components
- Micro frontends
- Modern UI frameworks
Allowed environments:
sandboxandprodYour Application ID must belong to the same environment to ensure you are tokenizing against the correct environment/services.
- Sandbox ID +
prod= will fail - Prod ID +
sandbox= will fail
- Sandbox ID +
- Update script reference to
/v/2/ - Replace
TokenFormwithPaymentForm - Move Application ID from submit to initialization
- Move environment from submit to initialization
- (Optional) Move submission callback to
onSubmitoption - Test token generation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Payment Form Minimal</title>
<style>
#finix-form {
width: 50%;
margin: 0 auto;
max-width: 600px;
min-width: 200px;
}
</style>
<script src="https://js.finix.com/v/2/finix.js"></script>
</head>
<body>
<h1>Payment Form Test Page</h1>
<div id="finix-form"></div>
<script>
Finix.PaymentForm("finix-form", "sandbox", "APgPDQrLD52TYvqazjHJJchM", {
onSubmit: (error, response) => {
const tokenData = response.data || {};
console.log("Generated token:", tokenData.id);
}
});
</script>
</body>
</html>In v1, you needed to control accepted payment methods at the initializer level, which required switching payment methods and swapping initializer functions.
TokenForm()— supported both card + bankCardTokenForm()— supported card onlyBankTokenForm()— supported bank only
In v2, there is only one initializer (Finix.PaymentForm()), and you configure the acceptable payment methods with the paymentMethods option.
paymentMethods: ["card", "bank"];This matches TokenForm() from v1 (both are accepted).
paymentMethods: ["card"];paymentMethods: ["bank"];| v1 initializer | v2 equivalent |
|---|---|
TokenForm() | Finix.PaymentForm(..., { paymentMethods: ["card","bank"] }) (default) |
CardTokenForm() | Finix.PaymentForm(..., { paymentMethods: ["card"] }) |
BankTokenForm() | Finix.PaymentForm(..., { paymentMethods: ["bank"] }) |
Finix.PaymentForm("finix-form", "sandbox", "APP_ID", {
paymentMethods: ["card"],
onSubmit: (error, response) => {
console.log("Generated token:", response?.data?.id);
}
});Finix.PaymentForm("finix-form", "sandbox", "APP_ID", {
paymentMethods: ["bank"],
onSubmit: (error, response) => {
console.log("Generated token:", response?.data?.id);
}
});Finix.PaymentForm("finix-form", "sandbox", "APP_ID", {
// paymentMethods default to ["card", "bank"],
onSubmit: (error, response) => {
console.log("Generated token:", response?.data?.id);
}
});For migration assistance:
- Email: Finix Support
- Contact your Finix representative
We're here to help you transition as smoothly as possible.