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