Boleto

Para criar uma cobrança ou um pedido com boleto, devemos incluir o objeto boleto dentro do nó payment, assim como a propriedade "payment_method": "boleto". O objeto boleto contém as seguintes propriedades:

AtributosTipoDescrição
bankstringCódigo do banco. 001 (Banco do Brasil); 033 (Santander); 237 (Bradesco); 341 (Itau); 745 (Citibank) e 104 (Caixa Econômica Federal).
instructionsstringInstruções do boleto. Max: 256 caracteres.
due_atdatetimeData de vencimento. (Opcional)
nosso_numerostringNúmero que identifica unicamente um boleto para uma conta.
typestringTipo de espécie do boleto.DM (Duplicata Mercantil) e BDP (Boleto de proposta)
metadataobjectObjeto chave/valor utilizado para armazenar informações adicionais sobre o pagamento.Saiba mais sobre metadata.
document_numberstringIdentificador do boleto. Max: 16 caracteres.

❗️

BOLETOS COM REGISTRO TÊM CAMPOS OBRIGATÓRIOS

Para requisições de cobrança de boletos com registro os campos name, address e document do cliente (objeto customer) devem ser enviados OBRIGATORIAMENTE.

{
    "items": [
        {
            "amount": 2990,
            "description": "Chaveiro do Tesseract",
            "quantity": 1
        }
    ],
    "customer": {
        "name": "Tony Stark",
        "email": "[email protected]",
        "address": {
    	"line_1": "375, Av. General Justo, Centro",
    	"line_2": "8º andar",
    	"zip_code": "20021130",
    	"city": "Rio de Janeiro",
    	"state": "RJ",
    	"country": "BR"
    }
    },
    "shipping": {
        "amount": 100,
        "description": "Stark",
        "recipient_name": "Tony Stark",
        "recipient_phone": "24586787867",
        "address": {
            "line_1": "10880, Malibu Point, Malibu Central",
            "zip_code": "90265",
            "city": "Malibu",
            "state": "CA",
            "country": "US"    
        }
    },
    "payments": [
        {
            "payment_method": "boleto",
      "boleto": {
        "instructions": "Pagar até o vencimento",
        "due_at": "2022-09-20T00:00:00Z",
        "document_number": "123",
        "type": "DM"            
                    }
                }
           
        
    ]
}
{
  "id": "or_56GXnk6T0eU88qMm",
  "code": "YV3RCRIN24",
  "amount": 3090,
  "currency": "BRL",
  "closed": true,
  "items": [
    {
      "id": "oi_6rXqKEzuZYcRo2zL",
      "description": "Chaveiro do Tesseract",
      "amount": 2990,
      "quantity": 1,
      "status": "active",
      "created_at": "2019-10-16T17:36:30Z",
      "updated_at": "2019-10-16T17:36:30Z"
    }
  ],
  "customer": {
    "id": "cus_x4nz0P4SbOTA0KBZ",
    "name": "Tony Stark",
    "email": "[email protected]",
    "document": "14582256988",
    "type": "individual",
    "delinquent": false,
    "created_at": "2019-05-02T17:06:01Z",
    "updated_at": "2019-06-12T14:50:18Z",
    "phones": {}
  },
  "shipping": {
    "amount": 100,
    "description": "Stark",
    "recipient_name": "Tony Stark",
    "recipient_phone": "24586787867",
    "address": {
      "city": "Malibu",
      "state": "CA",
      "country": "US",
      "zip_code": "90265",
      "line_1": "10880, Malibu Point, Malibu Central"
    }
  },
  "status": "pending",
  "created_at": "2019-10-16T17:36:30Z",
  "updated_at": "2019-10-16T17:36:30Z",
  "closed_at": "2019-10-16T17:36:30Z",
  "ip": "52.168.67.32",
  "session_id": "322b821a",
  "device": {
    "platform": "ANDROID OS"
  },
  "location": {
    "latitude": "-22.970722",
    "longitude": "43.182365"
  },
  "charges": [
    {
      "id": "ch_K2rJ5nlHwTE4qRDP",
      "code": "YV3RCRIN24",
      "gateway_id": "3b4bb2d9-19b3-4638-a974-0bb914fff472",
      "amount": 3090,
      "status": "pending",
      "currency": "BRL",
      "payment_method": "boleto",
      "created_at": "2019-10-16T17:36:30Z",
      "updated_at": "2019-10-16T17:36:31Z",
      "customer": {
        "id": "cus_x4nz0P4SbOTA0KBZ",
        "name": "Tony Stark",
        "email": "[email protected]",
        "document": "14582256988",
        "type": "individual",
        "delinquent": false,
        "created_at": "2019-05-02T17:06:01Z",
        "updated_at": "2019-06-12T14:50:18Z",
        "phones": {}
      },
      "last_transaction": {
        "id": "tran_bZ0N3DjjUzTW68eq",
        "transaction_type": "boleto",
        "gateway_id": "044581ea-67e8-4772-bd56-f10ade5499de",
        "amount": 3090,
        "status": "generated",
        "success": true,
        "url": "https://sandbox.mundipaggone.com/Boleto/ViewBoleto.aspx?044581ea-67e8-4772-bd56-f10ade5499de",
        "pdf": "https://api.mundipagg.com/core/v1/transactions/tran_bZ0N3DjjUzTW68eq/pdf",
        "line": "34191.75462 24615.781234 41234.510000 3 83840000003090",
        "barcode": "https://api.mundipagg.com/core/v1/transactions/tran_bZ0N3DjjUzTW68eq/barcode",
        "qr_code": "https://api.mundipagg.com/core/v1/transactions/tran_bZ0N3DjjUzTW68eq/qrcode",
        "nosso_numero": "46246157",
        "type": "DM",
        "document_number": "123",
        "instructions": "Pagar até o vencimento",
        "due_at": "2020-09-20T00:00:00Z",
        "created_at": "2019-10-16T17:36:30Z",
        "updated_at": "2019-10-16T17:36:30Z",
        "gateway_response": {
          "code": "201"
        },
        "antifraud_response": {}
      }
    }
  ],
  "checkouts": []
}
//This example was built using MundiAPI-PHP SDK.
//For more information, please refer to https://github.com/mundipagg/MundiAPI-PHP

