Module: Nimbleshop::PaymentUtil

Extended by:
PaymentUtil
Included in:
PaymentUtil
Defined in:
lib/nimbleshop/nimbleshop/payment_util.rb

Instance Method Summary collapse

Instance Method Details

#activemerchant_options(order) ⇒ Object



27
28
29
30
31
32
# File 'lib/nimbleshop/nimbleshop/payment_util.rb', line 27

def activemerchant_options(order)
  billing_address = { billing_address: billing_address_json(order) }
  shipping_address = { shipping_address: shipping_address_json(order) }
  misc = { order_id: order.number, email: order.email }
  billing_address.merge(shipping_address).merge(misc)
end

#billing_address_json(order) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/nimbleshop/nimbleshop/payment_util.rb', line 5

def billing_address_json(order)
  a = order.real_billing_address

  { address1: a.address1,
    city:     a.city,
    state:    a.state_name,
    country:  a.country_name,
    zip:      a.zipcode }
end

#shipping_address_json(order) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/nimbleshop/nimbleshop/payment_util.rb', line 15

def shipping_address_json(order)
  a = order.shipping_address

  { first_name: a.first_name,
    last_name:  a.last_name,
    address1:   a.address1,
    city:       a.city,
    state:      a.state_name,
    country:    a.country_name,
    zip:        a.zipcode }
end