Class: Spree::Payment::GatewayOptions
- Inherits:
-
Object
- Object
- Spree::Payment::GatewayOptions
- Defined in:
- app/models/spree/payment/gateway_options.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
Instance Method Summary collapse
- #billing_address ⇒ Object
- #customer ⇒ Object
- #customer_id ⇒ Object
- #discount ⇒ Object
- #hash_methods ⇒ Object
-
#initialize(payment) ⇒ GatewayOptions
constructor
A new instance of GatewayOptions.
- #ip ⇒ Object
- #order_id ⇒ Object
- #payment_id ⇒ Object
- #shipping ⇒ Object
- #shipping_address ⇒ Object
- #statement_descriptor_suffix ⇒ Object
- #subtotal ⇒ Object
- #tax ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(payment) ⇒ GatewayOptions
Returns a new instance of GatewayOptions.
4 5 6 7 |
# File 'app/models/spree/payment/gateway_options.rb', line 4 def initialize(payment) @payment = payment @order = payment.order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
9 10 11 |
# File 'app/models/spree/payment/gateway_options.rb', line 9 def order @order end |
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
9 10 11 |
# File 'app/models/spree/payment/gateway_options.rb', line 9 def payment @payment end |
Instance Method Details
#billing_address ⇒ Object
53 54 55 |
# File 'app/models/spree/payment/gateway_options.rb', line 53 def billing_address order.bill_address.try(:active_merchant_hash) end |
#customer ⇒ Object
17 18 19 |
# File 'app/models/spree/payment/gateway_options.rb', line 17 def customer order.email end |
#customer_id ⇒ Object
21 22 23 |
# File 'app/models/spree/payment/gateway_options.rb', line 21 def customer_id order.user_id end |
#discount ⇒ Object
49 50 51 |
# File 'app/models/spree/payment/gateway_options.rb', line 49 def discount order.promo_total * exchange_multiplier end |
#hash_methods ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/models/spree/payment/gateway_options.rb', line 61 def hash_methods [ :email, :customer, :customer_id, :ip, :order_id, :payment_id, :shipping, :tax, :subtotal, :discount, :currency, :billing_address, :shipping_address ] end |
#ip ⇒ Object
25 26 27 |
# File 'app/models/spree/payment/gateway_options.rb', line 25 def ip order.last_ip_address end |
#order_id ⇒ Object
29 30 31 |
# File 'app/models/spree/payment/gateway_options.rb', line 29 def order_id "#{order.number}-#{payment.number}" end |
#payment_id ⇒ Object
33 34 35 |
# File 'app/models/spree/payment/gateway_options.rb', line 33 def payment_id payment.number end |
#shipping ⇒ Object
37 38 39 |
# File 'app/models/spree/payment/gateway_options.rb', line 37 def shipping order.ship_total * exchange_multiplier end |
#shipping_address ⇒ Object
57 58 59 |
# File 'app/models/spree/payment/gateway_options.rb', line 57 def shipping_address order.ship_address.try(:active_merchant_hash) end |
#statement_descriptor_suffix ⇒ Object
13 14 15 |
# File 'app/models/spree/payment/gateway_options.rb', line 13 def statement_descriptor_suffix order.number end |
#subtotal ⇒ Object
45 46 47 |
# File 'app/models/spree/payment/gateway_options.rb', line 45 def subtotal order.item_total * exchange_multiplier end |
#tax ⇒ Object
41 42 43 |
# File 'app/models/spree/payment/gateway_options.rb', line 41 def tax order.additional_tax_total * exchange_multiplier end |
#to_hash ⇒ Object
79 80 81 82 83 |
# File 'app/models/spree/payment/gateway_options.rb', line 79 def to_hash Hash[hash_methods.map do |method| [method, send(method)] end] end |