The dLocal Object


Create pre-built UI components to collect payment information with Smart Fields (simply referred to as fields in the API).

var fields = dlocal.fields({ 
    locale: 'en',
    country: 'BR'

This method creates an instance of fields, which manages a group of Smart Fields. It receives an options object. Available options are documented below:

localeStringThe IETF language tag of the locale to display placeholders and error strings in. Default is Spanish (es). Supported values are: es, en, pt, zh, cv, tr.
countryStringUser’s country code. ISO 3166-1 alpha-2 codes.
fontsArray (Optional)An array of custom fonts, which Smart Fields created from the fields object can use. Fonts can either be loaded via a CSS file by passing an object with the cssSrc attribute, or they can be loaded directly by passing a Font object.

cssSrc attribute

cssSrcStringA relative or absolute URL pointing to a CSS file with @font-face definitions, for example: ""

The Font object

familyStringThe name to give the font.
srcStringA valid src value pointing to your custom font file. This is usually (though not always) a link to a file with a .woff, .otf, or .svg suffix.
displayString (Optional)A valid font-display value.
styleStringOne of 'normal', 'italic', 'oblique'. Defaults to 'normal'.
unicodeRangeString (Optional)A valid unicode-range value.
weightString (Optional)A valid font-weight. Note that this is a string, not a number.


Use dlocalInstance.createPinToken() to convert information collected by Smart Fields into a token that you can safely pass to your server for use in an API call.

This token expires 10 minutes after it has been created, or after the operation is made.

   .then(function(result) {
       // Handle result.token
   .catch(function(result) {
       // Handle result.error

This method takes one argument:

  • field, the Smart Field you wish to tokenize data from. If applicable, the Smart Field pulls data from other Smart Fields you’ve created on the same instance of fields to tokenize (i.e: change pin operation).

dlocalInstance.createPinToken returns a Promise which resolves with a result object. This object has either:

result.tokenToken was created successfully
result.errorThere was an error. This includes client-side validation errors.