The simplest way to start the prequalification process is by using our prequalification button. The image below is a sample of how it could look on your page (the text Payment as low as ... was added by the plugin).
You only have to add an element to the page and call the inject method passing the class name of the element as shown below:
The element can be a <span>, <div> or <p> and you need to include the data attributes amount and type:
The plugin exposes the addEventListener method that you can use to listen for approval events. You must provide a function that will be called every time an event is emitted. This function will receive an object with the event name and the event arguments.
alert("User was approved and publicId is "+ e.eventArgs.publicId);
You can use the EVENT_USER_WAS_APPROVED variable to check if the event is an approval. The eventArgs property will contain the publicId that you can use to call our API and get the approval amount.
As an alternative to inject our prequalification button, you can use the prequalify method to manually open the pre-qualification popup. The method references the amount and returns a promise that you can use to check if the user was approved. It also returns the publicId that you can use to call our API and get the approval amount.