Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 4d75cd5

Browse files
committed
init files
0 parents  commit 4d75cd5

File tree

17 files changed

+577
-0
lines changed

17 files changed

+577
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.bundle/
2+
log/*.log
3+
pkg/
4+
test/dummy/db/*.sqlite3
5+
test/dummy/log/*.log
6+
test/dummy/tmp/
7+
test/dummy/.sass-cache
8+
test/dummy

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "test/dummy"]
2+
path = test/dummy
3+
url = git://github.com/danielweinmann/catarse.git

Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source "http://rubygems.org"
2+
3+
# Declare your gem's dependencies in catarse_moip.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

Gemfile.lock

+125
Original file line numberDiff line numberDiff line change
@@ -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

MIT-LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -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.

README.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# CatarseMoip
2+
3+
Catarse moip integration with [Catarse](https://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+

Rakefile

+27
Original file line numberDiff line numberDiff line change
@@ -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+
Original file line numberDiff line numberDiff line change
@@ -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

catarse_moip.gemspec

+26
Original file line numberDiff line numberDiff line change
@@ -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 = ["[email protected]"]
13+
s.homepage = "https://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

config/routes.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CatarseMoip::Engine.routes.draw do
2+
namespace :payment do
3+
resources :moip, only: [] do
4+
member do
5+
match :checkout
6+
end
7+
end
8+
end
9+
end

lib/catarse_moip.rb

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
require "catarse_moip/engine"
2+
3+
module CatarseMoip
4+
end

lib/catarse_moip/engine.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module CatarseMoip
2+
class Engine < ::Rails::Engine
3+
isolate_namespace CatarseMoip
4+
end
5+
end

lib/catarse_moip/version.rb

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module CatarseMoip
2+
VERSION = "0.0.1"
3+
end

lib/tasks/catarse_moip_tasks.rake

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# desc "Explaining what the task does"
2+
# task :catarse_moip do
3+
# # Task goes here
4+
# end

script/rails

+8
Original file line numberDiff line numberDiff line change
@@ -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 commit comments

Comments
 (0)