Class: Effective::OrdersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Effective::OrdersController
- Includes:
- Concerns::Purchase, CrudController, Providers::Cheque, Providers::Deluxe, Providers::DeluxeDelayed, Providers::DeluxeDelayedPurchase, Providers::Etransfer, Providers::Free, Providers::Helcim, Providers::MarkAsPaid, Providers::Moneris, Providers::MonerisCheckout, Providers::Paypal, Providers::Phone, Providers::Pretend, Providers::Refund, Providers::Stripe
- Defined in:
- app/controllers/effective/orders_controller.rb
Instance Method Summary collapse
- #bulk_send_buyer_receipt ⇒ Object
- #checkout ⇒ Object
-
#create ⇒ Object
Confirms an order from the cart.
- #declined ⇒ Object
- #deferred ⇒ Object
-
#edit ⇒ Object
Always step1.
-
#new ⇒ Object
If you want to use the Add to Cart -> Checkout flow Add one or more items however you do.
-
#purchased ⇒ Object
Thank you for Purchasing this Order.
- #recaptcha ⇒ Object
-
#send_buyer_receipt ⇒ Object
This is used by both the Admin and User.
-
#show ⇒ Object
Displays the order summary.
-
#update ⇒ Object
Confirms the order from existing order.
Methods included from Providers::Stripe
Methods included from Providers::Refund
Methods included from Providers::Pretend
Methods included from Providers::Phone
Methods included from Providers::Paypal
#paypal_params, #paypal_postback
Methods included from Providers::MonerisCheckout
Methods included from Providers::Moneris
Methods included from Providers::MarkAsPaid
#mark_as_paid, #mark_as_paid_params
Methods included from Providers::Helcim
Methods included from Providers::Free
Methods included from Providers::Etransfer
Methods included from Providers::DeluxeDelayedPurchase
#deluxe_delayed_purchase, #deluxe_delayed_purchase_params
Methods included from Providers::DeluxeDelayed
Methods included from Providers::Deluxe
Methods included from Providers::Cheque
Instance Method Details
#bulk_send_buyer_receipt ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/controllers/effective/orders_controller.rb', line 140 def bulk_send_buyer_receipt @orders = Effective::Order.deep.purchased.where(id: params[:ids]) begin EffectiveResources.(self, :index, Effective::Order.new(user: current_user)) @orders.each do |order| next unless EffectiveResources.(self, :show, order) order.send_order_receipt_to_buyer! end render json: { status: 200, message: "Successfully sent #{@orders.length} receipt emails"} rescue Exception => e render json: { status: 500, message: "Bulk send buyer receipt error: #{e.message}" } end end |
#checkout ⇒ Object
79 80 81 82 83 84 |
# File 'app/controllers/effective/orders_controller.rb', line 79 def checkout @order ||= Effective::Order.deep.was_not_purchased.find(params[:id]) @page_title ||= 'Checkout' EffectiveResources.(self, :checkout, @order) end |
#create ⇒ Object
Confirms an order from the cart.
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/effective/orders_controller.rb', line 55 def create @order ||= Effective::Order.deep.new(view_context.current_cart) EffectiveResources.(self, :create, @order) @order.assign_attributes(checkout_params) if (@order.confirm! rescue false) redirect_to(effective_orders.checkout_order_path(@order)) else flash.now[:danger] = "Unable to proceed: #{flash_errors(@order)}. Please try again." render :new end end |
#declined ⇒ Object
120 121 122 123 |
# File 'app/controllers/effective/orders_controller.rb', line 120 def declined @order = Effective::Order.deep.declined.find(params[:id]) EffectiveResources.(self, :show, @order) end |
#deferred ⇒ Object
115 116 117 118 |
# File 'app/controllers/effective/orders_controller.rb', line 115 def deferred @order = Effective::Order.deep.deferred.find(params[:id]) EffectiveResources.(self, :show, @order) end |
#edit ⇒ Object
Always step1
87 88 89 90 91 92 |
# File 'app/controllers/effective/orders_controller.rb', line 87 def edit @order ||= Effective::Order.deep.was_not_purchased.find(params[:id]) @page_title ||= 'Order Review' EffectiveResources.(self, :edit, @order) end |
#new ⇒ Object
If you want to use the Add to Cart -> Checkout flow Add one or more items however you do. redirect_to effective_orders.new_order_path, which is here. This is the entry point for any Checkout button. It displayes an order based on the cart Always step1
42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/effective/orders_controller.rb', line 42 def new @order ||= Effective::Order.deep.new(view_context.current_cart) EffectiveResources.(self, :new, @order) unless @order.valid? flash[:danger] = "Unable to proceed: #{flash_errors(@order)}. Please try again." redirect_to(effective_orders.cart_path) return end end |
#purchased ⇒ Object
Thank you for Purchasing this Order. This is where a successfully purchased order ends up
110 111 112 113 |
# File 'app/controllers/effective/orders_controller.rb', line 110 def purchased # Thank You! @order = Effective::Order.deep.purchased.find(params[:id]) EffectiveResources.(self, :show, @order) end |
#recaptcha ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/controllers/effective/orders_controller.rb', line 157 def recaptcha raise('recaptcha is not enabled') unless EffectiveOrders.recaptcha? raise('recaptcha secret key is not set') unless EffectiveOrders.recaptcha_secret_key.present? @order = Effective::Order.not_purchased.find(params[:id]) EffectiveResources.(self, :update, @order) redirect_url = params[:redirect_url].presence || effective_orders.checkout_order_path(@order) if verify_recaptcha(secret_key: EffectiveOrders.recaptcha_secret_key) session[:recaptcha_verified_order_id] = @order.id redirect_to redirect_url else flash[:danger] = 'Verification failed. Please try again.' redirect_to redirect_url end end |
#send_buyer_receipt ⇒ Object
This is used by both the Admin and User
126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'app/controllers/effective/orders_controller.rb', line 126 def send_buyer_receipt @order = Effective::Order.deep.purchased.find(params[:id]) EffectiveResources.(self, :show, @order) if @order.send_order_receipt_to_buyer! flash[:success] = "A receipt has been sent to #{@order.emails_send_to}" else flash[:danger] = "Unable to send receipt." end redirect_back(fallback_location: effective_orders.order_path(@order)) end |
#show ⇒ Object
Displays the order summary. For unpurchased orders, shows a Checkout button. For purchased orders, shows a Continue button.
72 73 74 75 76 77 |
# File 'app/controllers/effective/orders_controller.rb', line 72 def show @order ||= Effective::Order.deep.find(params[:id]) @page_title ||= @order.to_s EffectiveResources.(self, :show, @order) end |
#update ⇒ Object
Confirms the order from existing order
95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'app/controllers/effective/orders_controller.rb', line 95 def update @order ||= Effective::Order.deep.was_not_purchased.find(params[:id]) EffectiveResources.(self, :update, @order) @order.assign_attributes(checkout_params) if (@order.confirm! rescue false) redirect_to(effective_orders.checkout_order_path(@order)) else flash.now[:danger] = "Unable to proceed: #{flash_errors(@order)}. Please try again." render :edit end end |