class Docproof::PaymentProcessor

Constants

BTC_IN_SATOSHIS
MINIMUM_PRICE_IN_BTC

Attributes

bitcoin_address[R]
price_in_btc[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/docproof/payment_processor.rb, line 14
def initialize(options={})
  @bitcoin_address = options['pay_address'] || options['payment_address']

  # `price` given by the API is in satoshis (100_000_000 satoshis = 1 BTC)
  # and it is only available after successfully `register!` a document.
  @price_in_btc = MINIMUM_PRICE_IN_BTC
  @price_in_btc = options['price'].to_f / BTC_IN_SATOSHIS if options['price']
end

Public Instance Methods

perform!() click to toggle source
# File lib/docproof/payment_processor.rb, line 23
def perform!
  Coinbase.new(
    recipient: bitcoin_address,
    amount:    price_in_btc
  ).perform!
end