npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boleto-facil

v1.0.1

Published

SDK Node para integração com a API do Boleto Fácil.

Downloads

10

Readme

SDK Node para integração com o Boleto Fácil

Build Status Coverage Status

Este SDK (Software Development Kit) para o Boleto Fácil tem como objetivo abstrair, para desenvolvedores de aplicações Node, os detalhes de comunicação com a API do Boleto Fácil, tanto com o servidor de produção como com o servidor de testes (sandbox), de modo que o desenvolvedor possa se concentrar na lógica de negócio de sua aplicação.

Requisitos

  • Node (qualquer versão)

Integração

npm install boleto-facil --save

Limitações

O único item da API do Boleto Fácil que essa SDK não contempla é a notificação de pagamentos para aplicações Web, através da URL de notificação. Nesse caso, tanto a lógica de captura das requisições POST enviadas pelo Boleto Fácil com os dados dos pagamentos como a lógica da baixa das cobranças pagas ficam a cargo do sistema integrado com o Boleto Fácil.

Guia de uso

Por padrão, ao utilizar a API será utilizado o ambiente SANDBOX, para utilizar em produção, siga o exemplo abaixo:

import BoletoFacil from 'boleto-facil';

const boletoFacil = new BoletoFacil({
  production: true
});

Gerando uma cobrança

Charge é um método que representa uma cobrança do Boleto Fácil e que contém os atributos relacionados a ela, que são exatamente os atributos disponibilizados pela API do Boleto Fácil e podem ser conferidos aqui.

const chargeResponse = boletoFacil.issueCharge({
  token: '0192B1544430E3943D4F9E4AAAF94952DBF5DEC20590008C279A04EAD3059EEA',
  description: 'Pedido 48192 / TV 40 Polegadas / Cosméticos',
  reference: '',
  amount: '10.00',
  dueDate: '',
  installments: '',
  maxOverdueDays: '',
  fine: '',
  interest: '',
  discountAmount: '',
  discountDays: '',
  payerName: 'Cotabox',
  payerCpfCnpj: '21.842.162/0001-47',
  payerEmail: '',
  payerSecondaryEmail: '',
  payerPhone: '',
  payerBirthDate: '',
  billingAddressStreet: '',
  billingAddressNumber: '',
  billingAddressComplement: '',
  billingAddressNeighborhood: '',
  billingAddressCity: '',
  billingAddressState: '',
  billingAddressPostcode: '',
  notifyPayer: '',
  notificationUrl: '',
  responseType: '',
  feeSchemaToken: '',
  splitRecipient: '',
  paymentTypes: '',
  creditCardHash: '',
  creditCardNumber: '',
  creditCardHolderName: '',
  creditCardSecurityCode: '',
  creditCardExpirationMonth: '',
  creditCardExpirationYear: '',
  paymentAdvance: '',
});

chargeResponse.then(res => console.log(res));

A constante chargeResponse é uma promise que quando resolvida retorna a resposta da API da Boleto Fácil.

Consulta de saldo

Por padrão, as requisições feitas pelo SDK desserializam o retorno em JSON para popular os objetos com as informações das requisições, mas o SDK também provê a possibilidade de alterar a formatação do retorno da API para XML, conforme pode ser visto no exemplo abaixo:

const balance = boletoFacil.fetchBalance({
  token: '0192B1544430E3943D4F9E4AAAF94952DBF5DEC20590008C279A04EAD3059EEA',
  responseType: 'XML'
});

balance.then(res => console.log(res));

Solicitação de transferência

const response = boletoFacil.requestTransfer({
  token: '0192B1544430E3943D4F9E4AAAF94952DBF5DEC20590008C279A04EAD3059EEA',
});

response.then(res => console.log(res));

Consulta de pagamentos e cobranças

const charges = boletoFacil.listCharges({
  token: '0192B1544430E3943D4F9E4AAAF94952DBF5DEC20590008C279A04EAD3059EEA',
  beginPaymentDate: '30/05/2018',
});

charges.then(res => console.log(res));

Criação de favorecido (API Avançada)

A API avançada também está disponível no SDK. Segue abaixo um exemplo de criação de favorecido, com os principais atributos (e objetos) relacionados.

const payee = boletoFacil.createPayee({
  token: '0192B1544430E3943D4F9E4AAAF94952DBF5DEC20590008C279A04EAD3059EEA',
  notificationUrl: '',
  name: 'Isabella e Carolina Locações de Automóveis ME',
  cpfCnpj: '21.842.162/0001-47',
  email: '[email protected]',
  password: '12345',
  birthDate: '',
  phone: '(11) 3613-0831',
  linesOfBusiness: 'Fornecedor',
  tradingName: 'Isabella e Carolina Locações de Automóveis ME',
  reprName: 'Severino',
  reprCpfCnpj: '377.910.350-81',
  reprBirthDate: '25/09/2013',
  accountHolderName: 'Isabella e Carolina Locações de Automóveis ME',
  accountHolderCpfCnpj: '21.842.162/0001-47',
  bankNumber: '077',
  agencyNumber: '0001-9',
  accountNumber: '1211054-0',
  bankAccountType: 'CHECKING',
  accountComplementNumber: '',
  category: 'SERVICES',
  companyType: 'LTDA',
  street: 'Rua Manuel Soeiro Ramirez',
  number: '115',
  complement: '',
  neighborhood: 'Jardim Mimar',
  city: 'São Paulo',
  state: 'SP',
  postCode: '08534245',
  businessAreaId: '2024',
});

payee.then(res => console.log(res));

A tabela com os códigos de município do IBGE pode ser consultada aqui.

Suporte

Em caso de dúvidas, problemas ou sugestões, não hesite em contatar nossa equipe de suporte.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

| João Cavalcante | Leonardo Turbiani |-------------|--------| |João Cavalcante| Leonardo Turbiani |

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache 2.0 License - see the LICENSE.md file for details