Configuring Boleto

Learn how to configure Boleto for DigitalRiver.js with Elements.

If you're using DigitalRiver.js with Elements, you can create a Boleto payment method for your app or website in three easy steps:

Step 1: Build a Boleto Source Request and Details object

Build the Boleto Source Request and Details object. The Boleto Source Request object requires the following fields:

Boleto Source Details object

Use the Boleto Source Details object code sample.

{
    "returnUrl": "https://example.com",
    "nationalId": "16235836597"
}

The Boleto Source Details object requires the following fields:

Step 2: Create a Boleto source using DigitalRiver.js

Use the DigitalRiver.js library to create and mount elements to the HTML container.

The address object must contain postal code and state/province data that adheres to a standardized format using the state attribute. Note that the state attribute listed below corresponds to the countrySubdivision attribute used when providing address information. The payment session manages the correct field name on the backend.

var data = {
   "type":"boletoBancario",
   "sessionId":"ea03bf6f-84ef-4993-b1e7-b7d5ecf71d1f",
   "owner":{
      "firstName":"John",
      "lastName":"Doe",
      "email":"john.doe@gmail.com",
      "phoneNumber":"1555000000",
      "address":{
         "line1":"123 Main Street",
         "line2":"",
         "city":"Mossoró",
         "state":"SP",
         "postalCode":"59625-105",
         "country":"BR"
      }
   },
   "boletoBancario":{
      nationalId: "16704641000167"
   }
}

digitalriver.createSource(data).then(function(result) {    
    if (result.error) {        
        //handle errors    
    } else {        
        var source = result.source;        
        //send the source to back end        
        sendToBackend(source);    
    }
});

Boleto source response example

{
   "clientId":"gc",
   "channelId":"drdod15",
   "liveMode":false,
   "id":"42eace34-cd2c-47ff-bcde-5bedbbbffce1",
   "sessionId":"0f97ee7c-4c62-4ec6-b2c6-f36bd744ebdd",
   "clientSecret":"42eace34-cd2c-47ff-bcde-5bedbbbffce1_3606ed97-37c0-47d2-af40-79d062993ac0",
   "type":"boletoBancario",
   "reusable":false,
   "owner":{
      "firstName":"John",
      "lastName":"Doe",
      "email":"john.doe@gmail.com",
      "phoneNumber":"1555000000",
      "address":{
         "line1":"123 Main Street",
         "city":"Mossoró",
         "state":"SP",
         "postalCode":"59625-105",
         "country":"BR"
      }
   },
   "amount":"100.00",
   "currency":"BRL",
   "state":"pending_funds",
   "creationIp":"209.87.180.27",
   "createdTime":"2021-10-18T18:28:36.191Z",
   "updatedTime":"2021-10-18T18:28:36.191Z",
   "flow":"receiver",
   "language":"en",
   "boletoBancario":{
      "documentCode":"23790001246004987209031123456704579990000010000",
      "document":"https://link/to/the/payment-slip.pdf"
   }
}

Step 3: Use the authorized source

Once authorized, you can use the source by attaching it to a cart.

{
  "paymentMethod": {
    "sourceId": "e7ba0595-059c-460c-bad8-2812123b9313"
  }
}

Best practices

To use Boleto as a payment method:

  1. Optional. Set the locale and currency. curl --location --request GET 'https://{host}/v1/shoppers/me.json?locale=pt_BR&currency=BRL' \ --header 'Content-Type: application/json' --header 'authorization: bearer ***\

  2. Optional. Set the the cart address to the BR address.

  3. Attach the tax ID to the cart. This action inserts the tax ID into the payment session.

  4. Create a Boleto source with a payment session ID. Note that the tax ID is required when creating the Boleto source. The payment session ID provides the tax ID.

Last updated