Class: Paytureman::PaymentNew

Inherits:
Payment
  • Object
show all
Defined in:
lib/payments/payment_new.rb

Instance Attribute Summary

Attributes inherited from Payment

#gateway, #order_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Payment

#current, new_from_payment

Constructor Details

#initialize(order_id, amount, ip, gateway = nil) ⇒ PaymentNew

Returns a new instance of PaymentNew.



13
14
15
16
# File 'lib/payments/payment_new.rb', line 13

def initialize(order_id, amount, ip, gateway = nil)
  super(order_id, amount, gateway)
  @ip = ip
end

Class Method Details

.new_from_memento(memento) ⇒ Object



23
24
25
# File 'lib/payments/payment_new.rb', line 23

def self.new_from_memento(memento)
  new(memento.order_id, memento.amount, memento.ip, memento.gateway)
end

Instance Method Details

#prepare(description = PaymentDescription.new) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/payments/payment_new.rb', line 27

def prepare(description = PaymentDescription.new)
  session_id = payture.init(order_id, amount_in_cents, ip, description.to_h)
  if session_id
    PaymentPrepared.new(order_id, amount, session_id, gateway)
  else
    self
  end
end

#save_to_memento(memento) ⇒ Object



18
19
20
21
# File 'lib/payments/payment_new.rb', line 18

def save_to_memento(memento)
  super
  memento.ip = ip
end