Class: Gold::Concerns::MerchantFacing::ConfrontMandatoryBillingAction

Inherits:
HasAccessToRoutes
  • Object
show all
Defined in:
app/controllers/gold/concerns/merchant_facing.rb

Overview

See documentation on ‘confront_mandatory_billing_action`.

Instance Method Summary collapse

Methods inherited from HasAccessToRoutes

#initialize

Constructor Details

This class inherits a constructor from Gold::Concerns::MerchantFacing::HasAccessToRoutes

Instance Method Details

#callObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'app/controllers/gold/concerns/merchant_facing.rb', line 42

def call
  begin
    state = @context.billing.current_state
  rescue ActiveRecord::RecordNotFound
    state = nil
  end

  Gold.logger.info("Confronting billing, state is '#{state}'")

  case state
  when nil, :new
    Gold.logger.info("Redirecting to terms page...")
    return @context.redirect_to(@engine.terms_url)
  when :select_tier, :reinstalled, :accepted_terms
    Gold.logger.info("Redirecting to select tier...")
    return @context.redirect_to(@engine.select_tier_url)
  when :charge_missing
    Gold.logger.info("Redirecting to missing charge...")
    return @context.redirect_to(@engine.missing_charge_url)
  when :sudden_charge, :delayed_charge, :optional_charge
    Gold.logger.info("Redirecting to outstanding charge...")
    return @context.redirect_to(@engine.outstanding_charge_url)
  when :sudden_charge_declined, :delayed_charge_declined
    Gold.logger.info("Redirecting to declined charge...")
    return @context.redirect_to(@engine.declined_charge_url)
  when :sudden_charge_expired, :delayed_charge_expired
    Gold.logger.info("Redirecting to expired charge...")
    return @context.redirect_to(@engine.expired_charge_url)
  when :marked_as_delinquent, :delinquent
    Gold.logger.info("Redirecting to missing charge...")
    return @context.redirect_to(@engine.missing_charge_url)
  when :marked_as_suspended, :suspended
    Gold.logger.info("Redirecting to suspended page...")
    return @context.redirect_to(@engine.suspended_path)
  when :marked_as_uninstalled, :uninstalled, :frozen, :done
    Gold.logger.info("Redirecting to uninstalled page...")
    return @context.redirect_to(@engine.uninstalled_path)
  when :cleanup
    Gold.logger.info("Shop is cleanup, redirecting to unavailable...")
    return @context.redirect_to(@engine.unavailable_path)
  end
end