Class: Workarea::Zipco::Checkout
- Inherits:
-
Object
- Object
- Workarea::Zipco::Checkout
- Defined in:
- app/services/workarea/zipco/checkout.rb
Instance Attribute Summary collapse
-
#checkout ⇒ Object
readonly
Returns the value of attribute checkout.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #complete ⇒ Object
-
#initialize(checkout, user, options = {}) ⇒ Checkout
constructor
A new instance of Checkout.
Constructor Details
#initialize(checkout, user, options = {}) ⇒ Checkout
Returns a new instance of Checkout.
7 8 9 10 11 12 |
# File 'app/services/workarea/zipco/checkout.rb', line 7 def initialize(checkout, user, = {}) @checkout = checkout @user = user @options = @order = Workarea::Order.where(zipco_order_id: zipco_order_id).first end |
Instance Attribute Details
#checkout ⇒ Object (readonly)
Returns the value of attribute checkout.
4 5 6 |
# File 'app/services/workarea/zipco/checkout.rb', line 4 def checkout @checkout end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'app/services/workarea/zipco/checkout.rb', line 4 def @options end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
4 5 6 |
# File 'app/services/workarea/zipco/checkout.rb', line 4 def order @order end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/services/workarea/zipco/checkout.rb', line 4 def user @user end |
Instance Method Details
#complete ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/workarea/zipco/checkout.rb', line 14 def complete approved_referred_order = result == "approved" && order.zipco_referred? if result == "referred" order.set_zipco_referred_at! else order.update_attributes(zipco_referred_at: nil) end order.user_id = user.try(:id) Workarea::Pricing.perform(order, checkout.shipping) checkout.payment.adjust_tender_amounts(order.total_price) if order.zipco_referred? checkout.handle_zipco_referred elsif approved_referred_order checkout.handle_zipco_approved_referred else checkout.place_order end end |