Version: current

Document Verification

About this guide

This page explains how to verify if the document provided by the customer is a valid one. This is very helpful to reduce the number of declined payments due to invalid document ID.

If you are not integrated with EBANX Direct API yet, please take a look in this basic guide about it. Are you not sure if EBANX Direct API is the best option for your e-commerce? Please, talk with one of our integration specialists.

What you will need

Before starting your integration, please make sure that you have:

  1. An EBANX Sandbox account. That's not the case? Please sign up for an Sandbox Account here;

How it works

To check a document using EBANX.js, follow the steps below:

  1. Add EBANX.js to your webpage

    Our client SDK enables you to securely collect payment information from your customers. Add the following script to your webpage:

    <script type="text/javascript" src="https://ebanx-js.ebanx.com/v1.106.0/dist/ebanx.js"></script>

    And initialize it with your Merchant's Configuration:

    EBANX.init({
    publicIntegrationKey: 'your_integration_key_goes_here',
    country: 'br',
    mode: 'test',
    });
  2. Create an object with the document information

    Create an object with with the following fields:

    const docInformation = {
    type: 'br_cpf',
    document: '85351346893',
    };

    The available document types are:

    CountryDocumentType Parameter Value
    ArgentinaCDIar_cdi
    ArgentinaCUILar_cuil
    ArgentinaCUITar_cuit
    ArgentinaDNIar_dni
    BrazilCPFbr_cpf
    BrazilCNPJbr_cnpj
    ChileRUTcl_rut
    ColombiaCCco_cc
    ColombiaCEco_ce
    ColombiaNITco_nit
    EcuadorDOCec_doc
    PeruDOCpe_doc
    UruguayCIuy_ci
    South AfricaIDza_id
  3. Check if the document provided is valid

    Call the EBANX.utils.document.check function using the object created in the previous step.

    EBANX.utils.document
    .check(docInformation)
    .then((verificationData) => {
    // use the verificationData object to fullfil your payment
    })
    .catch((error) => {
    // handle any errors that can happen
    });

    EBANX.utils.document.check returns a Promise object, so, make sure you handle the asynchrounous call properly by using a callback function. A successful authentication response contains the following fields:

    Valid Document:

    //The verificationData object created in the previous step will have the following fields:
    {
    "status": "success",
    "data": {
    "document": {
    "isValid": true,
    "maskedField": "853.513.468-93"
    }
    }
    }

    Invalid Document:

    //The verificationData object created in the previous step will have the following fields:
    {
    "status": "success",
    "data": {
    "document": {
    "isValid": false,
    "maskedField": ""
    }
    }
    }

Live sample

Here's a quick sample of how you can use EBANX.js to verify a document number:

Getting help

We hope this article was enlightening, but in case we’ve failed to take out your doubts you have the following options to keep on seeking for answers:

  • If you’re not our partner yet and would like to know more about our prices and conditions please fill our this form and our commercial team will get in touch with you.
  • In case you’re already our partner please get in touch with our support team at integration@ebanx.com.
Last updated on by FlavioCostaeSilva