All Projects → mundipagg → Boleto Api

mundipagg / Boleto Api

Licence: mit
API for register and generate "Boletos"

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Boleto Api

Python N26
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/
Stars: ✭ 116 (-47.75%)
Mutual labels:  api, bank
N26
API and CLI to get information of your N26 account
Stars: ✭ 107 (-51.8%)
Mutual labels:  api, bank
Cnbankcard
🏦 由银行卡卡号解析出发卡行和卡别,适用于中国国内多数银行,返回JSON数据。
Stars: ✭ 853 (+284.23%)
Mutual labels:  api, bank
N26
💳 Un-official node.js module for interact with your N26 (previously Number26) account
Stars: ✭ 128 (-42.34%)
Mutual labels:  api, bank
Tensei
🚀 Content management and distribution with a touch of elegance.
Stars: ✭ 217 (-2.25%)
Mutual labels:  api
Pan Configurator
Framework and utilities to easily manage and edit Palo Alto Network PANOS devices
Stars: ✭ 216 (-2.7%)
Mutual labels:  api
Fintech To Ynab
Automatically push Monzo and Starling transactions into YNAB in real time.
Stars: ✭ 214 (-3.6%)
Mutual labels:  bank
Crafatar
A blazing fast API for Minecraft faces
Stars: ✭ 212 (-4.5%)
Mutual labels:  api
Hexo Theme Doc
A documentation theme for the Hexo blog framework
Stars: ✭ 222 (+0%)
Mutual labels:  api
Praw
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to Reddit's API.
Stars: ✭ 2,675 (+1104.95%)
Mutual labels:  api
Bookmarks.dev
Bookmarks and Code Snippets Manager for Developers & Co
Stars: ✭ 218 (-1.8%)
Mutual labels:  api
Graphql Php
A PHP7 implementation of the GraphQL specification.
Stars: ✭ 217 (-2.25%)
Mutual labels:  api
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (-5.41%)
Mutual labels:  api
Ray
a framework that helps you to deliver well-designed python APIs
Stars: ✭ 215 (-3.15%)
Mutual labels:  api
Controller
Complete, fast and testable actions for Rack and Hanami
Stars: ✭ 221 (-0.45%)
Mutual labels:  api
Chartbrew
Open-source web platform for creating charts out of different data sources (databases and APIs) 📈📊
Stars: ✭ 199 (-10.36%)
Mutual labels:  api
Hcloud Go
A Go library for the Hetzner Cloud API
Stars: ✭ 218 (-1.8%)
Mutual labels:  api
Flipper
🐬 Beautiful, performant feature flags for Ruby.
Stars: ✭ 2,732 (+1130.63%)
Mutual labels:  api
Goku Api Gateway
A Powerful HTTP API Gateway in pure golang!Goku API Gateway (中文名:悟空 API 网关)是一个基于 Golang开发的微服务网关,能够实现高性能 HTTP API 转发、服务编排、多租户管理、API 访问权限控制等目的,拥有强大的自定义插件系统可以自行扩展,并且提供友好的图形化配置界面,能够快速帮助企业进行 API 服务治理、提高 API 服务的稳定性和安全性。
Stars: ✭ 2,773 (+1149.1%)
Mutual labels:  api
Php Fedex Api Wrapper
This library provides a fluid interface for constructing requests to the FedEx web service API.
Stars: ✭ 215 (-3.15%)
Mutual labels:  api

mundipagg maturity

GoDoc Go Report Card

Codacy Badge Maintainability

What is the Online Registered "Boleto" API?

BoletoOnline is an API for boleto's online register in banks and boleto's creation for payments.

Currently, we support the following banks:

  • Banco do Brasil
  • Caixa
  • Citibank
  • Santander
  • BradescoShopFacil
  • BradescoNetEmpresas
  • Itau

The integration order will follow the list above but we may have changes considering our clients demands.

API Building

The API was developed using GO language and therefore it is necessary to install the language tools in case you need to compile the application from the source.

GO can be downloaded here

Before cloning the Project, you should create the file path inside $GOPATH

% mkdir -p "$GOPATH/src/github.com/mundipagg"
% cd $GOPATH/src/github.com/mundipagg 
% git clone https://github.com/mundipagg/boleto-api

