BR Financial ID framework

The BR - Financial ID framework masks string input of formatted CPF and CNPJ numbers from Brazil. It can mask the forms with or without punctuation. The earlier digits are masked with a chained instance of CM Numeric, and a checksum is calculated from them for the last two. The input and output numbers are both validated for length, format and accuracy of the checksum. The format of CPF has 9 randomized digits with a total of 1 billion combinations, making masked collisions possible by its nature but very unlikely.

Configuration parameters

This framework was created based on a plugin developed by professional services. It’s default instance replicates the behavior distributed to clients in the field. At this time there is no UI for framework, though additional instances can be created through the API with two configurable options:

  • maskInvalidInput: This is configurable to true or false. If false, it will throw a NonConformantDataException for string inputs that do not pass validation as CPF or CNPJ numbers.

  • fallbackAlgorithm: This is a configurable algorithm reference. If maskInvalidInput is true, then a string input that does not pass validation will be sent to this algorithm. The chained algorithm may throw its own NonConformantDataExceptions.

Create a payment algorithm via API

Here is an example post to create an instance of BR - Financial ID with a fallback algorithm enabled:

Copy
{
      "algorithmName": "BR Financial ID - Custom Fallback",
      "algorithmType": "COMPONENT",
      "description": "Masks CPF and CNPJ Brazilian registry numbers and falls back to a custom algorithm.",
      "maskType": "STRING",
      "frameworkId": 33,
      "pluginId": 7,
      "algorithmExtension": {
        "maskInvalidInput": true,
        "fallbackAlgorithm": {
          "name": "dlpx-core:CM Alpha-Numeric"        }
      }
    }

The algorithm name can be changed to any valid algorithm in the chosen masking engine. The appropriate framework ID and plugin ID should be taken from the chosen compliance node.

Examples

Examples of valid CPF and CNPJ values before and after masking:

Copy
842.262.714-08   →   209.674.029-05
70.193.999/0001-18   →   28.823.097/0001-51
84226271408   →   20967402905
70193999000118   →   28823097000151

Examples of invalid inputs processed using a fallback algorithm:

Copy
83.tomato.590/0001-50   →   84.byhmsk.760/8830-11
11111111111111   →   76005296937223
2   →   1

If maskInvalidInput is set to false, invalid inputs are not masked and a NonConformantDataException is generated during job execution.

Create an algorithm using this framework

To create an algorithm using this framework, follow the steps in Create an Algorithm and select BR – Financial ID during the Configuration step.