Sha256: 934bb863ecc3540761627fac076d804ad7098fcc7bc74557e3bcc37b48340f5e
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
module Spree module CheckoutWithMollie # If we're currently in the checkout def update if payment_params_valid? && paying_with_mollie? if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env) payment = @order.payments.last payment.process! mollie_payment_url = payment.payment_source.payment_url MollieLogger.debug("For order #{@order.number} redirect user to payment URL: #{mollie_payment_url}") redirect_to mollie_payment_url else render :edit end else super end end end module CheckoutControllerDecorator def payment_method_id_param params[:order][:payments_attributes].first[:payment_method_id] end def paying_with_mollie? payment_method = PaymentMethod.find(payment_method_id_param) payment_method.is_a? Gateway::MollieGateway end def payment_params_valid? (params[:state] === 'payment') && params[:order][:payments_attributes] end end CheckoutController.prepend(CheckoutWithMollie) CheckoutController.prepend(CheckoutControllerDecorator) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_mollie_gateway-4.0.1 | app/controllers/spree/checkout_controller_decorator.rb |
spree_mollie_gateway-4.0.0 | app/controllers/spree/checkout_controller_decorator.rb |