Before compiling the application, you should install the Glide, which is the application dependency manager.

After installing GO, do:

% cd devops
% ./build

The build.sh script will download the application dependencies and install wkhtmltox, which is necessary to create boleto's in PDF format.

Running the application

Running the API with default configurations Eg:

Linux (*NIX):

% ./boleto-api

Windows:

% boleto-api.exe

If you want to run the API in dev mode, which will load all standard environment variables, you should execute the application like this:

% ./boleto-api -dev

In case you want to run the application in mock mode using in memory database instead of bank integration, you should use the mock option:

% ./boleto-api -mock

In case you want to run the application with log turned off, you should use the option -nolog:

% ./boleto-api -nolog

You can combine all these options and, in case you want to use them altogether, you can simply use the -airplane-mode option

% ./boleto-api -airplane-mode

By default, boleto api will up and running a https server but you can run in http mode with the following option

% ./boleto-api -http-only

Using Boleto API Online

You can use Postman to request the API's services or even the curl See following examples

Banco do Brasil

% curl -X POST \
  http://localhost:3000/v1/boleto/register \
  -d '{
    "Authentication" : {
        "Username":"user",
        "Password":"pass"
    },
    "Agreement":{
        "AgreementNumber":11111,
        "WalletVariation":19,
        "Wallet":17,
        "Agency":"123",
        "AgencyDigit":"2",
        "Account":"1231231",
        "AccountDigit":"3"
    },
    "Title":{
      "ExpireDate": "2017-05-25",
        "AmountInCents":200,
        "OurNumber":101405187,
        "Instructions":"Instruções"
    },
    "Buyer":{
        "Name":"BoletoOnlione",
        "Document": {
            "Type":"CNPJ",
            "Number":"73400584000166"
        },
        "Address":{
            "Street":"Rua Teste",
            "Number": "11",
            "Complement":"",
            "ZipCode":"12345678",
            "City":"Rio de Janeiro",
            "District":"Melhor bairro",
            "StateCode":"RJ"
        }
    },
    "Recipient":{
        "Name":"Nome do Recebedor",
        "Document": {
            "Type":"CNPJ",
            "Number":"12312312312366"
        },
        "Address":{
            "Street":"Rua do Recebedor",
            "Number": "322",
            "Complement":"2º Piso loja 404",
            "ZipCode":"112312342",
            "City":"Rio de Janeiro",
            "District":"Outro bairro",
            "StateCode":"RJ"
        }
    },
    "BankNumber":1
}

Response Banco do Brasil

{
  "Url": "http://localhost:3000/boleto?fmt=html&id=g8HXWatft9oMLdTMAqzxbnPYFv3sqgV_KD0W7j8Cy9nkCLZMIK1WH2p9JwP1Jzz4ZtohmQ==",
  "DigitableLine": "00190000090101405100500066673179971340000010000",
  "BarCodeNumber": "00199713400000100000000001014051000006667317",
  "Links": [
    {
      "href": "http://localhost:3000/boleto?fmt=html&id=wOKZh6K_moLwXTW0Xr3oelh9YkYWXdl3VyURiQ-bu6TcuDzxdZI52BnQnuzNpGeh4TapUA==",
      "rel": "html",
      "method": "GET"
    },
    {
      "href": "http://localhost:3000/boleto?fmt=pdf&id=wOKZh6K_moLwXTW0Xr3oelh9YkYWXdl3VyURiQ-bu6TcuDzxdZI52BnQnuzNpGeh4TapUA==",
      "rel": "pdf",
      "method": "GET"
    }
  ]
}

Caixa

curl -X POST \
  http://localhost:3000/v1/boleto/register \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'postman-token: 1bc1dd5f-cc34-0716-3d56-f18798d3fb39' \
  -d '{
    "BankNumber": 104,
    "Agreement": {
        "AgreementNumber": 200656,
        "Agency":"1679"
    },
    "Title": {
        "ExpireDate": "2017-08-30",
        "AmountInCents": 1000,
        "OurNumber": 0,
        "Instructions": "Mensagem",
        "DocumentNumber": "NPC160517"
    },
    "Buyer": {
        "Name": "TESTE PAGADOR 001",
        "Document": {
            "Type": "CPF",
            "Number": "57962014849"
        },
        "Address": {
            "Street": "SAUS QUADRA 03",
            "Number": "",
            "Complement": "",
            "ZipCode": "20520051",
            "City": "Rio de Janeiro",
            "District": "Tijuca",
            "StateCode": "RJ"
        }
    },
    "Recipient": {
        "Document": {
            "Type": "CNPJ",
            "Number": "00732159000109"
        }
    }
}'

