app/controllers/spree/admin/payments_controller.rb in spree_backend-2.0.13 vs app/controllers/spree/admin/payments_controller.rb in spree_backend-2.1.0

- old
+ new

@@ -30,19 +30,21 @@ end if @order.completed? @payment.process! flash[:success] = flash_message_for(@payment, :successfully_created) + + redirect_to admin_order_payments_path(@order) else #This is the first payment (admin created order) until @order.completed? @order.next! end flash[:success] = Spree.t(:new_order_completed) + redirect_to edit_admin_order_url(@order) end - redirect_to admin_order_payments_path(@order) rescue Spree::Core::GatewayError => e flash[:error] = "#{e.message}" redirect_to new_admin_order_payment_path(@order) end end @@ -67,11 +69,11 @@ def object_params if params[:payment] and params[:payment_source] and source_params = params.delete(:payment_source)[params[:payment][:payment_method_id]] params[:payment][:source_attributes] = source_params end - params[:payment] + params.require(:payment).permit(:amount, :payment_method_id, :source_attributes) end def load_data @amount = params[:amount] || load_order.total @payment_methods = PaymentMethod.available(:back_end) @@ -81,18 +83,12 @@ @payment_method = @payment_methods.first end @previous_cards = @order.credit_cards.with_payment_profile end - # At this point admin should have passed through Customer Details step - # where order.next is called which leaves the order in payment step - # - # Orders in complete step also allows to access this controller - # - # Otherwise redirect user to that step def can_transition_to_payment - unless @order.billing_address.present? + unless @order.billing_address.present? flash[:notice] = Spree.t(:fill_in_customer_info) redirect_to edit_admin_order_customer_url(@order) end end @@ -102,13 +98,9 @@ @order end def load_payment @payment = Payment.find(params[:id]) - end - - def model_class - Spree::Payment end end end end