diff --git a/.gitignore b/.gitignore index b73c12c..a3c0dc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .bundle/ -log/*.log +*.log pkg/ catarse_moip-0.0.2.gem diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index fad9d6f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "test/dummy"] - path = test/dummy - url = git://github.com/danielweinmann/catarse.git diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..46935a8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,17 @@ +rvm: + - 1.9.3 + +node_js: + - "0.10" + +before_script: + - "psql -c 'create role catarse SUPERUSER LOGIN;' postgres" + - "psql -c 'create database catarse_test;' -U catarse postgres" + - "npm install -g jquery jsdom jasmine-node" + +script: + - "bundle exec rake" + +branches: + only: + - master diff --git a/Gemfile b/Gemfile index d4cc3ca..0bae460 100644 --- a/Gemfile +++ b/Gemfile @@ -1,122 +1,6 @@ source "http://rubygems.org" -# Declare your gem's dependencies in catarse_moip.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. gemspec -source :gemcutter -source 'http://gems.github.com' -gem 'rails', '3.2.11' - -gem 'sidekiq', '= 2.4.0' -gem 'sinatra', require: false -gem 'foreman' -gem 'best_in_place' - -gem 'state_machine', require: 'state_machine/core' - -# Database and data related +gem 'moip', git: 'git://github.com/catarse/moip-ruby.git' gem 'pg' -gem 'pg_search' -gem 'postgres-copy' -gem 'schema_plus' - -gem 'catarse_paypal_express', git: 'git://github.com/devton/catarse_paypal_express.git', ref: '4fd17e269395ee4b3a32528ace0bcb7eec57a953' -#gem 'catarse_paypal_express', path: '../catarse_paypal_express' -#gem 'catarse_moip', git: 'git://github.com/devton/catarse_moip.git' -#gem 'catarse_moip', path: '../catarse_moip' -gem 'moip', git: 'git://github.com/moiplabs/moip-ruby.git' - -gem 'draper' - -# Frontend stuff -gem 'slim' -gem 'slim-rails' -gem 'jquery-rails' -gem 'initjs' - -# Authentication and Authorization -gem 'omniauth', "~> 1.1.0" -gem 'omniauth-openid', '~> 1.0.1' -gem 'omniauth-twitter', '~> 0.0.12' -gem 'omniauth-facebook', '~> 1.2.0' -gem 'omniauth-github', '~> 1.0.1' -gem 'omniauth-linkedin', '~> 0.0.6' -gem 'omniauth-yahoo', '~> 0.0.4' -gem 'devise', '1.5.3' -gem 'cancan', git: 'git://github.com/ryanb/cancan.git', branch: '2.0', ref: 'f1cebde51a87be149b4970a3287826bb63c0ac0b' - - -# Error reporting -gem "airbrake" - -# Email marketing -#gem 'mailchimp' -gem 'catarse_mailchimp', git: 'git://github.com/devton/catarse_mailchimp' - -# HTML manipulation and formatting -gem 'formtastic', "~> 2.1.1" -gem "auto_html", '= 1.4.2' -gem 'kaminari' -gem 'rails_autolink', '~> 1.0.7' - -# Uploads -gem 'carrierwave', '~> 0.7.0' -gem 'rmagick' -gem 'fog' - -# Other Tools -gem 'feedzirra' -gem 'validation_reflection', git: 'git://github.com/ncri/validation_reflection.git' -gem 'inherited_resources', '1.3.1' -gem 'has_scope' -gem 'spectator-validates_email', require: 'validates_email' -gem 'has_vimeo_video', '~> 0.0.5' -gem 'memoist', '~> 0.2.0' -gem 'wirble' -gem "on_the_spot" -gem 'weekdays' -gem 'brcep' -gem "RedCloth" -gem 'unicode' -gem 'enumerate_it' -gem 'httparty', '~> 0.6.1' -gem "rack-timeout" - -# Translations -gem 'http_accept_language' -gem 'routing-filter' #, :git => 'git://github.com/svenfuchs/routing-filter.git' - -# Administration -gem "meta_search", "1.1.3" - -# Payment -gem 'activemerchant', '1.17.0', require: 'active_merchant' -gem 'httpclient', '2.2.5' -gem 'selenium-webdriver' - -# Server -gem 'thin' - -group :assets do - gem 'sass-rails', '~> 3.2.5' - gem 'coffee-rails', '~> 3.2.2' - gem "compass-rails", "~> 1.0.2" - gem 'uglifier', '>= 1.0.3' - gem 'compass-960-plugin', '~> 0.10.4' -end - -group :test, :development do - gem 'launchy' - gem 'database_cleaner' - gem 'rspec-rails', "~> 2.10.0" - gem 'mocha', '0.10.4' - gem 'shoulda' - gem 'factory_girl_rails', '1.7.0' - gem 'capybara', ">= 1.0.1" -end - -group :development do - gem 'mailcatcher' -end diff --git a/Gemfile.lock b/Gemfile.lock index 97159ce..02f8dfd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,522 +1,128 @@ GIT - remote: git://github.com/devton/catarse_mailchimp - revision: a5be917969a1df6010fbbdea25a5c1407c6f8659 - specs: - catarse_mailchimp (0.0.1) - mailchimp - supermodel - -GIT - remote: git://github.com/devton/catarse_paypal_express.git - revision: 4fd17e269395ee4b3a32528ace0bcb7eec57a953 - ref: 4fd17e269395ee4b3a32528ace0bcb7eec57a953 - specs: - catarse_paypal_express (0.1.0) - activemerchant (~> 1.17.0) - rails (~> 3.2.6) - -GIT - remote: git://github.com/moiplabs/moip-ruby.git - revision: 2b61a77355cb8c5487ff68be0eef8873696a110e + remote: git://github.com/catarse/moip-ruby.git + revision: 39f9dab38fc33fe9bf614deb8e90ca166ab2d6bf specs: moip (1.0.2) activesupport (>= 2.3.2) httparty (~> 0.6.1) - nokogiri (~> 1.4.3) - -GIT - remote: git://github.com/ncri/validation_reflection.git - revision: 60320e6beb088808fd625a8d958dbd0d2661d494 - specs: - validation_reflection (1.0.0) - -GIT - remote: git://github.com/ryanb/cancan.git - revision: f1cebde51a87be149b4970a3287826bb63c0ac0b - ref: f1cebde51a87be149b4970a3287826bb63c0ac0b - branch: 2.0 - specs: - cancan (2.0.0.alpha) + nokogiri (~> 1.5.0) PATH remote: . specs: - catarse_moip (0.1.1) - libxml-ruby (~> 2.3.3) - rails (~> 3.2.6) + catarse_moip (2.3.4) + enumerate_it + libxml-ruby (~> 2.6.0) + rails (~> 4.0) GEM remote: http://rubygems.org/ - remote: http://rubygems.org/ - remote: http://gems.github.com/ specs: - RedCloth (4.2.9) - actionmailer (3.2.11) - actionpack (= 3.2.11) - mail (~> 2.4.4) - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) + actionmailer (4.0.0) + actionpack (= 4.0.0) + mail (~> 2.5.3) + actionpack (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.0) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemerchant (1.17.0) - activesupport (>= 2.3.11) - braintree (>= 2.0.0) - builder (>= 2.0.0) - json (>= 1.5.1) - activemodel (3.2.11) - activesupport (= 3.2.11) - builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) - activesupport (3.2.11) - i18n (~> 0.6) - multi_json (~> 1.0) - addressable (2.3.2) - airbrake (3.1.2) - activesupport - builder - arel (3.0.2) - auto_html (1.4.2) - RedCloth - redcarpet - rinku - tag_helper - bcrypt-ruby (3.0.1) - best_in_place (2.0.3) - jquery-rails - rails (~> 3.1) - braintree (2.16.0) - builder (>= 2.0.0) - brcep (3.2.0) - builder (3.0.4) - capybara (1.1.2) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - selenium-webdriver (~> 2.0) - xpath (~> 0.1.4) - carrierwave (0.7.1) - activemodel (>= 3.2.0) - activesupport (>= 3.2.0) - celluloid (0.12.3) - facter (>= 1.6.12) - timers (>= 1.0.0) - childprocess (0.3.5) - ffi (~> 1.0, >= 1.0.6) - chunky_png (1.2.6) - coffee-rails (3.2.2) - coffee-script (>= 2.2.0) - railties (~> 3.2.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.3.3) - compass (0.12.2) - chunky_png (~> 1.2) - fssm (>= 0.2.7) - sass (~> 3.1) - compass-960-plugin (0.10.4) - compass (>= 0.10.0) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) - connection_pool (0.9.2) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + arel (4.0.1) + atomic (1.1.14) + builder (3.1.4) crack (0.1.8) - curb (0.7.18) - daemons (1.1.9) - database_cleaner (0.8.0) - devise (1.5.3) - bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) - diff-lcs (1.1.3) - draper (0.17.0) - actionpack (~> 3.2) - activesupport (~> 3.2) - enumerate_it (0.7.17) + database_cleaner (1.1.1) + diff-lcs (1.2.4) + enumerate_it (1.2.0) activesupport (>= 3.0.0) erubis (2.7.0) - eventmachine (0.12.10) - excon (0.6.6) - execjs (1.4.0) - multi_json (~> 1.0) - facter (1.6.16) - factory_girl (2.6.4) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) + factory_girl (4.2.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.2.1) + factory_girl (~> 4.2.0) railties (>= 3.0.0) - faraday (0.8.4) - multipart-post (~> 1.1) - feedzirra (0.0.31) - activesupport (>= 3.0.8) - builder (~> 3.0.0) - curb (~> 0.7.15) - i18n (>= 0.5.0) - loofah (~> 1.0.0) - nokogiri (~> 1.4.4) - rake (>= 0.9.2) - rdoc (~> 3.8) - sax-machine (~> 0.0.20) - ffi (1.1.5) - fog (0.9.0) - builder - excon (~> 0.6.1) - formatador (>= 0.1.3) - json - mime-types - net-scp (>= 1.0.4) - net-ssh (>= 2.1.4) - nokogiri (>= 1.4.4) - ruby-hmac - foreman (0.60.2) - thor (>= 0.13.6) - formatador (0.2.3) - formtastic (2.1.1) - actionpack (~> 3.0) - fssm (0.2.9) - haml (3.1.7) - has_scope (0.5.1) - has_vimeo_video (0.0.5) - supermodel - vimeo - hashie (1.2.0) - hike (1.2.1) - http_accept_language (1.0.2) + hike (1.2.3) httparty (0.6.1) crack (= 0.1.8) - httpauth (0.1) - httpclient (2.2.5) - i18n (0.6.1) - inherited_resources (1.3.1) - has_scope (~> 0.5.0) - responders (~> 0.6) - initjs (0.1.2) - rails (~> 3.1) - journey (1.0.4) - jquery-rails (2.1.1) - railties (>= 3.1.0, < 5.0) - thor (~> 0.14) - json (1.7.6) - json_pure (1.7.5) - jwt (0.1.5) - multi_json (>= 1.0) - kaminari (0.14.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - launchy (2.1.2) - addressable (~> 2.3) - libwebsocket (0.1.5) - addressable - libxml-ruby (2.3.3) - loofah (1.0.0) - nokogiri (>= 1.3.3) - mail (2.4.4) - i18n (>= 0.4.0) + i18n (0.6.5) + libxml-ruby (2.6.0) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - mailcatcher (0.5.8) - activesupport (~> 3.0) - eventmachine (~> 0.12) - haml (~> 3.1) - mail (~> 2.3) - sinatra (~> 1.2) - skinny (~> 0.2, >= 0.2.1) - sqlite3 (~> 1.3) - thin (~> 1.2) - mailchimp (0.0.7.alpha) - httparty - memoist (0.2.0) - meta_search (1.1.3) - actionpack (~> 3.1) - activerecord (~> 3.1) - activesupport (~> 3.1) - polyamorous (~> 0.5.0) - metaclass (0.0.1) - mime-types (1.20.1) - mocha (0.10.4) - metaclass (~> 0.0.1) - multi_json (1.5.0) - multipart-post (1.1.5) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-ssh (2.5.2) - nokogiri (1.4.7) - oauth (0.4.6) - oauth2 (0.8.0) - faraday (~> 0.8) - httpauth (~> 0.1) - jwt (~> 0.1.4) - multi_json (~> 1.0) - rack (~> 1.2) - omniauth (1.1.1) - hashie (~> 1.2) - rack - omniauth-facebook (1.2.0) - omniauth-oauth2 (~> 1.0.0) - omniauth-github (1.0.1) - omniauth (~> 1.0) - omniauth-oauth2 (~> 1.0) - omniauth-linkedin (0.0.8) - omniauth-oauth (~> 1.0) - omniauth-oauth (1.0.1) - oauth - omniauth (~> 1.0) - omniauth-oauth2 (1.0.3) - oauth2 (~> 0.8.0) - omniauth (~> 1.0) - omniauth-openid (1.0.1) - omniauth (~> 1.0) - rack-openid (~> 1.3.1) - omniauth-twitter (0.0.12) - multi_json (~> 1.3) - omniauth-oauth (~> 1.0) - omniauth-yahoo (0.0.4) - omniauth-oauth (~> 1.0) - on_the_spot (1.0.1) - json_pure (>= 1.4.6) - orm_adapter (0.0.7) - pg (0.14.1) - pg_search (0.5.7) - activerecord (>= 3) - activesupport (>= 3) - polyamorous (0.5.0) - activerecord (~> 3.0) + mime-types (1.25.1) + minitest (4.7.5) + multi_json (1.8.0) + nokogiri (1.5.10) + pg (0.17.0) polyglot (0.3.3) - postgres-copy (0.5.7) - activerecord (>= 3.0.0) - pg - rails (>= 3.0.0) - responders - rack (1.4.4) - rack-cache (1.2) - rack (>= 0.4) - rack-openid (1.3.1) - rack (>= 1.1.0) - ruby-openid (>= 2.1.8) - rack-protection (1.2.0) - rack - rack-ssl (1.3.3) - rack + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rack-timeout (0.0.3) - rails (3.2.11) - actionmailer (= 3.2.11) - actionpack (= 3.2.11) - activerecord (= 3.2.11) - activeresource (= 3.2.11) - activesupport (= 3.2.11) - bundler (~> 1.0) - railties (= 3.2.11) - rails_autolink (1.0.9) - rails (~> 3.1) - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) - rack-ssl (~> 1.3.2) + rails (4.0.0) + actionmailer (= 4.0.0) + actionpack (= 4.0.0) + activerecord (= 4.0.0) + activesupport (= 4.0.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.0) + sprockets-rails (~> 2.0.0) + railties (4.0.0) + actionpack (= 4.0.0) + activesupport (= 4.0.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.0.3) - rdoc (3.12) - json (~> 1.4) - redcarpet (2.1.1) - redis (3.0.2) - redis-namespace (1.2.1) - redis (~> 3.0.0) - responders (0.9.2) - railties (~> 3.1) - rinku (1.7.0) - rmagick (2.13.1) - routing-filter (0.3.1) - actionpack - rspec (2.10.0) - rspec-core (~> 2.10.0) - rspec-expectations (~> 2.10.0) - rspec-mocks (~> 2.10.0) - rspec-core (2.10.1) - rspec-expectations (2.10.0) - diff-lcs (~> 1.1.3) - rspec-mocks (2.10.1) - rspec-rails (2.10.1) + thor (>= 0.18.1, < 2.0) + rake (10.1.0) + rspec-core (2.14.5) + rspec-expectations (2.14.2) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.3) + rspec-rails (2.14.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.10.0) - ruby-hmac (0.4.0) - ruby-openid (2.2.0) - rubyzip (0.9.9) - sass (3.2.1) - sass-rails (3.2.5) - railties (~> 3.2.0) - sass (>= 3.1.10) - tilt (~> 1.3) - sax-machine (0.0.20) - nokogiri (> 0.0.0) - schema_plus (1.0.1) - rails (>= 3.2) - valuable - selenium-webdriver (2.25.0) - childprocess (>= 0.2.5) - libwebsocket (~> 0.1.3) - multi_json (~> 1.0) - rubyzip - shoulda (3.1.1) - shoulda-context (~> 1.0) - shoulda-matchers (~> 1.2) - shoulda-context (1.0.0) - shoulda-matchers (1.3.0) - activesupport (>= 3.0.0) - sidekiq (2.4.0) - celluloid (~> 0.12.0) - connection_pool (~> 0.9.2) - multi_json (~> 1) - redis (~> 3) - redis-namespace - sinatra (1.3.3) - rack (~> 1.3, >= 1.3.6) - rack-protection (~> 1.2) - tilt (~> 1.3, >= 1.3.3) - skinny (0.2.1) - eventmachine (~> 0.12) - thin (~> 1.2) - slim (1.2.2) - temple (~> 0.4.0) - tilt (~> 1.3.3) - slim-rails (1.0.3) - actionpack (~> 3.0) - activesupport (~> 3.0) - railties (~> 3.0) - slim (~> 1.0) - spectator-validates_email (0.1.1) - actionpack (>= 3.0.0) - activemodel (>= 3.0.0) - sprockets (2.2.2) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) + sprockets (2.10.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) - state_machine (1.1.2) - supermodel (0.1.4) - activemodel (>= 3.0.0.beta) - tag_helper (0.0.3) - temple (0.4.0) - thin (1.4.1) - daemons (>= 1.0.9) - eventmachine (>= 0.12.6) - rack (>= 1.0.0) - thor (0.17.0) - tilt (1.3.3) - timers (1.0.1) - treetop (1.4.12) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + thor (0.18.1) + thread_safe (0.1.3) + atomic + tilt (1.4.1) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) - execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - unicode (0.4.3) - valuable (0.9.6) - vimeo (1.5.3) - httparty (>= 0.4.5) - httpclient (>= 2.1.5.2) - json (>= 1.1.9) - multipart-post (>= 1.0.1) - oauth (>= 0.4.3) - warden (1.2.1) - rack (>= 1.0) - weekdays (1.0.2) - wirble (0.1.3) - xpath (0.1.4) - nokogiri (~> 1.3) + tzinfo (0.3.37) PLATFORMS ruby DEPENDENCIES - RedCloth - activemerchant (= 1.17.0) - airbrake - auto_html (= 1.4.2) - best_in_place - brcep - cancan! - capybara (>= 1.0.1) - carrierwave (~> 0.7.0) - catarse_mailchimp! catarse_moip! - catarse_paypal_express! - coffee-rails (~> 3.2.2) - compass-960-plugin (~> 0.10.4) - compass-rails (~> 1.0.2) database_cleaner - devise (= 1.5.3) - draper - enumerate_it - factory_girl_rails (= 1.7.0) - feedzirra - fog - foreman - formtastic (~> 2.1.1) - has_scope - has_vimeo_video (~> 0.0.5) - http_accept_language - httparty (~> 0.6.1) - httpclient (= 2.2.5) - inherited_resources (= 1.3.1) - initjs - jquery-rails - kaminari - launchy - mailcatcher - memoist (~> 0.2.0) - meta_search (= 1.1.3) - mocha (= 0.10.4) + factory_girl_rails moip! - omniauth (~> 1.1.0) - omniauth-facebook (~> 1.2.0) - omniauth-github (~> 1.0.1) - omniauth-linkedin (~> 0.0.6) - omniauth-openid (~> 1.0.1) - omniauth-twitter (~> 0.0.12) - omniauth-yahoo (~> 0.0.4) - on_the_spot pg - pg_search - postgres-copy - rack-timeout - rails (= 3.2.11) - rails_autolink (~> 1.0.7) - rmagick - routing-filter - rspec-rails (~> 2.10.0) - sass-rails (~> 3.2.5) - schema_plus - selenium-webdriver - shoulda - sidekiq (= 2.4.0) - sinatra - slim - slim-rails - spectator-validates_email - state_machine - thin - uglifier (>= 1.0.3) - unicode - validation_reflection! - weekdays - wirble + rspec-rails (~> 2.14.0) diff --git a/README.md b/README.md index f87991c..e597092 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# CatarseMoip +# CatarseMoip [](https://travis-ci.org/catarse/catarse_moip) -Catarse moip integration with [Catarse](http://github.com/danielweinmann/catarse) crowdfunding platform +Catarse moip integration with [Catarse](http://github.com/catarse/catarse) crowdfunding platform ## Installation @@ -18,6 +18,12 @@ Configure the routes for your Catarse application. Add the following lines in th mount CatarseMoip::Engine => "/", :as => "catarse_moip" +## Rails 3.2.x and Rails 4 support + +If you are using the Rails 3.2.x on Catarse's code, you can use the version `1.0.0`. + +For Rails 4 support use the `2.0.0` version. + ### Configurations Create this configurations into Catarse database: @@ -30,30 +36,6 @@ In Rails console, run this: Configuration.create!(name: "moip_token", value: "TOKEN") Configuration.create!(name: "moip_key", value: "KEY") -## Development environment setup - -Clone the repository: - - $ git clone git://github.com/devton/catarse_moip.git - -Add the catarse code into test/dummy: - - $ git submodule add git://github.com/danielweinmann/catarse.git test/dummy - -Copy the Catarse's gems to Gemfile: - - $ cat test/dummy/Gemfile >> Gemfile - -And then execute: - - $ bundle - -## Troubleshooting in development environment - -Remove the admin folder from test/dummy application to prevent a weird active admin bug: - - $ rm -rf test/dummy/app/admin - ## Contributing 1. Fork it diff --git a/Rakefile b/Rakefile index 37f9b2d..6631f5b 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ #!/usr/bin/env rake begin require 'bundler/setup' + require 'rspec/core/rake_task' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end @@ -20,8 +21,12 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end +Bundler::GemHelper.install_tasks +RSpec::Core::RakeTask.new(:spec) +task :jasmine do + sh "jasmine-node spec/javascripts" +end - -Bundler::GemHelper.install_tasks +task default: [:spec, :jasmine] diff --git a/app/assets/javascripts/catarse_moip.js b/app/assets/javascripts/catarse_moip.js index 50726e8..a563a3a 100644 --- a/app/assets/javascripts/catarse_moip.js +++ b/app/assets/javascripts/catarse_moip.js @@ -1,6 +1,7 @@ +//= require ./catarse_moip/moip_form //= require ./catarse_moip/user_document //= require_tree ./catarse_moip $(function(){ - var view = window.moipForm = new CATARSE.MoipForm(); + app.createViewGetters(); }); diff --git a/app/assets/javascripts/catarse_moip/moip_form.js b/app/assets/javascripts/catarse_moip/moip_form.js index 2f98e7d..90b609e 100644 --- a/app/assets/javascripts/catarse_moip/moip_form.js +++ b/app/assets/javascripts/catarse_moip/moip_form.js @@ -1,21 +1,20 @@ -CATARSE.MoipForm = Backbone.View.extend({ +App.addChild('MoipForm', { el: 'form.moip', getMoipToken: function(onSuccess){ var that = this; - //$('#MoipWidget').remove(); if($('#MoipWidget').length > 0) { if(_.isFunction(onSuccess)){ onSuccess(); } } else { - $.post('/payment/moip/' + this.backerId + '/get_moip_token').success(function(response, textStatus){ + $.post('/payment/moip/' + this.contributionId + '/get_moip_token').success(function(response, textStatus){ that.paymentChoice.$('input').attr('disabled', 'disabled'); if(response.get_token_response.status == 'fail'){ that.checkoutFailure({Code: 0, Mensagem: response.get_token_response.message}); } else{ - $('#catarse_moip_form').prepend(response.widget_tag); + that.createMoipWidget(response); if(_.isFunction(onSuccess)){ onSuccess(response); } @@ -24,6 +23,17 @@ CATARSE.MoipForm = Backbone.View.extend({ } }, + createMoipWidget: function(data) { + widget_tag = $("
").attr({ + id: data.widget_tag.tag_id, + 'data-token': data.widget_tag.token, + 'callback-method-success': data.widget_tag.callback_success, + 'callback-method-error': data.widget_tag.callback_error, + }); + + $("#catarse_moip_form").prepend(widget_tag); + }, + checkoutFailure: function(data) { this.loader.hide(); var response_data = (data.length > 0 ? data[0] : data); @@ -37,7 +47,7 @@ CATARSE.MoipForm = Backbone.View.extend({ checkoutSuccessful: function(data) { var that = this; - $.post('/payment/moip/' + this.backerId + '/moip_response', {response: data}).success(function(){ + $.post('/payment/moip/' + this.contributionId + '/moip_response', {response: data}).success(function(){ that.loader.hide(); // Bail out when get an error from MoIP if(data.Status == 'Cancelado'){ @@ -45,15 +55,14 @@ CATARSE.MoipForm = Backbone.View.extend({ } // Go on otherwise - if(data.url) { + if(data.url && $('#payment_type_cards_section').css('display') != 'block') { var link = $(''+data.url+'') link.attr('href', data.url); $('.link_content:visible').empty().html(link); $('.payment_section:visible .subtitle').fadeIn('fast'); } - - var thank_you = $('#project_review').data('thank-you-path'); - if($('#payment_type_cards_section').css('display') == 'block') { + else { + var thank_you = $('#project_review').data('thank-you-path'); if(thank_you){ location.href = thank_you; } @@ -64,17 +73,13 @@ CATARSE.MoipForm = Backbone.View.extend({ }); }, - initialize: function(){ + activate: function(){ this.message = this.$('.next_step_after_valid_document .alert-danger'); - this.backerId = $('input#backer_id').val(); + this.contributionId = $('input#contribution_id').val(); this.projectId = $('input#project_id').val(); this.loader = this.$('.loader'); - this.paymentChoice = new CATARSE.PaymentChoice(); - this.paymentCard = new CATARSE.PaymentCard({moipForm: this}); - this.paymentSlip = new CATARSE.PaymentSlip({moipForm: this}); - this.paymentAccount = new CATARSE.PaymentAccount({moipForm: this}); window.checkoutSuccessful = _.bind(this.checkoutSuccessful, this); window.checkoutFailure = _.bind(this.checkoutFailure, this); } diff --git a/app/assets/javascripts/catarse_moip/payment_account.js b/app/assets/javascripts/catarse_moip/payment_account.js index 322a471..ec70d38 100644 --- a/app/assets/javascripts/catarse_moip/payment_account.js +++ b/app/assets/javascripts/catarse_moip/payment_account.js @@ -1,14 +1,15 @@ -CATARSE.PaymentAccount = CATARSE.UserDocument.extend({ +App.views.MoipForm.addChild('PaymentAccount', _.extend({ el: '#payment_type_account_section', events: { 'change select#account' : 'onChangeAccount', 'click input#build_account_link' : 'onBuildAccountClick', - 'keyup #user_document_account' : 'onUserDocumentKeyup' + 'keyup #user_document_account' : 'onUserDocumentKeyup', + 'click .link_content a' : 'onContentClick', }, - initialize: function(options){ - this.moipForm = options.moipForm; + activate: function(){ + this.moipForm = this.parent; this.$('input#user_document_account').mask("999.999.999-99"); }, @@ -32,5 +33,5 @@ CATARSE.PaymentAccount = CATARSE.UserDocument.extend({ MoipWidget(settings); }); } -}); +}, App.views.MoipForm.UserDocument)); diff --git a/app/assets/javascripts/catarse_moip/payment_card.js b/app/assets/javascripts/catarse_moip/payment_card.js index 64111e3..b24f91b 100644 --- a/app/assets/javascripts/catarse_moip/payment_card.js +++ b/app/assets/javascripts/catarse_moip/payment_card.js @@ -1,4 +1,4 @@ -CATARSE.PaymentCard = CATARSE.UserDocument.extend({ +App.views.MoipForm.addChild('PaymentCard', _.extend({ el: '#payment_type_cards_section', events: { @@ -8,9 +8,9 @@ CATARSE.PaymentCard = CATARSE.UserDocument.extend({ 'keyup #payment_card_cpf' : 'onUserDocumentKeyup' }, - initialize: function(options){ + activate: function(options){ // Set credit card fields masks - this.moipForm = options.moipForm; + this.moipForm = this.parent; this.$('input#payment_card_date').mask('99/99'); this.$('input#payment_card_birth').mask('99/99/9999'); this.$('input#payment_card_cpf').mask("999.999.999-99"); @@ -86,5 +86,4 @@ CATARSE.PaymentCard = CATARSE.UserDocument.extend({ } return 'Desconhecido'; } -}); - +}, App.views.MoipForm.UserDocument)); diff --git a/app/assets/javascripts/catarse_moip/payment_choice.js b/app/assets/javascripts/catarse_moip/payment_choice.js index be29648..953b13b 100644 --- a/app/assets/javascripts/catarse_moip/payment_choice.js +++ b/app/assets/javascripts/catarse_moip/payment_choice.js @@ -1,4 +1,4 @@ -CATARSE.PaymentChoice = Backbone.View.extend({ +App.views.MoipForm.addChild('PaymentChoice', { el: '.list_payment', events: { @@ -12,7 +12,7 @@ CATARSE.PaymentChoice = Backbone.View.extend({ }); }, - initialize: function(){ + activate: function(){ this.$('input#payment_type_cards').click(); } }); diff --git a/app/assets/javascripts/catarse_moip/payment_slip.js b/app/assets/javascripts/catarse_moip/payment_slip.js index 9e9d991..2fbb331 100644 --- a/app/assets/javascripts/catarse_moip/payment_slip.js +++ b/app/assets/javascripts/catarse_moip/payment_slip.js @@ -1,4 +1,4 @@ -CATARSE.PaymentSlip = CATARSE.UserDocument.extend({ +App.views.MoipForm.addChild('PaymentSlip', _.extend({ el: '#payment_type_boleto_section', events: { @@ -13,8 +13,8 @@ CATARSE.PaymentSlip = CATARSE.UserDocument.extend({ $('input#build_boleto').attr('disabled', !$documentField.hasClass('ok')); }, - initialize: function(options){ - this.moipForm = options.moipForm; + activate: function(options){ + this.moipForm = this.parent; this.$('input#user_document_payment_slip').mask("999.999.999-99"); }, @@ -31,19 +31,5 @@ CATARSE.PaymentSlip = CATARSE.UserDocument.extend({ } MoipWidget(settings); }); - }, - - onContentClick: function(e){ - window.setTimeout(function(){ - location.href="/thank_you"; - var thank_you = $('#project_review').data('thank-you-path'); - if(thank_you){ - location.href = thank_you; - } - else { - location.href = '/'; - } - }, 1000); } -}); - +}, App.views.MoipForm.UserDocument)); diff --git a/app/assets/javascripts/catarse_moip/user_document.js b/app/assets/javascripts/catarse_moip/user_document.js index 5d51c85..d9cf2a9 100644 --- a/app/assets/javascripts/catarse_moip/user_document.js +++ b/app/assets/javascripts/catarse_moip/user_document.js @@ -1,4 +1,10 @@ -CATARSE.UserDocument = Backbone.View.extend({ +App.views.MoipForm.UserDocument = { + onContentClick: function(e){ + window.setTimeout(function(){ + app.moipForm.checkoutSuccessful({'StatusPagamento': 'Success'}); + }, 2000); + }, + onUserDocumentKeyup: function(e){ var $documentField = $(e.currentTarget); @@ -17,8 +23,10 @@ CATARSE.UserDocument = Backbone.View.extend({ if(resultCpf || resultCnpj) { $documentField.addClass('ok').removeClass('error'); - $.post('/projects/' + this.moipForm.projectId + '/backers/' + this.moipForm.backerId + '/update_info', { - backer: { payer_document: documentNumber } + $.ajax({ + url: '/projects/' + this.moipForm.projectId + '/contributions/' + this.moipForm.contributionId, + type: 'PUT', + data: { contribution: { payer_document: documentNumber } } }); } else { @@ -100,6 +108,6 @@ CATARSE.UserDocument = Backbone.View.extend({ else return false; } -}); +}; diff --git a/app/controllers/catarse_moip/moip_controller.rb b/app/controllers/catarse_moip/moip_controller.rb new file mode 100644 index 0000000..6aa2568 --- /dev/null +++ b/app/controllers/catarse_moip/moip_controller.rb @@ -0,0 +1,156 @@ +require 'enumerate_it' +require 'moip_transparente' + +module CatarseMoip + class MoipController < ApplicationController + attr_accessor :contribution + + class TransactionStatus < ::EnumerateIt::Base + associate_values( + :authorized => 1, + :started => 2, + :printed_boleto => 3, + :finished => 4, + :canceled => 5, + :process => 6, + :written_back => 7, + :refunded => 9 + ) + end + + skip_before_filter :force_http + layout :false + + def create_notification + @contribution = PaymentEngines.find_payment key: params[:id_transacao] + process_moip_message if @contribution.payment_method == 'MoIP' || @contribution.payment_method.nil? + return render :nothing => true, :status => 200 + rescue Exception => e + return render :text => "#{e.inspect}: #{e.message} recebemos: #{params}", :status => 422 + end + + def js + tries = 0 + begin + @moip = ::MoipTransparente::Checkout.new + render :text => open(@moip.get_javascript_url).set_encoding('ISO-8859-1').read.encode('utf-8') + rescue Exception => e + tries += 1 + retry unless tries > 3 + raise e + end + end + + def review + @moip = ::MoipTransparente::Checkout.new + end + + def moip_response + @contribution = PaymentEngines.find_payment id: params[:id], user_id: current_user.id + first_update_contribution unless params[:response]['StatusPagamento'] == 'Falha' + render nothing: true, status: 200 + end + + def get_moip_token + @contribution = PaymentEngines.find_payment id: params[:id], user_id: current_user.id + + ::MoipTransparente::Config.test = (PaymentEngines.configuration[:moip_test] == 'true') + ::MoipTransparente::Config.access_token = PaymentEngines.configuration[:moip_token] + ::MoipTransparente::Config.access_key = PaymentEngines.configuration[:moip_key] + + @moip = ::MoipTransparente::Checkout.new + + invoice = { + razao: "Apoio para o projeto '#{contribution.project.name}'", + id: contribution.key, + total: contribution.value.to_s, + acrescimo: '0.00', + desconto: '0.00', + cliente: { + id: contribution.user.id, + nome: contribution.payer_name, + email: contribution.payer_email, + logradouro: "#{contribution.address_street}, #{contribution.address_number}", + complemento: contribution.address_complement, + bairro: contribution.address_neighbourhood, + cidade: contribution.address_city, + uf: contribution.address_state, + cep: contribution.address_zip_code, + telefone: contribution.address_phone_number + } + } + + response = @moip.get_token(invoice) + + session[:thank_you_id] = contribution.project.id + + contribution.update_column :payment_token, response[:token] if response and response[:token] + + render json: { + get_token_response: response, + moip: @moip, + widget_tag: { + tag_id: 'MoipWidget', + token: response[:token], + callback_success: 'checkoutSuccessful', + callback_error: 'checkoutFailure' + } + } + end + + def first_update_contribution + response = ::MoIP.query(contribution.payment_token) + if response && response["Autorizacao"] + params = response["Autorizacao"]["Pagamento"] + params = params.first unless params.respond_to?(:key) + + contribution.with_lock do + if params["Status"] == "Autorizado" + contribution.confirm! + elsif contribution.pending? + contribution.waiting! + end + + contribution.update_attributes({ + :payment_id => params["CodigoMoIP"], + :payment_choice => params["FormaPagamento"], + :payment_method => 'MoIP', + :payment_service_fee => params["TaxaMoIP"] + }) if params + end + end + end + + def process_moip_message + contribution.with_lock do + first_update_contribution if contribution.payment_method.nil? + payment_notification = PaymentEngines.create_payment_notification contribution_id: contribution.id, extra_data: JSON.parse(params.to_json.force_encoding('iso-8859-1').encode('utf-8')) + payment_id = (contribution.payment_id.gsub(".", "").to_i rescue 0) + + if payment_id <= params[:cod_moip].to_i + contribution.update_attributes payment_id: params[:cod_moip] + + if (params[:valor].to_i/100.0) < contribution.value && params[:valor] + return contribution.invalid! unless contribution.invalid_payment? + end + + case params[:status_pagamento].to_i + when TransactionStatus::PROCESS + payment_notification.deliver_process_notification + when TransactionStatus::AUTHORIZED + contribution.confirm! unless contribution.confirmed? + when TransactionStatus::WRITTEN_BACK, TransactionStatus::REFUNDED + contribution.refund! unless contribution.refunded? + when TransactionStatus::CANCELED + unless contribution.canceled? + contribution.cancel! + if contribution.payment_choice.downcase == 'boletobancario' + payment_notification.deliver_slip_canceled_notification + end + end + end + end + end + end + end +end diff --git a/app/controllers/catarse_moip/payment/moip_controller.rb b/app/controllers/catarse_moip/payment/moip_controller.rb deleted file mode 100644 index 2735819..0000000 --- a/app/controllers/catarse_moip/payment/moip_controller.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'moip_transparente' -module CatarseMoip::Payment - class MoipController < ApplicationController - skip_before_filter :force_http - layout :false - - def js - @moip = ::MoipTransparente::Checkout.new - render :text => open(@moip.get_javascript_url).set_encoding('ISO-8859-1').read.encode('utf-8') - end - - def review - @moip = ::MoipTransparente::Checkout.new - end - - def moip_response - @backer = current_user.backs.find params[:id] - - @backer.payment_notifications.create(extra_data: params[:response]) - - if not @backer.confirmed and params[:response]['Status'] == 'Autorizado' - @backer.confirm! - end - - unless params[:response]['StatusPagamento'] == 'Falha' - @backer.update_attributes({ - payment_id: params[:response]['CodigoMoIP'], - payment_service_fee: params[:response]['TaxaMoIP'].to_f - }) - end - - render nothing: true, status: 200 - end - - def get_moip_token - @backer = current_user.backs.not_confirmed.find params[:id] - - ::MoipTransparente::Config.test = (::Configuration[:moip_test] == 'true') - ::MoipTransparente::Config.access_token = ::Configuration[:moip_token] - ::MoipTransparente::Config.access_key = ::Configuration[:moip_key] - - @moip = ::MoipTransparente::Checkout.new - - invoice = { - razao: "Apoio para o projeto '#{@backer.project.name}'", - id: @backer.key, - total: @backer.value.to_s, - acrescimo: '0.00', - desconto: '0.00', - cliente: { - id: @backer.user.id, - nome: @backer.payer_name, - email: @backer.payer_email, - logradouro: "#{@backer.address_street}, #{@backer.address_number}", - complemento: @backer.address_complement, - bairro: @backer.address_neighbourhood, - cidade: @backer.address_city, - uf: @backer.address_state, - cep: @backer.address_zip_code, - telefone: @backer.address_phone_number - } - } - - response = @moip.get_token(invoice) - - session[:thank_you_id] = @backer.project.id - - if response and response[:token] - @backer.update_column :payment_token, response[:token] - end - - render json: { get_token_response: response, moip: @moip, widget_tag: @moip.widget_tag('checkoutSuccessful', 'checkoutFailure'), javascript_tag: @moip.javascript_tag } - end - end -end diff --git a/app/controllers/catarse_moip/payment/notifications_controller.rb b/app/controllers/catarse_moip/payment/notifications_controller.rb deleted file mode 100644 index 0c4e260..0000000 --- a/app/controllers/catarse_moip/payment/notifications_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'catarse_moip/processors/moip' - -module CatarseMoip::Payment - class NotificationsController < ApplicationController - skip_before_filter :force_http - def create - @backer = Backer.find_by_key! params[:id_transacao] - @processor = CatarseMoip::Processors::Moip.new @backer - @processor.process!(params) - return render :nothing => true, :status => 200 - rescue Exception => e - ::Airbrake.notify({ :error_class => "MoIP notification", :error_message => "MoIP notification: #{e.inspect}", :parameters => params}) rescue nil - return render :text => "#{e.inspect}: #{e.message} recebemos: #{params}", :status => 422 - end - - end -end - diff --git a/app/views/catarse_moip/payment/moip/review.html.slim b/app/views/catarse_moip/moip/review.html.slim similarity index 56% rename from app/views/catarse_moip/payment/moip/review.html.slim rename to app/views/catarse_moip/moip/review.html.slim index ea28d62..b234dac 100644 --- a/app/views/catarse_moip/payment/moip/review.html.slim +++ b/app/views/catarse_moip/moip/review.html.slim @@ -12,11 +12,12 @@ = radio_button_tag 'payment_type', "boleto" = label_tag :payment_type_boleto, 'Boleto', :class => "boleto" - = radio_button_tag 'payment_type', "account" - = label_tag :payment_type_account, 'Débito em Conta', :class => "account" + / + = radio_button_tag 'payment_type', "account" + = label_tag :payment_type_account, 'Débito em Conta', :class => "account" #payment_type_cards_section.payment_section - h3= t('projects.backers.review.form.labels.payment_card') + h3= t('projects.contributions.review.form.labels.payment_card') .clearfix @@ -29,7 +30,7 @@ .choose_card .div - span= t('projects.backers.review.form.labels.owner_card') + span= t('projects.contributions.review.form.labels.owner_card') .owner_outside .owner ol.inputs @@ -46,7 +47,7 @@ = label_tag :payment_card_birth, "Data de Nascimento" = text_field_tag :payment_card_birth, nil .div - span= t('projects.backers.review.form.labels.number_card') + span= t('projects.contributions.review.form.labels.number_card') .infocard_outside .infocard ol.inputs @@ -66,40 +67,41 @@ .clearfix .bootstrap-twitter .loader.hide= image_tag('loading.gif') - = submit_tag t('projects.backers.review.form.labels.submit'), :disabled => true, :class => 'btn btn-primary btn-large', :id => "credit_card_submit" + = submit_tag t('projects.contributions.review.form.labels.submit'), :disabled => true, :class => 'btn btn-primary btn-large', :id => "credit_card_submit" #payment_type_boleto_section.hide.payment_section - h3= t('projects.backers.review.form.labels.payment_boleto') + h3= t('projects.contributions.review.form.labels.payment_boleto') .clearfix .bootstrap-twitter style="float: none;" .alert.alert-danger.hide p.error_msg .clearfix .bootstrap-twitter - = label_tag 'user_document_payment_slip', t('projects.backers.review.form.labels.document') + = label_tag 'user_document_payment_slip', t('projects.contributions.review.form.labels.document') = text_field_tag 'user_document_payment_slip', nil, { autocomplete: 'off' } .loader.hide= image_tag('loading.gif') - = submit_tag t('projects.backers.review.form.labels.build_boleto'), :class => 'btn btn-primary btn-large', :id => "build_boleto", :disabled => true + = submit_tag t('projects.contributions.review.form.labels.build_boleto'), :class => 'btn btn-primary btn-large', :id => "build_boleto", :disabled => true .clearfix - p.subtitle.hide= t('projects.backers.review.form.labels.payment_boleto_subtitle') + p.subtitle.hide= t('projects.contributions.review.form.labels.payment_boleto_subtitle') .link_content - #payment_type_account_section.hide.payment_section - h3= t('projects.backers.review.form.labels.payment_account') - .clearfix - .bootstrap-twitter style="float: none;" - .alert.alert-danger.hide - p.error_msg - .clearfix - .bootstrap-twitter - = label_tag 'user_document_account', t('projects.backers.review.form.labels.document') - = text_field_tag 'user_document_account', nil, { autocomplete: 'off' } - = label_tag :account, t('projects.backers.review.form.labels.select_account') - = select_tag :account, options_for_select([['Banco do Brasil', 'BancoDoBrasil'], ['Bradesco'], ['Banrisul'], ['Itaú', 'Itau'] ]), :include_blank => true - .loader.hide= image_tag('loading.gif') - = submit_tag t('projects.backers.review.form.labels.submit'), :class => 'btn btn-primary btn-large', :id => "build_account_link", :disabled => true - p.subtitle.hide= t('projects.backers.review.form.labels.select_account') - .link_content + / + #payment_type_account_section.hide.payment_section + h3= t('projects.contributions.review.form.labels.payment_account') + .clearfix + .bootstrap-twitter style="float: none;" + .alert.alert-danger.hide + p.error_msg + .clearfix + .bootstrap-twitter + = label_tag 'user_document_account', t('projects.contributions.review.form.labels.document') + = text_field_tag 'user_document_account', nil, { autocomplete: 'off' } + = label_tag :account, t('projects.contributions.review.form.labels.select_account') + = select_tag :account, options_for_select([['Banco do Brasil', 'BancoDoBrasil'], ['Bradesco'], ['Banrisul'], ['Itaú', 'Itau'] ]), :include_blank => true + .loader.hide= image_tag('loading.gif') + = submit_tag t('projects.contributions.review.form.labels.submit'), :class => 'btn btn-primary btn-large', :id => "build_account_link", :disabled => true + p.subtitle.hide= t('projects.contributions.review.form.labels.select_account') + .link_content -== javascript_include_tag js_payment_moip_index_path +== javascript_include_tag js_moip_index_path diff --git a/catarse_moip.gemspec b/catarse_moip.gemspec index 9ee233c..dfb8e7c 100644 --- a/catarse_moip.gemspec +++ b/catarse_moip.gemspec @@ -8,19 +8,20 @@ require "catarse_moip/version" Gem::Specification.new do |s| s.name = "catarse_moip" s.version = CatarseMoip::VERSION - s.authors = ["Antônio Roberto Silva"] - s.email = ["forevertonny@gmail.com"] - s.homepage = "http://github.com/devton/catarse_moip" + s.authors = ["Antônio Roberto Silva", "Diogo Biazus", "Josemar Davi Luedke"] + s.email = ["forevertonny@gmail.com", "diogob@gmail.com", "josemarluedke@gmail.com"] + s.homepage = "http://github.com/catarse/catarse_moip" s.summary = "MoIP integration with Catarse" s.description = "MoIP integration with Catarse crowdfunding platform" s.files = `git ls-files`.split($\) s.test_files = s.files.grep(%r{^(test|spec|features)/}) - s.add_dependency "rails", "~> 3.2.6" - s.add_dependency('libxml-ruby', '~> 2.3.3') + s.add_dependency "rails", "~> 4.0" + s.add_dependency('libxml-ruby', '~> 2.6.0') + s.add_dependency "enumerate_it" - s.add_development_dependency "rspec-rails" + s.add_development_dependency "rspec-rails", "~> 2.14.0" s.add_development_dependency "factory_girl_rails" s.add_development_dependency "database_cleaner" end diff --git a/config/initializers/moip.rb b/config/initializers/moip.rb index cdd1c26..775e968 100644 --- a/config/initializers/moip.rb +++ b/config/initializers/moip.rb @@ -1,8 +1,5 @@ ::MoIP.setup do |config| - if ::Configuration[:moip_uri] - config.uri = ::Configuration[:moip_uri] - end - - config.token = ::Configuration[:moip_token] or '' - config.key = ::Configuration[:moip_key] or '' + config.uri = (PaymentEngines.configuration[:moip_uri] rescue nil) || '' + config.token = (PaymentEngines.configuration[:moip_token] rescue nil) || '' + config.key = (PaymentEngines.configuration[:moip_key] rescue nil) || '' end diff --git a/config/initializers/register.rb b/config/initializers/register.rb index e70657e..5bbfb1a 100644 --- a/config/initializers/register.rb +++ b/config/initializers/register.rb @@ -1 +1,5 @@ -PaymentEngines.register({name: 'moip', review_path: ->(backer){ CatarseMoip::Engine.routes.url_helpers.review_payment_moip_path(backer) }, locale: 'pt'}) +begin + PaymentEngines.register(CatarseMoip::PaymentEngine.new) +rescue Exception => e + puts "Error while registering payment engine: #{e}" +end diff --git a/config/locales/en.yml b/config/locales/en.yml index 390f2e1..816ffe3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,6 @@ en: projects: - backers: + contributions: review: moip: 'Payments from Brazil' checkout: diff --git a/config/locales/pt.yml b/config/locales/pt.yml index a798711..18e090f 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -1,6 +1,6 @@ pt: projects: - backers: + contributions: review: moip: 'Pagamento nacional' form: diff --git a/config/routes.rb b/config/routes.rb index 4211b2f..3c012dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,15 +1,13 @@ CatarseMoip::Engine.routes.draw do - namespace :payment do - resources :moip, only: [] do - collection do - post 'notifications' => "notifications#create" - get 'js' - end - member do - match :moip_response - match :review - match :get_moip_token - end + resources :moip, only: [], path: 'payment/moip' do + collection do + post 'notifications' => "moip#create_notification" + get 'js' + end + member do + post :moip_response + get :review + post :get_moip_token end end end diff --git a/lib/catarse_moip.rb b/lib/catarse_moip.rb index 9a9aed6..717fd3f 100644 --- a/lib/catarse_moip.rb +++ b/lib/catarse_moip.rb @@ -1,6 +1,5 @@ require "catarse_moip/engine" -require "catarse_moip/checkout/config" -require "catarse_moip/checkout/checkout" +require "catarse_moip/payment_engine" #require "moip" module CatarseMoip diff --git a/lib/catarse_moip/checkout/checkout.rb b/lib/catarse_moip/checkout/checkout.rb deleted file mode 100644 index 6a6b79e..0000000 --- a/lib/catarse_moip/checkout/checkout.rb +++ /dev/null @@ -1,220 +0,0 @@ -require 'net/https' -require 'uri' -require 'xml' -require 'base64' - -module CatarseMoip - module Checkout - class Checkout - - def javascript_tag - "" - end - - def widget_tag(success, fail) - "