class Stall::Checkout::PaymentCheckoutStep

Public Instance Methods

allow_inactive_carts?() click to toggle source

When we access this step after a payment to validate the step, the cart is “inactive”, so we force processing the cart.

# File lib/stall/checkout/payment_checkout_step.rb, line 25
def allow_inactive_carts?
  !!params[:succeeded]
end
process() click to toggle source

Determine wether the customer's payment has been validated or not.

By default, the payment processing occurs in the background and, for some of the payment gateways, can be run asynchronously. In this case, the gateway should redirect here with the `:succeeded` param in the URL.

If the payment processing occurs synchronously, the gateway overrides the synchronous_payment_notification? method, using the cart payment state to determine this parameter.

# File lib/stall/checkout/payment_checkout_step.rb, line 14
def process
  if gateway.synchronous_payment_notification?
    cart.paid?
  elsif params[:succeeded]
    true
  end
end

Private Instance Methods

gateway() click to toggle source
# File lib/stall/checkout/payment_checkout_step.rb, line 31
def gateway
  @gateway ||= Stall::Payments::Gateway.for(cart.payment.payment_method).new(cart)
end