catarse_moip 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.gitmodules +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +125 -0
- data/MIT-LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +27 -0
- data/app/controllers/catarse_moip/payment/moip_controller.rb +59 -0
- data/catarse_moip.gemspec +26 -0
- data/config/routes.rb +9 -0
- data/lib/catarse_moip.rb +4 -0
- data/lib/catarse_moip/engine.rb +5 -0
- data/lib/catarse_moip/version.rb +3 -0
- data/lib/tasks/catarse_moip_tasks.rake +4 -0
- data/script/rails +8 -0
- data/spec/controllers/catarse_moip/payment/moip_controller_spec.rb +81 -0
- data/spec/spec_helper.rb +122 -0
- metadata +144 -0
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
catarse_moip (0.0.1)
|
5
|
+
moip (~> 2.1.1)
|
6
|
+
rails (~> 3.2.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.7)
|
12
|
+
actionpack (= 3.2.7)
|
13
|
+
mail (~> 2.4.4)
|
14
|
+
actionpack (3.2.7)
|
15
|
+
activemodel (= 3.2.7)
|
16
|
+
activesupport (= 3.2.7)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.0)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.1.3)
|
24
|
+
activemodel (3.2.7)
|
25
|
+
activesupport (= 3.2.7)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.7)
|
28
|
+
activemodel (= 3.2.7)
|
29
|
+
activesupport (= 3.2.7)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.7)
|
33
|
+
activemodel (= 3.2.7)
|
34
|
+
activesupport (= 3.2.7)
|
35
|
+
activesupport (3.2.7)
|
36
|
+
i18n (~> 0.6)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
arel (3.0.2)
|
39
|
+
builder (3.0.0)
|
40
|
+
database_cleaner (0.8.0)
|
41
|
+
diff-lcs (1.1.3)
|
42
|
+
erubis (2.7.0)
|
43
|
+
factory_girl (3.6.1)
|
44
|
+
activesupport (>= 3.0.0)
|
45
|
+
factory_girl_rails (3.6.0)
|
46
|
+
factory_girl (~> 3.6.0)
|
47
|
+
railties (>= 3.0.0)
|
48
|
+
hike (1.2.1)
|
49
|
+
httparty (0.8.3)
|
50
|
+
multi_json (~> 1.0)
|
51
|
+
multi_xml
|
52
|
+
i18n (0.6.0)
|
53
|
+
journey (1.0.4)
|
54
|
+
json (1.7.4)
|
55
|
+
mail (2.4.4)
|
56
|
+
i18n (>= 0.4.0)
|
57
|
+
mime-types (~> 1.16)
|
58
|
+
treetop (~> 1.4.8)
|
59
|
+
mime-types (1.19)
|
60
|
+
moip (2.1.2)
|
61
|
+
activesupport (>= 2.3.2)
|
62
|
+
httparty (~> 0.8.1)
|
63
|
+
moip
|
64
|
+
nokogiri (~> 1.4.3)
|
65
|
+
multi_json (1.3.6)
|
66
|
+
multi_xml (0.5.1)
|
67
|
+
nokogiri (1.4.7)
|
68
|
+
polyglot (0.3.3)
|
69
|
+
rack (1.4.1)
|
70
|
+
rack-cache (1.2)
|
71
|
+
rack (>= 0.4)
|
72
|
+
rack-ssl (1.3.2)
|
73
|
+
rack
|
74
|
+
rack-test (0.6.1)
|
75
|
+
rack (>= 1.0)
|
76
|
+
rails (3.2.7)
|
77
|
+
actionmailer (= 3.2.7)
|
78
|
+
actionpack (= 3.2.7)
|
79
|
+
activerecord (= 3.2.7)
|
80
|
+
activeresource (= 3.2.7)
|
81
|
+
activesupport (= 3.2.7)
|
82
|
+
bundler (~> 1.0)
|
83
|
+
railties (= 3.2.7)
|
84
|
+
railties (3.2.7)
|
85
|
+
actionpack (= 3.2.7)
|
86
|
+
activesupport (= 3.2.7)
|
87
|
+
rack-ssl (~> 1.3.2)
|
88
|
+
rake (>= 0.8.7)
|
89
|
+
rdoc (~> 3.4)
|
90
|
+
thor (>= 0.14.6, < 2.0)
|
91
|
+
rake (0.9.2.2)
|
92
|
+
rdoc (3.12)
|
93
|
+
json (~> 1.4)
|
94
|
+
rspec (2.11.0)
|
95
|
+
rspec-core (~> 2.11.0)
|
96
|
+
rspec-expectations (~> 2.11.0)
|
97
|
+
rspec-mocks (~> 2.11.0)
|
98
|
+
rspec-core (2.11.1)
|
99
|
+
rspec-expectations (2.11.2)
|
100
|
+
diff-lcs (~> 1.1.3)
|
101
|
+
rspec-mocks (2.11.1)
|
102
|
+
rspec-rails (2.11.0)
|
103
|
+
actionpack (>= 3.0)
|
104
|
+
activesupport (>= 3.0)
|
105
|
+
railties (>= 3.0)
|
106
|
+
rspec (~> 2.11.0)
|
107
|
+
sprockets (2.1.3)
|
108
|
+
hike (~> 1.2)
|
109
|
+
rack (~> 1.0)
|
110
|
+
tilt (~> 1.1, != 1.3.0)
|
111
|
+
thor (0.15.4)
|
112
|
+
tilt (1.3.3)
|
113
|
+
treetop (1.4.10)
|
114
|
+
polyglot
|
115
|
+
polyglot (>= 0.3.1)
|
116
|
+
tzinfo (0.3.33)
|
117
|
+
|
118
|
+
PLATFORMS
|
119
|
+
ruby
|
120
|
+
|
121
|
+
DEPENDENCIES
|
122
|
+
catarse_moip!
|
123
|
+
database_cleaner
|
124
|
+
factory_girl_rails
|
125
|
+
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,67 @@
|
|
1
|
+
# CatarseMoip
|
2
|
+
|
3
|
+
Catarse moip integration with [Catarse](http://github.com/danielweinmann/catarse) crowdfunding platform
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this lines to your Catarse application's Gemfile:
|
8
|
+
|
9
|
+
gem 'catarse_moip'
|
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 CatarseMoip::Engine => "/", :as => "catarse_moip"
|
20
|
+
|
21
|
+
### Configurations
|
22
|
+
|
23
|
+
Create this configurations into Catarse database:
|
24
|
+
|
25
|
+
moip_uri, moip_token and moip_key
|
26
|
+
|
27
|
+
In Rails console, run this:
|
28
|
+
|
29
|
+
Configuration.create!(name: "moip_uri", value: "https://desenvolvedor.moip.com.br/sandbox")
|
30
|
+
Configuration.create!(name: "moip_token", value: "TOKEN")
|
31
|
+
Configuration.create!(name: "moip_key", value: "KEY")
|
32
|
+
|
33
|
+
## Development environment setup
|
34
|
+
|
35
|
+
Clone the repository:
|
36
|
+
|
37
|
+
$ git clone git://github.com/devton/catarse_moip.git
|
38
|
+
|
39
|
+
Add the catarse code into test/dummy:
|
40
|
+
|
41
|
+
$ git submodule add git://github.com/danielweinmann/catarse.git test/dummy
|
42
|
+
|
43
|
+
Copy the Catarse's gems to Gemfile:
|
44
|
+
|
45
|
+
$ cat test/dummy/Gemfile >> Gemfile
|
46
|
+
|
47
|
+
And then execute:
|
48
|
+
|
49
|
+
$ bundle
|
50
|
+
|
51
|
+
## Troubleshooting in development environment
|
52
|
+
|
53
|
+
Remove the admin folder from test/dummy application to prevent a weird active admin bug:
|
54
|
+
|
55
|
+
$ rm -rf test/dummy/app/admin
|
56
|
+
|
57
|
+
## Contributing
|
58
|
+
|
59
|
+
1. Fork it
|
60
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
63
|
+
5. Create new Pull Request
|
64
|
+
|
65
|
+
|
66
|
+
This project rocks and uses MIT-LICENSE.
|
67
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
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 = 'CatarseMoip'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module CatarseMoip::Payment
|
2
|
+
class MoipController < ApplicationController
|
3
|
+
before_filter :setup_moip
|
4
|
+
|
5
|
+
def checkout
|
6
|
+
@backer = current_user.backs.not_confirmed.find params[:id]
|
7
|
+
begin
|
8
|
+
response = MoIP.checkout(payment_info)
|
9
|
+
@backer.update_attribute :payment_token, response["Token"]
|
10
|
+
session[:_payment_token] = response["Token"]
|
11
|
+
|
12
|
+
redirect_to MoIP.moip_page(response["Token"])
|
13
|
+
rescue Exception => e
|
14
|
+
Airbrake.notify({ :error_class => "Checkout MOIP Error", :error_message => "MOIP Error: #{e.inspect}", :parameters => params}) rescue nil
|
15
|
+
Rails.logger.info "-----> #{e.inspect}"
|
16
|
+
flash[:failure] = t('projects.backers.checkout.moip_error')
|
17
|
+
return redirect_to main_app.new_project_backer_path(@backer.project) #
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def setup_moip
|
24
|
+
MoIP.setup do |config|
|
25
|
+
config.uri = (::Configuration[:moip_uri] || 'https://moip.com.br/')
|
26
|
+
config.token = ::Configuration[:moip_token]
|
27
|
+
config.key = ::Configuration[:moip_key]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def payer_info
|
32
|
+
{
|
33
|
+
nome: current_user.full_name,
|
34
|
+
email: current_user.email,
|
35
|
+
logradouro: current_user.address_street,
|
36
|
+
numero: current_user.address_number,
|
37
|
+
complemento: current_user.address_complement,
|
38
|
+
bairro: current_user.address_neighbourhood,
|
39
|
+
cidade: current_user.address_city,
|
40
|
+
estado: current_user.address_state,
|
41
|
+
pais: 'BRA',
|
42
|
+
cep: current_user.address_zip_code,
|
43
|
+
tel_fixo: current_user.phone_number
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def payment_info
|
48
|
+
{
|
49
|
+
valor: "%0.0f" % (@backer.value),
|
50
|
+
id_proprio: @backer.key,
|
51
|
+
razao: "Apoio para o projeto '#{@backer.project.name}'",
|
52
|
+
forma: "BoletoBancario",
|
53
|
+
dias_expiracao: 2,
|
54
|
+
pagador: payer_info,
|
55
|
+
url_retorno: main_app.thank_you_url
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
# Maintain your gem's version:
|
5
|
+
require "catarse_moip/version"
|
6
|
+
|
7
|
+
# Describe your gem and declare its dependencies:
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "catarse_moip"
|
10
|
+
s.version = CatarseMoip::VERSION
|
11
|
+
s.authors = ["Antônio Roberto Silva"]
|
12
|
+
s.email = ["forevertonny@gmail.com"]
|
13
|
+
s.homepage = "http://github.com/devton/catarse_moip"
|
14
|
+
s.summary = "MoIP integration with Catarse"
|
15
|
+
s.description = "MoIP integration with Catarse crowdfunding platform"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split($\)
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
|
20
|
+
s.add_dependency "rails", "~> 3.2.6"
|
21
|
+
s.add_dependency 'moip', "~> 2.1.1"
|
22
|
+
|
23
|
+
s.add_development_dependency "rspec-rails"
|
24
|
+
s.add_development_dependency "factory_girl_rails"
|
25
|
+
s.add_development_dependency "database_cleaner"
|
26
|
+
end
|
data/config/routes.rb
ADDED
data/lib/catarse_moip.rb
ADDED
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_moip/engine', __FILE__)
|
6
|
+
|
7
|
+
require 'rails/all'
|
8
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CatarseMoip::Payment::MoipController do
|
4
|
+
context 'after user submit the review form' do
|
5
|
+
let(:current_user) { Factory(:user, :full_name => 'Lorem Ipsum',
|
6
|
+
:email => 'lorem@lorem.com',
|
7
|
+
:address_zip_code => '33600-999',
|
8
|
+
:address_street => 'R. Ipsum',
|
9
|
+
:address_number => '666',
|
10
|
+
:address_complement => 'House',
|
11
|
+
:address_city => 'Some City',
|
12
|
+
:address_state => 'LP',
|
13
|
+
:phone_number => '(90) 9999-9999') }
|
14
|
+
|
15
|
+
context 'found some errors' do
|
16
|
+
it 'should raise a error when current_user is not present' do
|
17
|
+
lambda {
|
18
|
+
post :checkout, { id: 10, locale: 'en', use_route: 'catarse_moip' }
|
19
|
+
}.should raise_exception
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'when backer already confirmed, should raise a not found' do
|
23
|
+
sign_in(current_user)
|
24
|
+
backer = Factory(:backer, confirmed: true, user: current_user)
|
25
|
+
|
26
|
+
lambda {
|
27
|
+
post :checkout, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
|
28
|
+
}.should raise_exception ActiveRecord::RecordNotFound
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'when backer not belongs to current_user, should raise a not found' do
|
32
|
+
sign_in(current_user)
|
33
|
+
backer = Factory(:backer)
|
34
|
+
|
35
|
+
lambda {
|
36
|
+
post :checkout, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
|
37
|
+
}.should raise_exception ActiveRecord::RecordNotFound
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'throught moip' do
|
42
|
+
context 'when raise something' do
|
43
|
+
before do
|
44
|
+
MoIP.stub(:checkout).and_raise(StandardError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should handle the error and redirect' do
|
48
|
+
sign_in(current_user)
|
49
|
+
backer = Factory(:backer, confirmed: false, user: current_user)
|
50
|
+
|
51
|
+
post :checkout, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
|
52
|
+
backer.reload
|
53
|
+
|
54
|
+
backer.payment_token.should be_nil
|
55
|
+
flash[:failure].should == I18n.t('projects.backers.checkout.moip_error')
|
56
|
+
response.should be_redirect
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'without error' do
|
61
|
+
before do
|
62
|
+
MoIP.stub(:checkout).and_return({'Token' => 'ABCD'})
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should redirect to moip, setup session payment_token and update backer with token' do
|
66
|
+
sign_in(current_user)
|
67
|
+
backer = Factory(:backer, confirmed: false, user: current_user)
|
68
|
+
|
69
|
+
post :checkout, { id: backer.id, locale: 'en', use_route: 'catarse_moip' }
|
70
|
+
backer.reload
|
71
|
+
|
72
|
+
backer.payment_token.should == 'ABCD'
|
73
|
+
session[:_payment_token].should == 'ABCD'
|
74
|
+
|
75
|
+
response.should redirect_to("https://www.moip.com.br/Instrucao.do?token=ABCD")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,122 @@
|
|
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 'fakeweb'
|
6
|
+
|
7
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
8
|
+
|
9
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
10
|
+
# in spec/support/ and its subdirectories.
|
11
|
+
Dir[File.join(ENGINE_RAILS_ROOT, 'spec/support/**/*.rb')].each {|f| require f }
|
12
|
+
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
# ## Mock Framework
|
16
|
+
#
|
17
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
18
|
+
#
|
19
|
+
# config.mock_with :mocha
|
20
|
+
# config.mock_with :flexmock
|
21
|
+
# config.mock_with :rr
|
22
|
+
|
23
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
24
|
+
config.fixture_path = "#{ENGINE_RAILS_ROOT}/spec/fixtures"
|
25
|
+
|
26
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
27
|
+
# examples within a transaction, remove the following line or assign false
|
28
|
+
# instead of true.
|
29
|
+
config.use_transactional_fixtures = false
|
30
|
+
|
31
|
+
# If true, the base class of anonymous controllers will be inferred
|
32
|
+
# automatically. This will be the default behavior in future versions of
|
33
|
+
# rspec-rails.
|
34
|
+
config.infer_base_class_for_anonymous_controllers = false
|
35
|
+
|
36
|
+
# Include Engine routes (needed for Controller specs)
|
37
|
+
config.include CatarseMoip::Engine.routes.url_helpers
|
38
|
+
|
39
|
+
# Include Catarse routes
|
40
|
+
config.include Catarse::Application.routes.url_helpers
|
41
|
+
|
42
|
+
config.include Devise::TestHelpers, :type => :controller
|
43
|
+
|
44
|
+
config.include Factory::Syntax::Methods
|
45
|
+
config.before(:suite) do
|
46
|
+
DatabaseCleaner.strategy = :transaction
|
47
|
+
DatabaseCleaner.clean_with :truncation
|
48
|
+
end
|
49
|
+
|
50
|
+
config.before(:each) do
|
51
|
+
Project.any_instance.stub(:store_image_url).and_return('http://www.store_image_url.com')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
RoutingFilter.active = false # Because this issue: https://github.com/svenfuchs/routing-filter/issues/36
|
56
|
+
|
57
|
+
def fixture_file(filename)
|
58
|
+
return nil if filename.nil?
|
59
|
+
file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
|
60
|
+
File.read(file_path)
|
61
|
+
end
|
62
|
+
def post_moip_params
|
63
|
+
{
|
64
|
+
:id_transacao => 'ABCD',
|
65
|
+
:valor => 2190, #=> R$ 21,90
|
66
|
+
:status_pagamento => 3,
|
67
|
+
:cod_moip => 12345123,
|
68
|
+
:forma_pagamento => 1,
|
69
|
+
:tipo_pagamento => 'CartaoDeCredito',
|
70
|
+
:email_consumidor => 'some@email.com'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def moip_query_response
|
75
|
+
{
|
76
|
+
"ID"=>"201109300946542390000012428473", "Status"=>"Sucesso",
|
77
|
+
"Autorizacao"=>{
|
78
|
+
"Pagador"=>{
|
79
|
+
"Nome"=>"Lorem Ipsum", "Email"=>"some@email.com"
|
80
|
+
},
|
81
|
+
"EnderecoCobranca"=>{
|
82
|
+
"Logradouro"=>"Some Address ,999", "Numero"=>"999",
|
83
|
+
"Complemento"=>"Address A", "Bairro"=>"Hello World", "CEP"=>"99999-000",
|
84
|
+
"Cidade"=>"Some City", "Estado"=>"MG", "Pais"=>"BRA",
|
85
|
+
"TelefoneFixo"=>"(31)3666-6666"
|
86
|
+
},
|
87
|
+
"Recebedor"=>{
|
88
|
+
"Nome"=>"Happy Guy", "Email"=>"happy@email.com"
|
89
|
+
},
|
90
|
+
"Pagamento"=>{
|
91
|
+
"Data"=>"2011-09-30T09:33:37.000-03:00", "TotalPago"=>"999.00", "TaxaParaPagador"=>"0.00",
|
92
|
+
"TaxaMoIP"=>"19.37", "ValorLiquido"=>"979.63", "FormaPagamento"=>"BoletoBancario",
|
93
|
+
"InstituicaoPagamento"=>"Itau", "Status"=>"BoletoImpresso", "CodigoMoIP"=>"0000.0728.5285"
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def moip_query_response_with_array
|
100
|
+
{
|
101
|
+
"ID"=>"201109300946542390000012428473", "Status"=>"Sucesso",
|
102
|
+
"Autorizacao"=>{
|
103
|
+
"Pagador"=>{
|
104
|
+
"Nome"=>"Lorem Ipsum", "Email"=>"some@email.com"
|
105
|
+
},
|
106
|
+
"EnderecoCobranca"=>{
|
107
|
+
"Logradouro"=>"Some Address ,999", "Numero"=>"999",
|
108
|
+
"Complemento"=>"Address A", "Bairro"=>"Hello World", "CEP"=>"99999-000",
|
109
|
+
"Cidade"=>"Some City", "Estado"=>"MG", "Pais"=>"BRA",
|
110
|
+
"TelefoneFixo"=>"(31)3666-6666"
|
111
|
+
},
|
112
|
+
"Recebedor"=>{
|
113
|
+
"Nome"=>"Happy Guy", "Email"=>"happy@email.com"
|
114
|
+
},
|
115
|
+
"Pagamento"=>[{
|
116
|
+
"Data"=>"2011-09-30T09:33:37.000-03:00", "TotalPago"=>"999.00", "TaxaParaPagador"=>"0.00",
|
117
|
+
"TaxaMoIP"=>"19.37", "ValorLiquido"=>"979.63", "FormaPagamento"=>"BoletoBancario",
|
118
|
+
"InstituicaoPagamento"=>"Itau", "Status"=>"BoletoImpresso", "CodigoMoIP"=>"0000.0728.5285"
|
119
|
+
}]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: catarse_moip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Antônio Roberto Silva
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: moip
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.1.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.1.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec-rails
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: factory_girl_rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: database_cleaner
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: MoIP integration with Catarse crowdfunding platform
|
95
|
+
email:
|
96
|
+
- forevertonny@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- .gitmodules
|
103
|
+
- Gemfile
|
104
|
+
- Gemfile.lock
|
105
|
+
- MIT-LICENSE
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- app/controllers/catarse_moip/payment/moip_controller.rb
|
109
|
+
- catarse_moip.gemspec
|
110
|
+
- config/routes.rb
|
111
|
+
- lib/catarse_moip.rb
|
112
|
+
- lib/catarse_moip/engine.rb
|
113
|
+
- lib/catarse_moip/version.rb
|
114
|
+
- lib/tasks/catarse_moip_tasks.rake
|
115
|
+
- script/rails
|
116
|
+
- spec/controllers/catarse_moip/payment/moip_controller_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
homepage: http://github.com/devton/catarse_moip
|
119
|
+
licenses: []
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ! '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.8.21
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
141
|
+
summary: MoIP integration with Catarse
|
142
|
+
test_files:
|
143
|
+
- spec/controllers/catarse_moip/payment/moip_controller_spec.rb
|
144
|
+
- spec/spec_helper.rb
|