catarse_dineromail 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in catarse_dineromail.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group
6
+ gemspec
7
+
8
+ gem 'dinero_mail_checkout', git: "git://github.com/josemarluedke/dinero_mail_checkout.git"
9
+ gem 'dinero_mail_ipn', git: "git://github.com/josemarluedke/dinero_mail_ipn.git"
data/Gemfile.lock ADDED
@@ -0,0 +1,138 @@
1
+ GIT
2
+ remote: git://github.com/josemarluedke/dinero_mail_checkout.git
3
+ revision: ac19016a9956acf5c86a5e88e59cba977dc9c2bb
4
+ specs:
5
+ dinero_mail_checkout (0.0.1)
6
+
7
+ GIT
8
+ remote: git://github.com/josemarluedke/dinero_mail_ipn.git
9
+ revision: a5f107ac16abeb8bd0553c30c0c0c6ad598dc6f1
10
+ specs:
11
+ dinero_mail_ipn (1.0.2)
12
+ httparty (~> 0.6.1)
13
+ nokogiri (~> 1.4.3)
14
+
15
+ PATH
16
+ remote: .
17
+ specs:
18
+ catarse_dineromail (0.0.1)
19
+ dinero_mail_checkout
20
+ dinero_mail_ipn
21
+ rails (~> 3.2.6)
22
+
23
+ GEM
24
+ remote: http://rubygems.org/
25
+ specs:
26
+ actionmailer (3.2.6)
27
+ actionpack (= 3.2.6)
28
+ mail (~> 2.4.4)
29
+ actionpack (3.2.6)
30
+ activemodel (= 3.2.6)
31
+ activesupport (= 3.2.6)
32
+ builder (~> 3.0.0)
33
+ erubis (~> 2.7.0)
34
+ journey (~> 1.0.1)
35
+ rack (~> 1.4.0)
36
+ rack-cache (~> 1.2)
37
+ rack-test (~> 0.6.1)
38
+ sprockets (~> 2.1.3)
39
+ activemodel (3.2.6)
40
+ activesupport (= 3.2.6)
41
+ builder (~> 3.0.0)
42
+ activerecord (3.2.6)
43
+ activemodel (= 3.2.6)
44
+ activesupport (= 3.2.6)
45
+ arel (~> 3.0.2)
46
+ tzinfo (~> 0.3.29)
47
+ activeresource (3.2.6)
48
+ activemodel (= 3.2.6)
49
+ activesupport (= 3.2.6)
50
+ activesupport (3.2.6)
51
+ i18n (~> 0.6)
52
+ multi_json (~> 1.0)
53
+ arel (3.0.2)
54
+ builder (3.0.0)
55
+ crack (0.1.8)
56
+ database_cleaner (0.8.0)
57
+ diff-lcs (1.1.3)
58
+ erubis (2.7.0)
59
+ factory_girl (2.6.4)
60
+ activesupport (>= 2.3.9)
61
+ factory_girl_rails (1.7.0)
62
+ factory_girl (~> 2.6.0)
63
+ railties (>= 3.0.0)
64
+ fakeweb (1.3.0)
65
+ hike (1.2.1)
66
+ httparty (0.6.1)
67
+ crack (= 0.1.8)
68
+ i18n (0.6.0)
69
+ journey (1.0.4)
70
+ json (1.7.3)
71
+ mail (2.4.4)
72
+ i18n (>= 0.4.0)
73
+ mime-types (~> 1.16)
74
+ treetop (~> 1.4.8)
75
+ mime-types (1.19)
76
+ multi_json (1.3.6)
77
+ nokogiri (1.4.7)
78
+ polyglot (0.3.3)
79
+ rack (1.4.1)
80
+ rack-cache (1.2)
81
+ rack (>= 0.4)
82
+ rack-ssl (1.3.2)
83
+ rack
84
+ rack-test (0.6.1)
85
+ rack (>= 1.0)
86
+ rails (3.2.6)
87
+ actionmailer (= 3.2.6)
88
+ actionpack (= 3.2.6)
89
+ activerecord (= 3.2.6)
90
+ activeresource (= 3.2.6)
91
+ activesupport (= 3.2.6)
92
+ bundler (~> 1.0)
93
+ railties (= 3.2.6)
94
+ railties (3.2.6)
95
+ actionpack (= 3.2.6)
96
+ activesupport (= 3.2.6)
97
+ rack-ssl (~> 1.3.2)
98
+ rake (>= 0.8.7)
99
+ rdoc (~> 3.4)
100
+ thor (>= 0.14.6, < 2.0)
101
+ rake (0.9.2.2)
102
+ rdoc (3.12)
103
+ json (~> 1.4)
104
+ rspec (2.10.0)
105
+ rspec-core (~> 2.10.0)
106
+ rspec-expectations (~> 2.10.0)
107
+ rspec-mocks (~> 2.10.0)
108
+ rspec-core (2.10.1)
109
+ rspec-expectations (2.10.0)
110
+ diff-lcs (~> 1.1.3)
111
+ rspec-mocks (2.10.1)
112
+ rspec-rails (2.10.1)
113
+ actionpack (>= 3.0)
114
+ activesupport (>= 3.0)
115
+ railties (>= 3.0)
116
+ rspec (~> 2.10.0)
117
+ sprockets (2.1.3)
118
+ hike (~> 1.2)
119
+ rack (~> 1.0)
120
+ tilt (~> 1.1, != 1.3.0)
121
+ thor (0.15.4)
122
+ tilt (1.3.3)
123
+ treetop (1.4.10)
124
+ polyglot
125
+ polyglot (>= 0.3.1)
126
+ tzinfo (0.3.33)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ catarse_dineromail!
133
+ database_cleaner
134
+ dinero_mail_checkout!
135
+ dinero_mail_ipn!
136
+ factory_girl_rails
137
+ fakeweb
138
+ rspec-rails
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # CatarseDineromail
2
+
3
+ Dineromail integration with [Catarse](http://github.com/danielweinmann/catarse) crowdfunding platform
4
+
5
+ ## Installation
6
+
7
+ Add this line to your Catarse application's Gemfile:
8
+
9
+ gem 'catarse_dinero'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ Configure the routes for your Catarse application. Add the following lines in the routes file (config/routes.rb):
18
+
19
+ mount CatarseDineromail::Engine => "/", :as => "catarse_dineromail"
20
+
21
+ Create required configurations into Catarse database:
22
+
23
+ dineromail_merchant
24
+
25
+ dineromail_ipn_password
26
+
27
+ dineromail_country_id
28
+
29
+ ## Development environment setup
30
+
31
+ Clone the repository:
32
+
33
+ $ git clone git://github.com/josemarluedke/catarse_dineromail.git
34
+
35
+ Add the catarse code into test/dummy:
36
+
37
+ $ git submodule add git://github.com/danielweinmann/catarse.git test/dummy
38
+
39
+ Copy the Catarse's gem into Gemfile:
40
+
41
+ $ cat test/dummy/Gemfile >> Gemfile
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
54
+
55
+
56
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'CatarseDineromail'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec)
31
+
32
+ # RSpec as default
33
+ task :default => :spec
@@ -0,0 +1,87 @@
1
+ module CatarseDineromail
2
+ module Payment
3
+ class DineromailController < ApplicationController
4
+ before_filter :initialize_dineromail
5
+ SCOPE = "projects.backers.checkout"
6
+
7
+ def pay
8
+ begin
9
+ backer = current_user.backs.not_confirmed.find params[:id]
10
+ if backer
11
+ transaction_id = (Digest::MD5.hexdigest "#{SecureRandom.hex(5)}-#{DateTime.now.to_s}")[1..20].downcase
12
+ backer.update_attribute :payment_method, 'Dineromail'
13
+ backer.update_attribute :payment_token, transaction_id
14
+ data = DineroMailCheckout::CheckoutData.validate({item_name_1: t('paypal_description', scope: SCOPE),
15
+ item_quantity_1: 1,
16
+ item_currency_1: DineroMailCheckout.configuration.currency,
17
+ change_quantity: 0,
18
+ item_ammount_1: backer.moip_value,
19
+ buyer_name: backer.user.name,
20
+ buyer_phone: backer.user.phone_number,
21
+ buyer_email: backer.user.email,
22
+ ok_url: success_payment_dineromail_url(backer),
23
+ error_url: error_payment_dineromail_url(backer),
24
+ transaction_id: transaction_id})
25
+ redirect_to DineroMailCheckout::Client.get_uri(data)
26
+ end
27
+ rescue Exception => e
28
+ Airbrake.notify({ :error_class => "Dineromail Error", :error_message => "Dineromail Error: #{e.inspect}", :parameters => params}) rescue nil
29
+ Rails.logger.info "-----> #{e.inspect}"
30
+ flash[:failure] = t('paypal_error', scope: SCOPE)
31
+ return redirect_to main_app.new_project_backer_path(backer.project)
32
+ end
33
+ end
34
+
35
+ def success
36
+ backer = current_user.backs.find params[:id]
37
+ session[:thank_you_id] = backer.project.id
38
+ session[:_payment_token] = backer.payment_token
39
+
40
+ flash[:success] = t('success', scope: SCOPE)
41
+ redirect_to main_app.thank_you_path
42
+ end
43
+
44
+ def error
45
+ backer = current_user.backs.find params[:id]
46
+ flash[:failure] = t('paypal_error', scope: SCOPE)
47
+ redirect_to main_app.new_project_backer_path(backer.project)
48
+ end
49
+
50
+ def notifications
51
+ notification = params[:Notificacion]
52
+ return render(status: 404, nothing: true) if notification.nil?
53
+
54
+ xml = Nokogiri::XML(notification)
55
+ ids = []
56
+ xml.xpath("//OPERACION//ID").each {|o| ids << o.children.text}
57
+
58
+ c = DineroMailIpn::Client.new(account: ::Configuration[:dineromail_merchant], password: ::Configuration[:dineromail_ipn_password], pais: DineroMailCheckout::Configuration.country_name(::Configuration[:dineromail_country_id]))
59
+ reports = c.consulta_transacciones(ids).reports
60
+ if reports
61
+ reports.each do |report|
62
+ begin
63
+ backer = Backer.not_confirmed.where(payment_token: report.id).first
64
+ backer.confirm! if backer and report.transaction_completed?
65
+ rescue Exception => e
66
+ Rails.logger.info "-----> #{e.inspect}"
67
+ end
68
+ end
69
+ end
70
+ render nothing: true
71
+ end
72
+
73
+ protected
74
+ def initialize_dineromail
75
+ DineroMailCheckout.configure do |config|
76
+ config.payment_method = 'all'
77
+ config.merchant = (::Configuration[:dineromail_merchant] || nil)
78
+ config.logo_url = "#{request.protocol}#{request.host_with_port}/assets/logo.png"
79
+ config.currency = DineroMailCheckout::Configuration::Currency::CLP
80
+ config.country_id = ::Configuration[:dineromail_country_id]
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
87
+
@@ -0,0 +1,26 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "catarse_dineromail/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "catarse_dineromail"
9
+ s.version = CatarseDineromail::VERSION
10
+ s.authors = ["Josemar Davi Luedke"]
11
+ s.email = ["josemarluedke@gmail.com"]
12
+ s.homepage = "http://github.com/josemarluedke/catarse-dineromail"
13
+ s.summary = "Dineromail integration with Catarse"
14
+ s.description = "Dineromail integration with Catarse crowdfunding platform"
15
+
16
+ s.files = `git ls-files`.split($\)
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ s.add_dependency "rails", "~> 3.2.6"
20
+ s.add_dependency "dinero_mail_checkout"
21
+ s.add_dependency "dinero_mail_ipn"
22
+ s.add_development_dependency "rspec-rails"
23
+ s.add_development_dependency "fakeweb"
24
+ s.add_development_dependency "factory_girl_rails"
25
+ s.add_development_dependency "database_cleaner"
26
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,15 @@
1
+ CatarseDineromail::Engine.routes.draw do
2
+ namespace :payment do
3
+ resources :dineromail, only: [] do
4
+ member do
5
+ get :pay
6
+ get :success
7
+ get :error
8
+ end
9
+
10
+ collection do
11
+ post :notifications
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module CatarseDineromail
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CatarseDineromail
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module CatarseDineromail
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "catarse_dineromail/engine"
2
+
3
+ module CatarseDineromail
4
+ end
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/catarse_dineromail/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe CatarseDineromail::Payment::DineromailController do
4
+
5
+ describe "notifications" do
6
+ it "should 404 status code when not passed the 'Notification' param" do
7
+ post :notifications, {use_route: :catarse_dineromail}
8
+ response.status.should == 404
9
+ end
10
+
11
+ it "should 200 status code when pass the 'Notification' param" do
12
+ post :notifications, {Notificacion: fixture_file("dineromail_ipn_request.xml"), use_route: :catarse_dineromail}
13
+ response.status.should == 200
14
+ end
15
+
16
+ it "should confirm the backer" do
17
+ backer = Factory(:backer, payment_token: "ade4206f68ce02024ae1", confirmed: false)
18
+ backer.confirmed.should be_false
19
+ stub_post("/Vender/Consulta_IPN.asp", "dineromail_ipn_response.xml", {:url => {:https => false}, country: DineroMailCheckout::Configuration.country_name(::Configuration[:dineromail_country_id])})
20
+ post :notifications, {Notificacion: fixture_file("dineromail_ipn_request.xml"), use_route: :catarse_dineromail}
21
+ backer.reload
22
+ backer.confirmed.should be_true
23
+ end
24
+ end
25
+
26
+ describe "pay" do
27
+ it "should redirect" do
28
+ backer = Factory(:backer, confirmed: false)
29
+ sign_in backer.user
30
+ post :pay, {id: backer, use_route: :catarse_dineromail}
31
+ response.should be_redirect
32
+ end
33
+
34
+ it "should set the payment_token" do
35
+ backer = Factory(:backer, confirmed: false)
36
+ sign_in backer.user
37
+ backer.payment_token.should be_nil
38
+ post :pay, {id: backer, use_route: :catarse_dineromail}
39
+ backer.reload
40
+ backer.payment_token.should_not be_nil
41
+ response.should be_redirect
42
+ end
43
+ end
44
+
45
+ describe "success" do
46
+ it "should redirect to thank you path" do
47
+ backer = Factory(:backer, confirmed: false)
48
+ sign_in backer.user
49
+ post :success, {id: backer, use_route: :catarse_dineromail}
50
+ response.should redirect_to(thank_you_path)
51
+ end
52
+ end
53
+
54
+ describe "error" do
55
+ it "should redirect to new project backer path" do
56
+ backer = Factory(:backer, confirmed: false)
57
+ sign_in backer.user
58
+ post :error, {id: backer, use_route: :catarse_dineromail}
59
+ response.should redirect_to(new_project_backer_path(backer.project))
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,12 @@
1
+ <NOTIFICACION>
2
+ <TIPONOTIFICACION>12</TIPONOTIFICACION>
3
+ <OPERACIONES>
4
+ <OPERACION>
5
+ <TIPO>1</TIPO><ID>2320</ID>
6
+ </OPERACION>
7
+ <OPERACION>
8
+ <TIPO>12</TIPO>
9
+ <ID>434</ID>
10
+ </OPERACION>
11
+ </OPERACIONES>
12
+ </NOTIFICACION>
@@ -0,0 +1,36 @@
1
+ <REPORTE>
2
+ <ESTADOREPORTE>1</ESTADOREPORTE>
3
+ <DETALLE>
4
+ <OPERACIONES>
5
+ <OPERACION>
6
+ <ID>ade4206f68ce02024ae1</ID>
7
+ <FECHA></FECHA>
8
+ <ESTADO>2</ESTADO>
9
+ <NUMTRANSACCION>1</NUMTRANSACCION>
10
+ <COMPRADOR>
11
+ <EMAIL>test@gmail.com</EMAIL>
12
+ <DIRECCION></DIRECCION>
13
+ <COMENTARIO></COMENTARIO>
14
+ <NOMBRE></NOMBRE>
15
+ <TELEFONO></TELEFONO>
16
+ <TIPODOC></TIPODOC>
17
+ <NUMERODOC></NUMERODOC>
18
+ </COMPRADOR>
19
+ <MONTO></MONTO>
20
+ <MONTONETO></MONTONETO>
21
+ <METODOPAGO></METODOPAGO>
22
+ <MEDIOPAGO></MEDIOPAGO>
23
+ <CUOTAS></CUOTAS>
24
+ <ITEMS>
25
+ <ITEM>
26
+ <DESCRIPCION></DESCRIPCION> <MONEDA></MONEDA> <PRECIOUNITARIO></PRECIOUNITARIO> <CANTIDAD></CANTIDAD>
27
+ </ITEM>
28
+ </ITEMS>
29
+ <VENDEDOR>
30
+ <TIPODOC></TIPODOC>
31
+ <NUMERODOC></NUMERODOC>
32
+ </VENDEDOR>
33
+ </OPERACION>
34
+  </OPERACIONES>
35
+ </DETALLE>
36
+ </REPORTE>
@@ -0,0 +1,81 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../test/dummy/config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'fakeweb'
7
+
8
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc,
11
+ # in spec/support/ and its subdirectories.
12
+ Dir[File.join(ENGINE_RAILS_ROOT, 'spec/support/**/*.rb')].each {|f| require f }
13
+
14
+
15
+ RSpec.configure do |config|
16
+ # ## Mock Framework
17
+ #
18
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
19
+ #
20
+ # config.mock_with :mocha
21
+ # config.mock_with :flexmock
22
+ # config.mock_with :rr
23
+
24
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
25
+ config.fixture_path = "#{ENGINE_RAILS_ROOT}/spec/fixtures"
26
+
27
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
28
+ # examples within a transaction, remove the following line or assign false
29
+ # instead of true.
30
+ config.use_transactional_fixtures = false
31
+
32
+ # If true, the base class of anonymous controllers will be inferred
33
+ # automatically. This will be the default behavior in future versions of
34
+ # rspec-rails.
35
+ config.infer_base_class_for_anonymous_controllers = false
36
+
37
+ # Include Engine routes (needed for Controller specs)
38
+ config.include CatarseDineromail::Engine.routes.url_helpers
39
+
40
+ # Include Catarse routes
41
+ config.include Catarse::Application.routes.url_helpers
42
+
43
+ config.include Devise::TestHelpers, :type => :controller
44
+
45
+ config.include Factory::Syntax::Methods
46
+ config.before(:suite) do
47
+ DatabaseCleaner.strategy = :transaction
48
+ DatabaseCleaner.clean_with :truncation
49
+ end
50
+
51
+ config.before(:each) do
52
+ Project.any_instance.stub(:store_image_url).and_return('http://www.store_image_url.com')
53
+ end
54
+ end
55
+
56
+ RoutingFilter.active = false # Because this issue: https://github.com/svenfuchs/routing-filter/issues/36
57
+
58
+ def fixture_file(filename)
59
+ return nil if filename.nil?
60
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
61
+ File.read(file_path)
62
+ end
63
+
64
+ def dinero_mail_url(path, options = {})
65
+ options[:https] = true if options[:https].nil?
66
+ options[:country] ||= 'argentina'
67
+ protocol = (options[:https] == true) ? 'https' : 'http'
68
+ "#{protocol}://#{options[:country]}.dineromail.com#{path}"
69
+ end
70
+
71
+ def stub_get(path, filename, options={})
72
+ opts = {:body => fixture_file(filename)}.merge(options)
73
+
74
+ FakeWeb.register_uri(:get, dinero_mail_url(path), opts)
75
+ end
76
+
77
+ def stub_post(path, filename, options={})
78
+ opts = {:body => fixture_file(filename)}.merge(options)
79
+
80
+ FakeWeb.register_uri(:post, dinero_mail_url(path, options[:url]), opts)
81
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: catarse_dineromail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Josemar Davi Luedke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70261112682420 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70261112682420
25
+ - !ruby/object:Gem::Dependency
26
+ name: dinero_mail_checkout
27
+ requirement: &70261112682000 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70261112682000
36
+ - !ruby/object:Gem::Dependency
37
+ name: dinero_mail_ipn
38
+ requirement: &70261112681540 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70261112681540
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-rails
49
+ requirement: &70261112681120 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70261112681120
58
+ - !ruby/object:Gem::Dependency
59
+ name: fakeweb
60
+ requirement: &70261112709620 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70261112709620
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_girl_rails
71
+ requirement: &70261112709200 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70261112709200
80
+ - !ruby/object:Gem::Dependency
81
+ name: database_cleaner
82
+ requirement: &70261112708780 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70261112708780
91
+ description: Dineromail integration with Catarse crowdfunding platform
92
+ email:
93
+ - josemarluedke@gmail.com
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - .gitignore
99
+ - Gemfile
100
+ - Gemfile.lock
101
+ - MIT-LICENSE
102
+ - README.md
103
+ - Rakefile
104
+ - app/controllers/catarse_dineromail/payment/dineromail_controller.rb
105
+ - catarse_dineromail.gemspec
106
+ - config/routes.rb
107
+ - lib/catarse_dineromail.rb
108
+ - lib/catarse_dineromail/engine.rb
109
+ - lib/catarse_dineromail/version.rb
110
+ - script/rails
111
+ - spec/controllers/catarse_dineromail/payment/dineromail_spec.rb
112
+ - spec/fixtures/dineromail_ipn_request.xml
113
+ - spec/fixtures/dineromail_ipn_response.xml
114
+ - spec/spec_helper.rb
115
+ homepage: http://github.com/josemarluedke/catarse-dineromail
116
+ licenses: []
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.10
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: Dineromail integration with Catarse
139
+ test_files:
140
+ - spec/controllers/catarse_dineromail/payment/dineromail_spec.rb
141
+ - spec/fixtures/dineromail_ipn_request.xml
142
+ - spec/fixtures/dineromail_ipn_response.xml
143
+ - spec/spec_helper.rb