GithubHelp home page GithubHelp logo

isabella232 / ruby-cli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitpay/ruby-cli

0.0 0.0 0.0 347 KB

Command line interface client for the ruby bitpay sdk

License: MIT License

Ruby 99.51% Shell 0.49%

ruby-cli's Introduction

BitPay Library for Ruby

GitHub license Travis Gem Coveralls Code Climate

Powerful, flexible, lightweight interface to the BitPay Bitcoin Payment Gateway API.

Installation

gem install bitpay-client

In your Gemfile:

gem 'bitpay-client', :require => 'bitpay'

Or directly:

require 'bitpay'

Configuration

The bitpay client creates a cryptographically secure connection to your server by pairing an API code with keys stored on your server. The library generates the keys as a .pem file, which is stored in $HOME/.bitpay/bitpay.pem or preferentially in an environment variable.

The client will generate a key when initialized if one does not already exist.

Basic Usage

Pairing with Bitpay.com

To pair with bitpay.com you need to have an approved merchant account.

  1. Login to your account
  2. Navigate to bitpay.com/api-tokens (Dashboard > My Account > API Tokens)
  3. Copy an existing pairing code or create a new token and copy the pairing code.
  4. Use the bitpay command line tool to pair with bitpay.com bitpay pair <pairing_code>

To create an invoice with a paired client:

The command line utility will save a PEM file in the file $HOME/.bitpay/bitpay.pem. When creating new clients, this pem file is needed in order to have an authorized client.

client = BitPay::Client.new(pem: File.read("#{ENV['HOME']}/.bitpay/bitpay.pem"))
invoice = client.create_invoice (id: <id>, price: <price>, currency: <currency>, facade: <facade>)

With invoice creation, price and currency are the only required fields. If you are sending a customer from your website to make a purchase, setting redirectURL will redirect the customer to your website when the invoice is paid.

Response will be a hash with information on your newly created invoice. Send your customer to the url to complete payment:

{
  "id"             => "DGrAEmbsXe9bavBPMJ8kuk",
  "url"            => "https://bitpay.com/invoice?id=DGrAEmbsXe9bavBPMJ8kuk",
  "status"         => "new",
  "btcPrice"       => "0.0495",
  "price"          => 10,
  "currency"       => "USD",
  "invoiceTime"    => 1383265343674,
  "expirationTime" => 1383266243674,
  "currentTime"    => 1383265957613
}

There are many options available when creating invoices, which are listed in the BitPay API documentation.

To get updated information on this invoice, make a get call with the id returned:

invoice = client.get_public_invoice(DGrAEmbsXe9bavBPMJ8kuk)'

The BitPay CLI gem requires the BitPay SDK gem. See the BitPay SDK Gem documentation for more details on using the BitPay Client SDK.

Testnet Usage

In order to pair with testnet, you will need a pairing code from test.bitpay.com and will need to use the bitpay client with the --test option.

API Documentation

API Documentation is available on the BitPay site.

Running the Tests

$ bundle install
$ bundle exec rake

jj

Found a bug?

Let us know! Send a pull request or a patch. Questions? Ask! We're here to help. We will respond to all filed issues.

Contributors

Click here to see a list of the contributors to this library.

ruby-cli's People

Contributors

arrtchiu avatar heisler3030 avatar joshuaestes avatar kyledrake avatar nmarley avatar philosodad avatar thoerner avatar unchaz 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.