Class: SolidusNexio::PaymentsController

Inherits:
Spree::CheckoutController
  • Object
show all
Defined in:
app/controllers/solidus_nexio/payments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/solidus_nexio/payments_controller.rb', line 5

def create
  if update_order
    payment_method = PaymentMethod.active.available_to_users.find(params[:payment_method_id])
    result = payment_method.process_order_payment(current_order) do |payment|
      capture_payment_method_payment_state_url(payment_method, payment.number)
    end
    render json: result
  else
    render json: { error: :invalid_order, details: current_order.errors.to_h }, status: 422
  end
end