Class: Corzinus::Checkout::PaymentStep

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/corzinus/checkout/payment_step.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PaymentStep

Returns a new instance of PaymentStep.



6
7
8
9
10
# File 'app/commands/corzinus/checkout/payment_step.rb', line 6

def initialize(options)
  @order = options[:order]
  payment_attrs = options[:params][:order][:credit_card_attributes]
  @payment_form = CreditCardForm.from_params(payment_attrs)
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/commands/corzinus/checkout/payment_step.rb', line 4

def order
  @order
end

#payment_formObject (readonly)

Returns the value of attribute payment_form.



4
5
6
# File 'app/commands/corzinus/checkout/payment_step.rb', line 4

def payment_form
  @payment_form
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
# File 'app/commands/corzinus/checkout/payment_step.rb', line 12

def call
  if payment_form.valid? && update_order
    broadcast(:valid)
  else
    broadcast :invalid, payment_form: payment_form
  end
end