Sha256: 6c4b4e68968070e12ba62790d90a09832e56836d68a953c5fe86923aa683a2be

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 KB

Contents

module Spree
  class SkrillStatusController < ApplicationController
    def update
      @order = Order.find_by_number!(params[:order_id])
      payment_method = PaymentMethod.find(params[:payment_method_id])
      skrill_transaction = SkrillTransaction.create_from_postback params

      payment = @order.payments.where(:state => "pending",
                                      :payment_method_id => payment_method).first

      if payment
        payment.source = skrill_transaction
        payment.save
      else
        payment = @order.payments.create(:amount => @order.total,
                                         :source => skrill_transaction,
                                         :payment_method => payment_method)
      end

      payment.started_processing!

       unless payment.completed?
        case params[:status]
          when "0"
            payment.pend #may already be pending
          when "2" #processed / captured
            payment.complete!
          when "-1", "-2"
            payment.failure!
          else
            raise "Unexpected payment status"
        end
      end

      render :text => ""
    end

  end
end

Version data entries

18 entries across 18 versions & 4 rubygems

Version Path
spree_gateway-3.3.0.rc2 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-3.3.0.rc1 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-3.2.0 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-3.2.0.beta lib/controllers/frontend/spree/skrill_status_controller.rb
solidus_gateway-1.1.1 lib/controllers/frontend/spree/skrill_status_controller.rb
solidus_gateway-1.1.0 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-3.1.0 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-3.0.0 lib/controllers/frontend/spree/skrill_status_controller.rb
solidus_gateway-1.0.1 lib/controllers/frontend/spree/skrill_status_controller.rb
solidus_gateway-0.9.0 lib/controllers/frontend/spree/skrill_status_controller.rb
solidus_gateway-1.0.0 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_first_data_gge4-3.0.0 lib/controllers/frontend/spree/skrill_status_controller.rb
spree_gateway-2.2.1 app/controllers/spree/skrill_status_controller.rb
spree_gateway-2.1.1 app/controllers/spree/skrill_status_controller.rb
spree_gateway-2.0.1 app/controllers/spree/skrill_status_controller.rb
spree_skrill-1.0.2 app/controllers/spree/skrill_status_controller.rb
spree_skrill-1.0.1 app/controllers/spree/skrill_status_controller.rb
spree_skrill-1.0.0 app/controllers/spree/skrill_status_controller.rb