Skip to main content

2. Add a credential

Invoice-Collector offers two flexible integration approaches to the credential addition process. Whether you prefer a quick, embedded solution or full control over the user experience, we have you covered.

Comparison Table

FeatureiFrame IntegrationFull API Integration
Setup Time48 hours2 weeks
CustomizationLimited (CSS theming)Complete control
MaintenanceAutomaticManual updates needed
API CallsHandled internallyYou manage all calls
WebSocket ManagementAutomaticYou implement
UI ConsistencyInvoice-Collector brandedYour brand
Technical ComplexityLowMedium to High
Best ForQuick implementationCustom experiences

1. Iframe integration (Quick & Easy)

The iFrame integration is the fastest way to add Invoice-Collector to your application. With this approach, the credential addition process is embedded in our pre-built interface. All the complex API interactions are handled automatically within the iframe, especialy the WebSocket connection and events handling.

The only thing to do is display an iframe with url:

/ui?token=${token}

Key Benefits:

  • Fastest integration - Get up and running in minutes
  • 🔒 Secure by default - Credentials never pass through your frontend
  • 🎨 Pre-built UI - No need to design credential collection forms
  • 🔄 Automatic updates - Always get the latest features and collectors
  • 📱 Responsive design - Works seamlessly on all devices

Perfect for:

  • MVPs and rapid prototyping
  • Teams with limited frontend resources
  • Applications that want to minimize maintenance
  • Projects prioritizing time-to-market

Implementation

StepSideDescription
1FrontendCreate a hidden iframe with no href.
2FrontendUser clicks on the "Add collector" button.
3FrontendUpdate the iframe href to /ui?token=${token} and display the iframe.
4FrontendListen for events sent from the iframe to parent (see the next section).

Events from iframe to parent

In order to integrate the iframe seamlessly in your frontend, our iframe send events to your frontend to notify what panel is currently displayed in the iframe. These events can be used to adapt the size of the iframe during the credential addition process.

Here are the events sent from the iframe to your frontend :

NameFormatDescriptionRecommended Embedding
Close{ type: 'ic-close' }The credential addition process in finished. The iframe can be closed.iframe_close
Panel Search{ type: 'ic-panel-search' }Current panel is "Search". User can search for a collector in the list.iframe_full
Panel Form{ type: 'ic-panel-form' }Current panel is "Form". User inputs are asked in a form.iframe_full
Panel Feedback{ type: 'ic-panel-feedback' }Current panel is "Feedback". A small feedback form is displayed.iframe_small
Panel Progress{ type: 'ic-panel-progress' }Current panel is "Progress". Credential collect is in progress.iframe_small
Panel Canvas{ type: 'ic-panel-canvas' }Current panel is "Canvas". User needs to authenticate using video stream.iframe_big

In your application, here is how the events can be catch:

window.addEventListener('message', function(event) {
//Message received from an iframe

// If event comes from Invoice-Collector
if (event.origin === "https://api.invoice-collector.com") {
if (event.data.type === 'ic-close') {
//Close the iframe
}
else if (event.data.type === 'ic-panel-search') {
//Panel "Search" is displayed
//Recommended: Resize the iframe to full screen (eg: 100%, 100%)
}
else if (event.data.type === 'ic-panel-form') {
//Panel "Form" is displayed
//Recommended: Resize the iframe to full screen (eg: 100%, 100%)
}
else if (event.data.type === 'ic-panel-progress') {
//Panel "Progress" is displayed
//Recommended: Resize the iframe to small size (eg: 500px, 500px)
}
else if (event.data.type === 'ic-panel-canvas') {
//Panel "Canvas" is displayed
//Recommended: Resize the iframe to big size (eg: 1200px, 600px)
}
else if (event.data.type === 'ic-panel-feedback')
//Panel "Progress" is displayed
//Recommended: Resize the iframe to small size (eg: 600px, 600px)
}
} else {
//Event origin is not Invoice-Collector
}
});

You may resize the iframe to match your desired UX, the choice is yours.

How it works


2. Full integration (Complete Control)

The Full API integration gives you complete control over the user experience. Build your own interface while leveraging our powerful backend infrastructure for credential management and invoice collection.

Key Benefits:

  • 🎨 Full UI customization - Design matches your brand perfectly
  • 🔧 Maximum flexibility - Control every aspect of the user flow
  • 📊 Custom analytics - Track user interactions your way
  • 🌐 Multi-platform - Reuse logic across web, mobile, and desktop

Perfect for:

  • Enterprise applications with specific branding requirements
  • Teams with strong frontend capabilities
  • Applications requiring deep integration with existing workflows
  • Projects needing custom validation or user guidance

Implementation

StepSideDescription
1FrontendCreate a page to display all the available collectors.
2FrontendCreate a page to ask for credentials.
3FrontendCreate a page to display addition progress.
4FrontendUser clicks on the "Add collector" button.
5BackendCall POST /user to create a user in our database and get the user.
6BackendCall GET /collectors to list all the available collectors.
7BackendCall POST /user/{user_id}/credential to create a new credential.
8FrontendImplement WebSocket connection /ws and events (state, screenshot, twofa, close).

WebSocket connection

When implementing the Full API integration, you'll need to establish a WebSocket connection to receive real-time updates about the credential collection process.

Messages Received from API:

  • State - Progress updates and state changes
  • Screenshot - For interactive login when needed

Messages Sent to API:

  • Twofa - Two-factor authentication code
  • Click - Mouse click simulation during interactive login
  • Keydown - Keyboard input during interactive login
  • Text - Text input during interactive login
  • Close - Complete interactive login session

For detailed information about WebSocket messages, refer to the Websocket Messages documentation.

How it works