Class: Workarea::Checkout::Steps::Payment

Inherits:
Base
  • Object
show all
Defined in:
app/models/workarea/checkout/steps/payment.rb

Instance Attribute Summary

Attributes inherited from Base

#checkout

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Workarea::Checkout::Steps::Base

Instance Method Details

#complete?Boolean

Whether this checkout step is finished. Requires:

  • order to be purchasable

  • payment purchasable for order total_price

Returns:

  • (Boolean)


36
37
38
# File 'app/models/workarea/checkout/steps/payment.rb', line 36

def complete?
  order.purchasable? && payment.purchasable?(order.total_price)
end

#update(params = {}) ⇒ Boolean

Update the payment step of checkout (does not place the order). Clears the previous credit card because we may not need one anymore and we shouldn’t keep one if we don’t need it.

Processes the payment params to determine whether it’s a saved card or new card.

Parameters:

  • params (Hash) (defaults to: {})

Options Hash (params):

  • :payment (String)

    The payment option, either new_card or UUID of saved card

  • :credit_card (String)

    New card attributes

Returns:

  • (Boolean)

    whether the update succeeded (order and payment were saved)



18
19
20
21
22
23
24
25
26
27
# File 'app/models/workarea/checkout/steps/payment.rb', line 18

def update(params = {})
  return false unless payment.address.present?

  set_payment_profile
  set_credit_card(params)
  update_order_pricing
  update_payment_tenders

  persist_update
end