Class: Paytureman::Payment
- Inherits:
-
Object
- Object
- Paytureman::Payment
- Defined in:
- lib/payments/payment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#configuration ⇒ Object
writeonly
Sets the attribute configuration.
-
#gateway ⇒ Object
Returns the value of attribute gateway.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
Class Method Summary collapse
Instance Method Summary collapse
- #current ⇒ Object
-
#initialize(order_id, amount, gateway = nil) ⇒ Payment
constructor
A new instance of Payment.
- #save_to_memento(memento) ⇒ Object
Constructor Details
#initialize(order_id, amount, gateway = nil) ⇒ Payment
Returns a new instance of Payment.
9 10 11 12 13 |
# File 'lib/payments/payment.rb', line 9 def initialize(order_id, amount, gateway = nil) @order_id = order_id @amount = amount @gateway = gateway end |
Instance Attribute Details
#configuration=(value) ⇒ Object
Sets the attribute configuration
7 8 9 |
# File 'lib/payments/payment.rb', line 7 def configuration=(value) @configuration = value end |
#gateway ⇒ Object
Returns the value of attribute gateway.
5 6 7 |
# File 'lib/payments/payment.rb', line 5 def gateway @gateway end |
#order_id ⇒ Object
Returns the value of attribute order_id.
6 7 8 |
# File 'lib/payments/payment.rb', line 6 def order_id @order_id end |
Class Method Details
.new_from_memento(memento) ⇒ Object
21 22 23 |
# 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) ⇒ Object
25 26 27 28 29 |
# 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 |
Instance Method Details
#current ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
15 16 17 18 19 |
# File 'lib/payments/payment.rb', line 15 def save_to_memento(memento) memento.order_id = order_id memento.amount = amount memento.gateway = gateway end |