Class: Docproof::PaymentProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/docproof/payment_processor.rb,
lib/docproof/payment_processor/coinbase.rb

Defined Under Namespace

Classes: Coinbase, MissingCredentials, MissingDependency

Constant Summary collapse

BTC_IN_SATOSHIS =
100_000_000
MINIMUM_PRICE_IN_BTC =
0.005

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PaymentProcessor

Returns a new instance of PaymentProcessor.



14
15
16
17
18
19
20
21
# 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

Instance Attribute Details

#bitcoin_addressObject (readonly)

Returns the value of attribute bitcoin_address.



11
12
13
# File 'lib/docproof/payment_processor.rb', line 11

def bitcoin_address
  @bitcoin_address
end

#price_in_btcObject (readonly)

Returns the value of attribute price_in_btc.



11
12
13
# File 'lib/docproof/payment_processor.rb', line 11

def price_in_btc
  @price_in_btc
end

Instance Method Details

#perform!Object



23
24
25
26
27
28
# File 'lib/docproof/payment_processor.rb', line 23

def perform!
  Coinbase.new(
    recipient: bitcoin_address,
    amount:    price_in_btc
  ).perform!
end