Sha256: d5442b1e179c33285c0bff05f776be8fbe08cda217a9651eda61fe69b99bfdb6

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

module SolidusNexio
  class PaymentsController < Spree::CheckoutController
    def create
      if update_order
        payment_method = PaymentMethod.find(params[:payment_method_id])
        result = payment_method.process_order_payment(@order)
        render json: result
      else
        render json: { error: :invalid_order, details: @order.errors.to_h }, status: 422
      end
    end

    def capture
      payment_method = PaymentMethod.find(params[:payment_method_id])
      payment = payment_method.payments.find(params[:payment_id])
      @result = payment_method.capture_order_payment(payment, params[:id], params[:status])
    end

    private

    def update_params
      massaged_params.require(:order).permit(permitted_checkout_payment_attributes)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_nexio-0.2.1 app/controllers/solidus_nexio/payments_controller.rb
solidus_nexio-0.2.0 app/controllers/solidus_nexio/payments_controller.rb