Class: Easypay::PaymentReference

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/easypay/payment_reference.rb

Instance Method Summary collapse

Instance Method Details

#process(object, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/easypay/payment_reference.rb', line 7

def process(object, options = {})
  @object = object
  
  if compliant?
    self.update_attributes(handle_model_methods)
    
    payment_reference = Easypay::Client.new(options).create_reference(self)
    
    self.update_attributes( :ep_message => payment_reference[:ep_message],
                            :ep_reference => payment_reference[:ep_reference],
                            :ep_cin => payment_reference[:ep_cin],
                            :ep_user => payment_reference[:ep_user],
                            :ep_entity => payment_reference[:ep_entity],
                            :ep_link => payment_reference[:payment_link],
                            :ep_last_status => payment_reference[:ep_status],
                            :request_log => payment_reference[:raw],
                            :item_description => self.item_description,
                            :item_quantity => self.item_quantity,
                            :o_name  => self.o_name,
                            :o_description  => self.o_description, 
                            :o_obs => self.o_obs,
                            :o_email => self.o_email,
                            :o_mobile  => self.o_mobile)
                            
    return payment_reference
  else
    nil
  end
end