Collecting Customer Data¶
To reduce the risk of invalid and fraudulent transactions, as well as to monitor the compliance of the partner activities specified by him when concluding the contract, the payment service needs to receive certain client data from the partner’s interface. This data includes a unique browser identifier, page URL, client ID, and other information. The partner must send data from each page that the customer goes to during the payment process.
Data collection and sending are performed through the fingerprint API service.
Using fingerprint API¶
-
Load the script from
https://fp.qiwi.com/static/fp.js
address onto the your site’s page with payment form:Please Note
If, during the payment process on your website, the client goes through a path consisting of several pages, the script must be loaded onto all such pages. For an example, see the diagram below.
flowchart TD ext("External web-site") -- "Redirecting the client for the order payment" --> site subgraph site [Partner site] Page1("Page 1\nSelecting the payment method\nFingerprint API integration") --> Page2("Page 2\nEntering payment details\nFingerprint API integration") Page2 --> Page3("Page 3\nEntering additional order info\nFingerprint API integration") Page3 --> Page4("Final page for the payment\nConfirming the payment\nFingerprint API integration") end
-
After client redirection to the partner’s payment form or on performing the payment request, call the function
window.initUserFingerprint()
to send customer data:Where:
params
— object with additional parameters for the service. Deep structures with nested objects are not allowed.callback
— callback function, where the logic of the following payment page transition can be placed, as the transition should happen after collecting the client data.
Important Information
window.initUserFingerprint()
function should be called only after browser loads the script, otherwise the error initUserFingerprint is not defined
would be received.
Examples of the function calling are given below.
Checking the Data Collection¶
After sending the client data to the service, make the following request:
Possible responses:
- HTTP status
204
means that integration was sucessful. - HTTP status
400
or other means that the integration error is received.
Integration Example¶
Example of a complete integration of the fingerprint API service is given below:
function loadUserFingerprintScript(host) {
return new Promise((resolve, reject) => {
let attempt = 0;
const maxAttempts = 3;
const timeout = 500;
const maxTimeout = 3000;
function loadScript() {
const script = document.createElement('script');
script.src = `${host}/static/fp.js`;
script.defer = true;
script.addEventListener('load', () => {
resolve();
})
// On getting the error, the script makes several attempts to load.
script.addEventListener('error', () => {
if (attempt > maxAttempts) {
reject();
return;
}
let calculatedTimeout = timeout * 2**attempt;
const resultTimeout = calculatedTimeout > maxTimeout ? maxTimeout : calculatedTimeout
attempt += 1
setTimeout(() => {
loadScript()
}, resultTimeout)
})
document.body.appendChild(script)
return script;
}
loadScript()
})
}
// Calling the script initialization.
function initUserFingerprint() {
return window.initUserFingerprint()
}
loadUserFingerprintScript('https://fp.qiwi.com').then(initUserFingerprint)