Permalink
Browse files

Initial

  • Loading branch information...
0 parents commit d8178c5b7056d60777aedd744a375c0c7c92b173 @BDQ BDQ committed Nov 18, 2011
@@ -0,0 +1,10 @@
+\#*
+*~
+.#*
+.DS_Store
+.idea
+.project
+tmp
+nbproject
+*.swp
+spec/dummy
1 .rspec
@@ -0,0 +1 @@
+--colour
18 Gemfile
@@ -0,0 +1,18 @@
+source 'http://rubygems.org'
+
+gem 'sqlite3'
+
+group :test do
+ gem 'rspec-rails', '= 2.7.0'
+ gem 'factory_girl', '= 1.3.3'
+ gem 'factory_girl_rails', '= 1.0.1'
+ gem 'faker'
+end
+
+if RUBY_VERSION < "1.9"
+ gem "ruby-debug"
+else
+ gem "ruby-debug19"
+end
+
+gemspec
@@ -0,0 +1,185 @@
+PATH
+ remote: .
+ specs:
+ spree_skrill (0.70.1)
+ spree_core (>= 0.70.1)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
+ mail (~> 2.3.0)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemerchant (1.17.0)
+ activesupport (>= 2.3.11)
+ braintree (>= 2.0.0)
+ builder (>= 2.0.0)
+ json (>= 1.5.1)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ acts_as_list (0.1.4)
+ arel (2.2.1)
+ braintree (2.13.1)
+ builder (>= 2.0.0)
+ builder (3.0.0)
+ cocaine (0.2.0)
+ columnize (0.3.4)
+ deface (0.7.1)
+ nokogiri (~> 1.5.0)
+ rails (>= 3.0.9)
+ diff-lcs (1.1.3)
+ erubis (2.7.0)
+ factory_girl (1.3.3)
+ factory_girl_rails (1.0.1)
+ factory_girl (~> 1.3)
+ railties (>= 3.0.0)
+ faker (1.0.0)
+ i18n (~> 0.4)
+ highline (1.5.1)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.17)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ json (1.6.1)
+ kaminari (0.12.4)
+ rails (>= 3.0.0)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ meta_search (1.1.1)
+ actionpack (~> 3.1.0)
+ activerecord (~> 3.1.0)
+ activesupport (~> 3.1.0)
+ polyamorous (~> 0.5.0)
+ mime-types (1.17.2)
+ multi_json (1.0.3)
+ nested_set (1.6.8)
+ activerecord (>= 3.0.0)
+ railties (>= 3.0.0)
+ nokogiri (1.5.0)
+ paperclip (2.4.1)
+ activerecord (>= 2.3.0)
+ activesupport (>= 2.3.2)
+ cocaine (>= 0.0.2)
+ mime-types
+ polyamorous (0.5.0)
+ activerecord (~> 3.0)
+ polyglot (0.3.3)
+ rack (1.3.5)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
+ bundler (~> 1.0)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rbx-require-relative (0.0.5)
+ rd_find_by_param (0.1.1)
+ activerecord (~> 3.0)
+ activesupport (~> 3.0)
+ rd_resource_controller (1.0.1)
+ rdoc (3.11)
+ json (~> 1.4)
+ rspec (2.7.0)
+ rspec-core (~> 2.7.0)
+ rspec-expectations (~> 2.7.0)
+ rspec-mocks (~> 2.7.0)
+ rspec-core (2.7.1)
+ rspec-expectations (2.7.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.7.0)
+ rspec-rails (2.7.0)
+ actionpack (~> 3.0)
+ activesupport (~> 3.0)
+ railties (~> 3.0)
+ rspec (~> 2.7.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ spree_core (0.70.1)
+ activemerchant (= 1.17.0)
+ acts_as_list (= 0.1.4)
+ deface (>= 0.7.0)
+ faker (= 1.0.0)
+ highline (= 1.5.1)
+ jquery-rails (>= 1.0.14)
+ kaminari (>= 0.12.4)
+ meta_search (= 1.1.1)
+ nested_set (= 1.6.8)
+ paperclip (= 2.4.1)
+ rails (= 3.1.1)
+ rd_find_by_param (= 0.1.1)
+ rd_resource_controller
+ state_machine (= 1.0.1)
+ stringex (= 1.0.3)
+ sprockets (2.0.3)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.4)
+ state_machine (1.0.1)
+ stringex (1.0.3)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ factory_girl (= 1.3.3)
+ factory_girl_rails (= 1.0.1)
+ faker
+ rspec-rails (= 2.7.0)
+ ruby-debug
+ spree_skrill!
+ sqlite3
26 LICENSE
@@ -0,0 +1,26 @@
+Copyright (c) 2011 [name of plugin creator]
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name Spree nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,20 @@
+SpreeSkrill
+===========
+
+Introduction goes here.
+
+
+Example
+=======
+
+Example goes here.
+
+Testing
+-------
+
+Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
+
+ $ bundle exec rake test app
+ $ bundle exec rspec spec
+
+Copyright (c) 2011 [name of extension creator], released under the New BSD License
@@ -0,0 +1,31 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rubygems/package_task'
+require 'rspec/core/rake_task'
+require 'cucumber/rake/task'
+require 'spree_core/testing_support/common_rake'
+
+RSpec::Core::RakeTask.new
+Cucumber::Rake::Task.new
+
+task :default => [:spec, :cucumber ]
+
+spec = eval(File.read('spree_skrill.gemspec'))
+
+Gem::PackageTask.new(spec) do |p|
+ p.gem_spec = spec
+end
+
+desc "Release to gemcutter"
+task :release => :package do
+ require 'rake/gemcutter'
+ Rake::Gemcutter::Tasks.new(spec).define
+ Rake::Task['gem:push'].invoke
+end
+
+desc "Generates a dummy app for testing"
+task :test_app do
+ ENV['LIB_NAME'] = 'spree_skrill'
+ Rake::Task['common:test_app'].invoke
+end
@@ -0,0 +1,9 @@
+# This file is used to designate compatibilty with different versions of Spree
+# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
+
+# Examples
+#
+# "0.70.x" => { :branch => "master"}
+# "0.60.x" => { :branch => "0-60-stable" }
+# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
+
@@ -0,0 +1,52 @@
+CheckoutController.class_eval do
+ before_filter :redirect_to_skrill_if_needed, :only => [:update]
+
+
+ def skrill_return
+ #need to force checkout to complete state
+ until @order.state == "complete"
+ if @order.next!
+ @order.update!
+ state_callback(:after)
+ end
+ end
+
+ redirect_to completion_route
+ end
+
+ private
+
+ def redirect_to_skrill_if_needed
+ return unless (params[:state] == "payment")
+ return unless params[:order][:payments_attributes]
+
+ if params[:order][:coupon_code]
+ @order.update_attributes(object_params)
+ @order.process_coupon_code
+ end
+
+ payment_method = PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id])
+
+ if payment_method.kind_of?(BillingIntegration::Skrill::QuickCheckout)
+ skrill_account = SkrillAccount.find_or_create_by_email(@order.email)
+
+ payment = @order.payments.create(
+ :amount => @order.total,
+ :source => skrill_account,
+ :payment_method => payment_method)
+
+ opts = {}
+ opts[:transaction_id] = payment.id
+ opts[:amount] = payment.amount
+ opts[:return_url] = skrill_return_order_checkout_url(@order)
+ opts[:status_url] = skrill_status_update_url
+ opts[:cancel_url] = order_url(@order)
+
+ payment.started_processing!
+ payment.pend!
+
+ redirect_to payment_method.redirect_url(@order, opts)
+ end
+ end
+
+end
@@ -0,0 +1,19 @@
+class SkrillStatusController < ApplicationController
+ def update
+ payment = Payment.find(params[:transaction_id])
+
+ 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
+
+
+ render :text => ""
+ end
+end
@@ -0,0 +1,2 @@
+module SkrillStatusHelper
+end
Oops, something went wrong.

0 comments on commit d8178c5

Please sign in to comment.