$secretKey = 'sk_test_4tdVXpseumRmqbo'; //the secret key will be provided by MundiPagg.
$basicAuthPassword = ''; //fill it with an empty string

$apiClient = new \MundiAPILib\MundiAPIClient(
    $secretKey,
    $basicAuthPassword
);

$orderController = $apiClient->getOrders();

$customer = new \MundiAPILib\Models\CreateCustomerRequest();
$customer->name = "Tony Stark";
$customer->email = "[email protected]";
$customer->address = new \MundiAPILib\Models\CreateAddressRequest();
$customer->address->street = "Av. General Justo, Centro";
$customer->address->number = "375";
$customer->address->zipCode = "20021130";
$customer->address->neighborhood = "Centro";
$customer->address->city = "Rio de Janeiro";
$customer->address->state = "RJ";
$customer->address->country = "BR";

$boleto = new \MundiAPILib\Models\CreateBoletoPaymentRequest();
$boleto->bank = "033";
$boleto->instructions = "Pagar até o vencimento";
$boleto->dueAt = new \DateTime('2020-09-20T00:00:00Z');

$request = new \MundiAPILib\Models\CreateOrderRequest();

$request->items = [new \MundiAPILib\Models\CreateOrderItemRequest()];
$request->items[0]->description = "Tesseract Bracelet";
$request->items[0]->quantity = 1;
$request->items[0]->amount = 2290; // this value should be in cents

$request->payments = [new \MundiAPILib\Models\CreatePaymentRequest()];
$request->payments[0]->paymentMethod = "boleto";
$request->payments[0]->boleto = $boleto;
$request->customer = $customer;

$result = $orderController->createOrder($request);

echo json_encode($result, JSON_PRETTY_PRINT);
package examples.order;

import com.mundipagg.api.MundiAPIClient;
import com.mundipagg.api.controllers.OrdersController;
import com.mundipagg.api.http.client.*;
import com.mundipagg.api.models.*;
import org.joda.time.DateTime;

import java.util.ArrayList;

public class CreateOrderBankSlip {
	
