Go to file
snogrammer d3c5e2a2e7 v0.1.2 (#1)
add store invoice specs. update readme.

add store invoice endpoints.

update repo info, docker images.

add store_id to config.

Co-authored-by: snogrammer <btcpay-gem@snogram.com>
Reviewed-on: https://code.snogrammer.com/snogrammer/btcpay/pulls/1
2020-11-21 14:51:14 -07:00
bin initial commit. 2020-07-15 19:36:16 -06:00
lib v0.1.2 (#1) 2020-11-21 14:51:14 -07:00
spec v0.1.2 (#1) 2020-11-21 14:51:14 -07:00
.gitignore ignore *.gem 2020-08-04 19:06:18 -06:00
.rspec initial commit. 2020-07-15 19:36:16 -06:00
.rubocop.yml initial commit. 2020-07-15 19:36:16 -06:00
.travis.yml initial commit. 2020-07-15 19:36:16 -06:00
Gemfile initial commit. 2020-07-15 19:36:16 -06:00
Gemfile.lock v0.1.2 (#1) 2020-11-21 14:51:14 -07:00
LICENSE.txt initial commit. 2020-07-15 19:36:16 -06:00
README.md v0.1.2 (#1) 2020-11-21 14:51:14 -07:00
Rakefile initial commit. 2020-07-15 19:36:16 -06:00
btcpay.gemspec v0.1.2 (#1) 2020-11-21 14:51:14 -07:00
docker-compose.btcpay.yml v0.1.2 (#1) 2020-11-21 14:51:14 -07:00

README.md

Btcpay Server

BTCPay Server Api Client

BTCPay Server is a free and open-source cryptocurrency payment processor which allows you to receive payments in Bitcoin and altcoins directly, with no fees, transaction cost or a middleman.

Installation

Add this line to your application's Gemfile:

gem 'btcpay'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install btcpay

Usage

Required Params

Auth Token

At least one of the following auth tokens are required. Auth tokens can be created via the following:

  1. auth_token
  • Scoped Api Tokens can be created via /Manage/APIKeys

  • BTCPAY_AUTH_TOKEN environment variable can also be used

  1. basic_auth_token
  • Legacy Api Key can be created per store via /stores/{store-id}/Tokens

  • BTCPAY_BASIC_AUTH_TOKEN environment variable can also be used

Base Url

A base_url is required to interact with the server.

  • BTCPAY_BASE_URL environment variable can also be used
client = BtcPay.new(auth_token: 'foobar', base_url: 'http://localhost:49392')

Response

A response consists of the following accessible attributes:

  1. #body - rubified response body
  2. #code - response status code
  3. #headers - response headers
  4. #raw - unaltered response body
  5. #status - :success/:failure

Request object types

All endpoints are accessed via namespaced Api resource. Example: client.users.create({ email: 'foo@bar.com', password: 'password', isAdministrator: false })

Api Keys:

  1. GET #current
  2. POST #create(payload)
  3. DELETE #revoke(key)
  4. DELETE #revoke!

Health:

  1. GET #status

Lightning:

  1. TODO - Set up local lightning network, testing, etc.

Pull Payments:

  1. GET #get(pull_payment_id)
  2. GET #payouts
  3. POST #create_payout(pull_payment_id, payload)

Server:

  1. GET #info

Store:

  1. GET #all
  2. POST #create(payload)
  3. GET #get(store_id)
  4. DELETE #delete(store_id)
  5. PUT #update(store_id, payload)
  • Invoices:
  1. GET #all(store_id)
  2. POST #create(store_id, payload)
  3. GET #get(store_id, invoice_id)
  4. DELETE #delete(store_id, invoice_id)
  5. POST #update_status(store_id, invoice_id, payload, status)
  6. POST #unarchive(store_id, invoice_id)
  • Payment Requests:
  1. GET #all(store_id)
  2. POST #create(store_id, payload)
  3. GET #get(store_id, request_id)
  4. DELETE #delete(store_id, request_id)
  5. PUT #update(store_id, request_id, payload)
  • Payouts:
  1. POST #approve(store_id, payout_id, payload)
  2. DELETE #delete(store_id, payout_id)
  • Pull Payments:
  1. GET #all(store_id)
  2. POST #create(store_id, payload)
  3. DELETE #delete(store_id, pull_payment_id)

Users:

  1. GET #me
  2. POST #create(payload)

Request helpers

Api Keys:

  • Authorize
  1. GET #html(permissions: [], application_name:, strict: true, selective_stores: false)
  2. #link(permissions: [], application_name:, strict: true, selective_stores: false)

Environment Variables

btcpay can be initialized with either arguments or ENV:

Variable Description Default
BTCPAY_AUTH_TOKEN BtcPay Auth Token -
BTCPAY_BASIC_AUTH_TOKEN BtcPay Basic Auth Token -
BTCPAY_BASE_URL BtcPay Base Url -

BtcPay Docker Compose

To get up and running locally quickly, a BTCPayServer docker-compose file has been added to test local API interactions. To get up and running:

  1. $ docker-compose -f docker-compose.btcpay.yml up
  2. $ open http://localhost:49392
  • Note: regtest environment default to allow for block/coin creation for test purpose
  • testnet environment should be used for integration/staging testing prior to production promotion.
  • mainnet is the real network.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/snogrammer/btcpay.

License

The gem is available as open source under the terms of the MIT License.