GithubHelp home page GithubHelp logo

bcash-ruby's Introduction

#Bcash Ruby

Gem Version Build Status Code Climate Coverage Status

Ruby wrapper for the Bcash API. This gem provides wrapper for account and transaction methods.

Installation

gem install bcash-ruby

Resources

Configuration

Bcash.configure do |b|
  b.email = Rails.application.secrets.bcash["email"]
  b.token = Rails.application.secrets.bcash["token"]
end

Usage Examples

Search accounts by CPF

  client = Bcash::Client.new
  response = client.search_account_by_cpf('07411111111')
  response.code # 1
  response.cpf # 074111111111
  response.message # Foi encontrado 1 registro para o CPF ou email informado!
  response.accounts.size # 1
  response.accounts.first # { "mail" => '[email protected]', "token" => 'kx4F3mkZDlGUejQNKWdnP5Ttmk', "idClient" => '205' }

Create account

  data = {
    owner: {
      email: "[email protected]",
      gender: "M",
      name: "José o Vendedor",
      cpf: "43677708699",
      birth_date: "12/12/1912"
    },
    address: {
      address: "Rua Agostinho",
      zip_code: "81560-040",
      number: "1000",
      neighborhood: "Centro",
      complement: "Casa",
      city: "Curitiba",
      state: "PR"
    },
    contact: {
      phone_number: "41-3333-3333"
    }
  }

  client = Bcash::Client.new
  response = client.create_account(data)
  response.success? # true
  response.message # Conta criada com sucesso

Find Transaction

  client = Bcash::Client.new

  # Find by order id
  response = client.find_by_order_id('1001')
  response.success? # true
  response.transaction
    # { "id_transacao"=>"123456",
    # "data_transacao"=>"07/10/2014",
    # "data_credito"=>"22/10/2014",
    # "valor_original"=>"5.00", ...}

  # Find by transaction_id
  response = client.find_by_transaction_id('2343856')
  response.success? # false
  response.message # Pedido não localizado

Verify Bcash return

  data = {
    transacao: '2833',
    status: 'Transação em Andamento',
    cod_status: '0',
    valor_original: '2145.23',
    valor_loja: '2083.23',
    token:  '1211CF51917E074BC3784592C71FC'
  }

  client = Bcash::Client.new
  response = client.verify_return(data)
  response.verified? #true

Supported Ruby Versions

This library aims to support and is [tested against][travis] the following Ruby implementations:

  • Ruby 1.9.3
  • Ruby 2.0.0
  • Ruby 2.1.0
  • Rubinius

If something doesn't work on one of these interpreters, it's a bug.

This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.

License

Copyright (c) 2014 Raphael Costa and minestore, Inc. See LICENSE for details.

bcash-ruby's People

Contributors

raphaelcosta avatar

Watchers

 avatar  avatar

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.