Sha256: 6af58c5aa319807dc47278d6563b45ce2af67af91409772d8edf53cb14e617cb

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

module Spree
  CheckoutController.class_eval do
    before_filter :confirm_pagseguro, :only => [:update]

    private
    # This method hacks order update event to generate a payment transaction
    # using pagseguro and displays payment button
    def confirm_pagseguro
      return unless (params[:state] == "payment") && params[:order][:payments_attributes]

      payment_method = PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id])
      if payment_method.kind_of?(BillingIntegration::Pagseguro::Checkout)
        pagseguro_checkout_url = payment_method.redirect_url(@order)

        @order.payments.create(:amount => @order.total, :payment_method_id => payment_method.id)
        redirect_to pagseguro_checkout_url
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_pagseguro-2.1.3 app/controllers/spree/checkout_controller_decorator.rb