class Paytureman::Payment
Attributes
amount[RW]
configuration[W]
gateway[RW]
order_id[RW]
Public Class Methods
new(order_id, amount, gateway = nil)
click to toggle source
# File lib/payments/payment.rb, line 9 def initialize(order_id, amount, gateway = nil) @order_id = order_id @amount = amount @gateway = gateway end
new_from_memento(memento)
click to toggle source
# File lib/payments/payment.rb, line 21 def self.new_from_memento(memento) new(memento.order_id, memento.amount, memento.gateway) end
new_from_payment(donor)
click to toggle source
# File lib/payments/payment.rb, line 25 def self.new_from_payment(donor) memento = OpenStruct.new donor.save_to_memento(memento) new_from_memento(memento) end
Public Instance Methods
current()
click to toggle source
# File lib/payments/payment.rb, line 31 def current current_payment_type = { :new => PaymentNew, :prepared => PaymentPrepared, :authorized => PaymentBlocked, :voided => PaymentCancelled, :charged => PaymentCharged, :refund => PaymentRefunded }[payture.status(order_id)] || PaymentUnknown current_payment_type.new_from_payment(self) end
save_to_memento(memento)
click to toggle source
# File lib/payments/payment.rb, line 15 def save_to_memento(memento) memento.order_id = order_id memento.amount = amount memento.gateway = gateway end
Protected Instance Methods
amount_in_cents()
click to toggle source
# File lib/payments/payment.rb, line 48 def amount_in_cents (amount * 100).round end
configuration()
click to toggle source
# File lib/payments/payment.rb, line 52 def configuration @configuration ||= Configuration.instance end
payture()
click to toggle source
# File lib/payments/payment.rb, line 56 def payture @payture ||= configuration.api_for(gateway) end