Class: Spree::Payment::GatewayOptions

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/payment/gateway_options.rb

Instance Method Summary collapse

Constructor Details

#initialize(payment) ⇒ GatewayOptions

Returns a new instance of GatewayOptions.



4
5
6
# File 'app/models/spree/payment/gateway_options.rb', line 4

def initialize(payment)
  @payment = payment
end

Instance Method Details

#billing_addressObject



48
49
50
# File 'app/models/spree/payment/gateway_options.rb', line 48

def billing_address
  order.bill_address.try(:active_merchant_hash)
end

#currencyObject



44
45
46
# File 'app/models/spree/payment/gateway_options.rb', line 44

def currency
  @payment.currency
end

#customerObject



12
13
14
# File 'app/models/spree/payment/gateway_options.rb', line 12

def customer
  order.email
end

#customer_idObject



16
17
18
# File 'app/models/spree/payment/gateway_options.rb', line 16

def customer_id
  order.user_id
end

#discountObject



40
41
42
# File 'app/models/spree/payment/gateway_options.rb', line 40

def discount
  order.promo_total * exchange_multiplier
end

#emailObject



8
9
10
# File 'app/models/spree/payment/gateway_options.rb', line 8

def email
  order.email
end

#hash_methodsObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/models/spree/payment/gateway_options.rb', line 56

def hash_methods
  [
    :email,
    :customer,
    :customer_id,
    :ip,
    :order_id,
    :shipping,
    :tax,
    :subtotal,
    :discount,
    :currency,
    :billing_address,
    :shipping_address
  ]
end

#ipObject



20
21
22
# File 'app/models/spree/payment/gateway_options.rb', line 20

def ip
  order.last_ip_address
end

#order_idObject



24
25
26
# File 'app/models/spree/payment/gateway_options.rb', line 24

def order_id
  "#{order.number}-#{@payment.number}"
end

#shippingObject



28
29
30
# File 'app/models/spree/payment/gateway_options.rb', line 28

def shipping
  order.ship_total * exchange_multiplier
end

#shipping_addressObject



52
53
54
# File 'app/models/spree/payment/gateway_options.rb', line 52

def shipping_address
  order.ship_address.try(:active_merchant_hash)
end

#subtotalObject



36
37
38
# File 'app/models/spree/payment/gateway_options.rb', line 36

def subtotal
  order.item_total * exchange_multiplier
end

#taxObject



32
33
34
# File 'app/models/spree/payment/gateway_options.rb', line 32

def tax
  order.additional_tax_total * exchange_multiplier
end

#to_hashObject



73
74
75
76
77
# File 'app/models/spree/payment/gateway_options.rb', line 73

def to_hash
  Hash[hash_methods.map do |method|
    [method, send(method)]
  end]
end