Class: Workarea::Zipco::Setup

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/zipco/setup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checkout) ⇒ Setup

Returns a new instance of Setup.

Parameters:

  • ::Workarea::Checkout


7
8
9
10
# File 'app/services/workarea/zipco/setup.rb', line 7

def initialize(checkout)
 @checkout = checkout
 @order = checkout.order
end

Instance Attribute Details

#checkoutObject (readonly)

Returns the value of attribute checkout.



4
5
6
# File 'app/services/workarea/zipco/setup.rb', line 4

def checkout
  @checkout
end

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/services/workarea/zipco/setup.rb', line 4

def order
  @order
end

Instance Method Details

#create_order_responseObject



12
13
14
# File 'app/services/workarea/zipco/setup.rb', line 12

def create_order_response
  @create_order_response ||= Zipco.gateway.create_order(order_details)
end

#redirect_uriObject



26
27
28
# File 'app/services/workarea/zipco/setup.rb', line 26

def redirect_uri
  create_order_response.redirect_uri
end

#set_checkout_dataObject



16
17
18
19
20
21
22
23
24
# File 'app/services/workarea/zipco/setup.rb', line 16

def set_checkout_data
  payment = Workarea::Payment.find(order.id)

  payment.clear_credit_card

  payment.set_zipco(token: create_order_response.zipco_order_id)

  order.update_attributes!(zipco_order_id: create_order_response.zipco_order_id)
end