Class: CoinJarCheckout::IPN

Inherits:
Object
  • Object
show all
Defined in:
lib/coinjar-checkout/ipn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ IPN

Returns a new instance of IPN.



6
7
8
# File 'lib/coinjar-checkout/ipn.rb', line 6

def initialize(args)
  reset(args)
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def amount
  @amount
end

#bitcoin_addressObject

Returns the value of attribute bitcoin_address.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def bitcoin_address
  @bitcoin_address
end

#bitcoin_amountObject

Returns the value of attribute bitcoin_amount.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def bitcoin_amount
  @bitcoin_amount
end

#currencyObject

Returns the value of attribute currency.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def currency
  @currency
end

#feeObject

Returns the value of attribute fee.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def fee
  @fee
end

#ipn_digestObject

Returns the value of attribute ipn_digest.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def ipn_digest
  @ipn_digest
end

#merchant_invoiceObject

Returns the value of attribute merchant_invoice.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def merchant_invoice
  @merchant_invoice
end

#merchant_referenceObject

Returns the value of attribute merchant_reference.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def merchant_reference
  @merchant_reference
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def status
  @status
end

#uuidObject

Returns the value of attribute uuid.



4
5
6
# File 'lib/coinjar-checkout/ipn.rb', line 4

def uuid
  @uuid
end

Instance Method Details

#fetch_orderObject



18
19
20
# File 'lib/coinjar-checkout/ipn.rb', line 18

def fetch_order
  CoinJarCheckout::Order.find(uuid)
end

#reset(args) ⇒ Object



22
23
24
25
26
27
# File 'lib/coinjar-checkout/ipn.rb', line 22

def reset(args)
  args.each do |k,v|
    instance_variable_set("@#{k}", v) unless v.nil?
  end
  self
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/coinjar-checkout/ipn.rb', line 14

def valid?
  verify
end

#verifyObject



10
11
12
# File 'lib/coinjar-checkout/ipn.rb', line 10

def verify
  ipn_digest == OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha256'), CoinJarCheckout.secret, "#{uuid}#{amount}#{currency}#{status}")
end