Response

{
    "id": "e1EVv1KRwuGX6OXOo7PNGYR-ePD1VPtjv5iqya1LJiLiaIKozN11YMiePNk-WebdgP4eIA==",
    "digitableLine": "10492.00650 61000.100042 09922.269841 3 72670000001000",
    "barCodeNumber": "10493726700000010002006561000100040992226984",
    "ourNumber": "14000000099222698",
    "links": [
        {
            "href": "https://200.201.168.67:8010/ecobranca/SIGCB/imprimir/0200656/14000000099222698",
            "rel": "pdf",
            "method": "GET"
        }
    ]
}

In case of Caixa, the impress of boleto will be handled by Caixa. So API will return the Caixa's boleto URL.

The API's response will have the following pattern if any error occur:

{
  "Errors": [
    {
      "Code": "MPExpireDate",
      "Message": "Data de expiração não pode ser menor que a data de hoje"
    }
  ]
}

API Installation

For installation of the executable it's only necessary environment variables configured and the compiled application.

Edit file $HOME/.bashrc.sh

    export API_PORT="3000"
    export API_VERSION="0.0.1"
    export ENVIRONMENT="Development"
    export SEQ_URL="http://example.mundipagg.com"
    export SEQ_API_KEY="API_KEY"
    export ENABLE_REQUEST_LOG="false"
    export ENABLE_PRINT_REQUEST="true"
    export URL_BB_REGISTER_BOLETO="https://cobranca.desenv.bb.com.br:7101/registrarBoleto"
    export URL_BB_TOKEN="https://oauth.desenv.bb.com.br:43000/oauth/token"
    export MONGODB_URL="10.0.2.15:27017"
    export APP_URL="http://localhost:8080/boleto"
% go build && mv boleto-api /usr/local/bin

Then the application will be installed locally.

API Installation using Docker

Before deploying, you should open the file docker-compose and configure the information which is relevant to the environment. After setting up the docker-compose, you can install the application using the file deploy.sh

% cd devops
% ./build.sh
% ./deploy.sh . local

The script will create the Docker's volume directories, compile the application, mount the API's and MongoDB's images and upload the containers. For more information about docker-compose, see doc.

The parameters sent to the script show that the deploy will run locally and not via TFS. In case you don't send the argument "local", the script will use docker-compose.release.yml.

After being deployed, the application can be stoped or started.

% cd devops/
% ./stop.sh
% ./start.sh

Backup & Restore

Run the following command to backup the database:

% cd devops
% ./doBackup.sh

The generated backups, by default, will be stored in the diretory $HOME/backups with the name bck_boleto-api-YYYY-MM-DD.tar. To restore a backup:

% cd devops
% ./doRestore.sh

To do the restoration of the database it'll be asked for the restoration file date in the following pattern: YYYY-MM-DD.

Contributing

To contribute, see CONTRIBUTING

Using Mongo in Dev

You can use mongo in dev on Docker by using the following command

 % docker run --name mongo-boleto -p 27017:27017 -d mongo

Source Code Layout

The application root contains only the file main.go and some config and documentation files.

In the root, we have the following packages:

  • api: Rest Controllers
  • auth: Bank authentication
  • bank: Boleto's register interface
  • bb: Implementation of Banco do Brasil
  • caixa: Implementation of Caixa
  • citibank: Implementation of Citibank
  • boleto: User boleto's creation
  • cache: Database (key value) in-memory used only when the application is running in mock mode
  • config: Application config
  • db: Database persistency
  • devops: Contains the upload, deploy, backup and restore files from the application
  • validations: Basic data validations
  • log: Application log
  • models: Application's data structure
  • parser: XML parser
  • test: Tests utilitaries
  • tmpl: Template utilitaries
  • util: Miscellaneous utilitaries
  • integrationTests: Contains all black box tests
  • vendor: Thirdpart libraries

For more information

See FAQ

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].