	public static void main(String[] args) {
		
        String basicAuthUserName = "sk_test_4tdVXpseumRmqbo"; // The username to use with basic authentication
        String basicAuthPassword = ""; // The password to use with basic authentication

        MundiAPIClient client = new MundiAPIClient(basicAuthUserName, basicAuthPassword);

        OrdersController orders_controller = new OrdersController();

        CreateCustomerRequest customer = new CreateCustomerRequest();
        customer.setName("sdk customer order");
        customer.setEmail("[email protected]");
        customer.setAddress(new CreateAddressRequest());
        customer.getAddress().setStreet("Malibu Point");
        customer.getAddress().setNumber("10880");
        customer.getAddress().setZipCode("90265");
        customer.getAddress().setNeighborhood("Central Malibu");
        customer.getAddress().setCity("Malibu");
        customer.getAddress().setState("CA");
        customer.getAddress().setCountry("US");

        CreateBoletoPaymentRequest create_boleto_payment_request = new CreateBoletoPaymentRequest();
        create_boleto_payment_request.setBank("033");
        create_boleto_payment_request.setInstructions("Pagar até o vencimento");
        create_boleto_payment_request.setDueAt(DateTime.parse("2019-12-31T00:00:00Z"));

        CreateOrderRequest request = new CreateOrderRequest();

        CreateOrderItemRequest orderItem = new CreateOrderItemRequest();
        orderItem.setDescription("Tesseract Bracelet");
        orderItem.setQuantity(3);
        orderItem.setAmount(1490);
        ArrayList<CreateOrderItemRequest> listOrderItem = new ArrayList<CreateOrderItemRequest>();
        listOrderItem.add(orderItem);
        request.setItems(listOrderItem);

        CreatePaymentRequest paymentItem = new CreatePaymentRequest();
        paymentItem.setPaymentMethod("boleto");
        paymentItem.setBoleto(create_boleto_payment_request);
        request.setCustomer(customer);
        ArrayList<CreatePaymentRequest> lisPaymentItem = new ArrayList<CreatePaymentRequest>();
        lisPaymentItem.add(paymentItem);
        request.setPayments(lisPaymentItem);


        orders_controller.createOrderAsync(request, new APICallBack<GetOrderResponse>() {
            public void onSuccess(HttpContext context, GetOrderResponse response) {

                System.out.println("Order bank slip create !");
                System.out.println("Status response: " + context.getResponse().getStatusCode());
                System.out.println("Order result status: " + response.getStatus());
                System.out.println("Order id: " + response.getId());

            }

            public void onFailure(HttpContext context, Throwable error) {

                System.out.println("Status response: " + context.getResponse().getStatusCode());
                System.out.println(error.getMessage());
                error.printStackTrace();
            }
        });
    }

}
from mundiapi.mundiapi_client import MundiapiClient
from mundiapi.models import *
from mundiapi.controllers import *
from mundiapi.exceptions.error_exception import *

MundiapiClient.config.basic_auth_user_name = "SUA_SECRET_KEY:"
orders_controller = orders_controller.OrdersController()

customer = create_customer_request.CreateCustomerRequest()
customer.name = "sdk customer test"
customer.email = "[email protected]"
customer.address = create_address_request.CreateAddressRequest()
customer.address.street = "Malibu Point"
customer.address.number = "10880"
customer.address.zip_code = "90265"
customer.address.neighborhood = "Central Malibu"
customer.address.city = "Malibu"
customer.address.state = "CA"
customer.address.country = "US"

boleto = create_boleto_payment_request.CreateBoletoPaymentRequest()
boleto.bank = "033"
boleto.instructions = "Pagar até o vencimento"
boleto.due_at = '2019-12-31T00:00:00Z'

request = create_order_request.CreateOrderRequest()

request.items = [create_order_item_request.CreateOrderItemRequest()]
request.items[0].description = "Tesseract Bracelet"
request.items[0].quantity = 3
request.items[0].amount = 1490

request.payments = [create_payment_request.CreatePaymentRequest()]
request.payments[0].payment_method = "boleto"
request.payments[0].boleto = boleto
request.customer = customer

try:
    result = orders_controller.create_order(request)
    assert result.status == "pending"
    assert result.charges[0].status == "pending"
    assert result.charges[0].last_transaction.success == True
    assert result.charges[0].last_transaction.status == "generated"
    assert result.charges[0].last_transaction.url is not None
    assert result.charges[0].last_transaction.bank is not None
    assert result.charges[0].last_transaction.pdf is not None
    assert result.charges[0].last_transaction.instructions is not None
	print("Order id is: ", result.id)
    print("Order result status: ", result.status)
    print("Boleto pdf: ", result.charges[0].last_transaction.pdf)
except ErrorException as ex:
    print(ex.message)
    print("Errors: ", ex.errors)
except Exception as ex:
    raise ex

Status das transações de boleto (Transaction)

As transações de boleto podem possuir os seguintes status:

StatusDescrição
generatedGerado
viewedVisualizado
underpaidPago a menor
overpaidPago a maior
paidPago
voidedCancelado
with_errorCom erro
failedFalha
Website Localization