Code Monkey home page Code Monkey logo

elixir-inter-sdk's Introduction

Inter

This is a simple wrapper around the Banco Inter's API - a Brazilian digital banking.

Installation

If available in Hex, the package can be installed by adding inter to your list of dependencies in mix.exs:

def deps do
  [
    {:inter, "~> 0.1.1"}
  ]
end

Usage:

api_key = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQ8Z4ZQ8Z4ZQ8Z\n-----END PRIVATE KEY-----\n"
api_cert = "-----BEGIN CERTIFICATE-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQ8Z4ZQ8Z4ZQ8Z\n-----END CERTIFICATE-----\n"
grant_type = "client_credentials"
scope = "pix.write pix.read webhook.read webhook.write cob.write pagamento-pix.write"
client_secret = "secret"
client_id = "client_id"

pix_charge_request = %Inter.Pix.Charge.Request{
  calendario: %Inter.Pix.Charge.Request.Calendario{
    expiracao: 3600
  },
  devedor: %Inter.Pix.Charge.Request.Devedor{
    cpf: "40894943030",
    nome: "Jhon Doe"
  },
  valor: %Inter.Pix.Charge.Request.Valor{
    original: "5.00", 
    modalidadeAlteracao: 1
  },
  infoAdicionais: [
    %Inter.Pix.Charge.Request.InfoAdicional{
      nome: "meu campo adicional", 
      valor: "algum valor 🤩"
    },
    %Inter.Pix.Charge.Request.InfoAdicional{
      nome: "meu campo adicional", 
      valor: "algum valor 🤩"
    },
    %Inter.Pix.Charge.Request.InfoAdicional{
      nome: "meu campo adicional", 
      valor: "algum valor 🤩"
    },
  ],
  chave: "46650032907724"
}

Inter.Client.new(client_id, client_secret, scope, grant_type, api_cert, api_key)
 |> Inter.pix_charge(pix_charge_request)

How to run locally?

  • docker-compose run --rm app bash
    • mix deps.get to install the dependencies
    • iex -S mix to open the elixir REPL

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/inter.

elixir-inter-sdk's People

Contributors

brunoocasali avatar jonatanrdsantos avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

elixir-inter-sdk's Issues

Add infoAdicionais to charge PIX

Add infoAdicionais to Charge PIX request:

example:

  "infoAdicionais": [
    {
    "nome": "Loren ipsum",
    "valor": "agora vai😎🥰"
    },
  ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.