funddit_paypal_express 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +13 -0
  5. data/Gemfile +7 -0
  6. data/Gemfile.lock +146 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +64 -0
  9. data/Rakefile +38 -0
  10. data/app/assets/javascripts/catarse_paypal_express.js +6 -0
  11. data/app/assets/javascripts/catarse_paypal_express/paypal_form.js +19 -0
  12. data/app/assets/javascripts/catarse_paypal_express/user_document.js +111 -0
  13. data/app/controllers/.gitkeep +0 -0
  14. data/app/controllers/catarse_paypal_express/paypal_express_controller.rb +113 -0
  15. data/app/views/catarse_paypal_express/paypal_express/review.html.slim +20 -0
  16. data/catarse_paypal_express.gemspec +27 -0
  17. data/config/initializers/active_merchant.rb +2 -0
  18. data/config/initializers/register.rb +5 -0
  19. data/config/locales/en.yml +17 -0
  20. data/config/locales/pt.yml +17 -0
  21. data/config/routes.rb +15 -0
  22. data/lib/catarse_paypal_express.rb +8 -0
  23. data/lib/catarse_paypal_express/contribution_actions.rb +20 -0
  24. data/lib/catarse_paypal_express/engine.rb +6 -0
  25. data/lib/catarse_paypal_express/gateway.rb +36 -0
  26. data/lib/catarse_paypal_express/payment_engine.rb +25 -0
  27. data/lib/catarse_paypal_express/version.rb +3 -0
  28. data/lib/tasks/catarse_paypal_express_tasks.rake +4 -0
  29. data/script/rails +9 -0
  30. data/spec/controllers/catarse_paypal_express/paypal_express_controller_spec.rb +363 -0
  31. data/spec/fixtures/ipn_data.txt +1 -0
  32. data/spec/lib/catarse_paypal_express/contribution_actions_spec.rb +41 -0
  33. data/spec/spec_helper.rb +61 -0
  34. data/spec/support/payment_engines.rb +5 -0
  35. data/test/dummy/README.rdoc +261 -0
  36. data/test/dummy/Rakefile +7 -0
  37. data/test/dummy/app/assets/javascripts/application.js +15 -0
  38. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  39. data/test/dummy/app/controllers/application_controller.rb +3 -0
  40. data/test/dummy/app/helpers/application_helper.rb +2 -0
  41. data/test/dummy/app/mailers/.gitkeep +0 -0
  42. data/test/dummy/app/models/.gitkeep +0 -0
  43. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  44. data/test/dummy/config.ru +4 -0
  45. data/test/dummy/config/application.rb +23 -0
  46. data/test/dummy/config/boot.rb +10 -0
  47. data/test/dummy/config/database.yml +50 -0
  48. data/test/dummy/config/environment.rb +5 -0
  49. data/test/dummy/config/environments/development.rb +29 -0
  50. data/test/dummy/config/environments/production.rb +80 -0
  51. data/test/dummy/config/environments/test.rb +36 -0
  52. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  53. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  54. data/test/dummy/config/initializers/inflections.rb +16 -0
  55. data/test/dummy/config/initializers/mime_types.rb +5 -0
  56. data/test/dummy/config/initializers/secret_token.rb +12 -0
  57. data/test/dummy/config/initializers/session_store.rb +3 -0
  58. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  59. data/test/dummy/config/locales/en.yml +5 -0
  60. data/test/dummy/config/routes.rb +4 -0
  61. data/test/dummy/lib/assets/.gitkeep +0 -0
  62. data/test/dummy/log/.gitkeep +0 -0
  63. data/test/dummy/public/404.html +26 -0
  64. data/test/dummy/public/422.html +26 -0
  65. data/test/dummy/public/500.html +25 -0
  66. data/test/dummy/public/favicon.ico +0 -0
  67. data/test/dummy/script/rails +6 -0
  68. metadata +231 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c88a4c11f65e16b76eb2bd60a21155c1daf4e5c
4
+ data.tar.gz: 6042fdd1f4c3a97d30a01c8a0b3c8436547a0e6c
5
+ SHA512:
6
+ metadata.gz: e27e0d4350d252ecd2453fc0a5567c03ff6985e367ccb2a75eca179a6042588d1d800b33aba4dce954cb0f99f2e4a59744d9cc1209837c5e22d6997073c09aca
7
+ data.tar.gz: d597e1a675d078441d40892215faf4275acd851e449b5f266160fbe83a89da5783804e4a91d1002cd520ceb87e8f132e27c3b570d02738cfd93ed69f48a31076
@@ -0,0 +1,7 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format d
2
+ --color
@@ -0,0 +1,13 @@
1
+ rvm:
2
+ - 2.0.0
3
+
4
+ before_script:
5
+ - "psql -c 'create role catarse SUPERUSER LOGIN;' postgres"
6
+ - "psql -c 'create database catarse_test;' -U catarse postgres"
7
+
8
+ script:
9
+ - "bundle exec rspec spec"
10
+
11
+ branches:
12
+ only:
13
+ - master
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'pg'
6
+ gem 'activemerchant', '>= 1.17.0', require: 'active_merchant'
7
+ gem 'slim-rails'
@@ -0,0 +1,146 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ catarse_paypal_express (3.0.1)
5
+ activemerchant (>= 1.34.0)
6
+ rails (~> 4.0)
7
+ slim-rails
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.1.6)
13
+ actionpack (= 4.1.6)
14
+ actionview (= 4.1.6)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ actionpack (4.1.6)
17
+ actionview (= 4.1.6)
18
+ activesupport (= 4.1.6)
19
+ rack (~> 1.5.2)
20
+ rack-test (~> 0.6.2)
21
+ actionview (4.1.6)
22
+ activesupport (= 4.1.6)
23
+ builder (~> 3.1)
24
+ erubis (~> 2.7.0)
25
+ active_utils (2.2.3)
26
+ activesupport (>= 2.3.11)
27
+ i18n
28
+ activemerchant (1.44.1)
29
+ active_utils (~> 2.2.0)
30
+ activesupport (>= 3.2.14, < 5.0.0)
31
+ builder (>= 2.1.2, < 4.0.0)
32
+ i18n (>= 0.6.9)
33
+ json (~> 1.7)
34
+ nokogiri (~> 1.4)
35
+ offsite_payments (~> 2.0.0)
36
+ activemodel (4.1.6)
37
+ activesupport (= 4.1.6)
38
+ builder (~> 3.1)
39
+ activerecord (4.1.6)
40
+ activemodel (= 4.1.6)
41
+ activesupport (= 4.1.6)
42
+ arel (~> 5.0.0)
43
+ activesupport (4.1.6)
44
+ i18n (~> 0.6, >= 0.6.9)
45
+ json (~> 1.7, >= 1.7.7)
46
+ minitest (~> 5.1)
47
+ thread_safe (~> 0.1)
48
+ tzinfo (~> 1.1)
49
+ arel (5.0.1.20140414130214)
50
+ builder (3.2.2)
51
+ database_cleaner (1.3.0)
52
+ diff-lcs (1.2.5)
53
+ erubis (2.7.0)
54
+ factory_girl (4.4.0)
55
+ activesupport (>= 3.0.0)
56
+ factory_girl_rails (4.4.1)
57
+ factory_girl (~> 4.4.0)
58
+ railties (>= 3.0.0)
59
+ hike (1.2.3)
60
+ i18n (0.6.11)
61
+ json (1.8.1)
62
+ mail (2.6.1)
63
+ mime-types (>= 1.16, < 3)
64
+ mime-types (2.4.3)
65
+ mini_portile (0.6.0)
66
+ minitest (5.4.2)
67
+ money (6.3.0)
68
+ i18n (>= 0.6.4, <= 0.7.0.dev)
69
+ multi_json (1.10.1)
70
+ nokogiri (1.6.3.1)
71
+ mini_portile (= 0.6.0)
72
+ offsite_payments (2.0.1)
73
+ active_utils (~> 2.2.0)
74
+ activesupport (>= 3.2.14, < 5.0.0)
75
+ builder (>= 2.1.2, < 4.0.0)
76
+ i18n (~> 0.5)
77
+ json (~> 1.7)
78
+ money (< 7.0.0)
79
+ nokogiri (~> 1.4)
80
+ pg (0.17.1)
81
+ rack (1.5.2)
82
+ rack-test (0.6.2)
83
+ rack (>= 1.0)
84
+ rails (4.1.6)
85
+ actionmailer (= 4.1.6)
86
+ actionpack (= 4.1.6)
87
+ actionview (= 4.1.6)
88
+ activemodel (= 4.1.6)
89
+ activerecord (= 4.1.6)
90
+ activesupport (= 4.1.6)
91
+ bundler (>= 1.3.0, < 2.0)
92
+ railties (= 4.1.6)
93
+ sprockets-rails (~> 2.0)
94
+ railties (4.1.6)
95
+ actionpack (= 4.1.6)
96
+ activesupport (= 4.1.6)
97
+ rake (>= 0.8.7)
98
+ thor (>= 0.18.1, < 2.0)
99
+ rake (10.3.2)
100
+ rspec-core (2.14.8)
101
+ rspec-expectations (2.14.5)
102
+ diff-lcs (>= 1.1.3, < 2.0)
103
+ rspec-mocks (2.14.6)
104
+ rspec-rails (2.14.2)
105
+ actionpack (>= 3.0)
106
+ activemodel (>= 3.0)
107
+ activesupport (>= 3.0)
108
+ railties (>= 3.0)
109
+ rspec-core (~> 2.14.0)
110
+ rspec-expectations (~> 2.14.0)
111
+ rspec-mocks (~> 2.14.0)
112
+ slim (2.0.3)
113
+ temple (~> 0.6.6)
114
+ tilt (>= 1.3.3, < 2.1)
115
+ slim-rails (2.1.5)
116
+ actionpack (>= 3.0, < 4.2)
117
+ activesupport (>= 3.0, < 4.2)
118
+ railties (>= 3.0, < 4.2)
119
+ slim (~> 2.0)
120
+ sprockets (2.12.2)
121
+ hike (~> 1.2)
122
+ multi_json (~> 1.0)
123
+ rack (~> 1.0)
124
+ tilt (~> 1.1, != 1.3.0)
125
+ sprockets-rails (2.2.0)
126
+ actionpack (>= 3.0)
127
+ activesupport (>= 3.0)
128
+ sprockets (>= 2.8, < 4.0)
129
+ temple (0.6.8)
130
+ thor (0.19.1)
131
+ thread_safe (0.3.4)
132
+ tilt (1.4.1)
133
+ tzinfo (1.2.2)
134
+ thread_safe (~> 0.1)
135
+
136
+ PLATFORMS
137
+ ruby
138
+
139
+ DEPENDENCIES
140
+ activemerchant (>= 1.17.0)
141
+ catarse_paypal_express!
142
+ database_cleaner
143
+ factory_girl_rails
144
+ pg
145
+ rspec-rails (~> 2.14.0)
146
+ slim-rails
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Antônio Roberto Silva
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.
@@ -0,0 +1,64 @@
1
+ # CatarsePaypalExpress [![Code Climate](https://codeclimate.com/github/catarse/catarse_paypal_express.png)](https://codeclimate.com/github/catarse/catarse_paypal_express)
2
+
3
+ Catarse paypal express 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_paypal_express'
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 CatarsePaypalExpress::Engine => "/", :as => "catarse_paypal_express"
20
+
21
+ ## Rails 3.2.x and Rails 4 support
22
+
23
+ If you are using the Rails 3.2.x on Catarse's code, you can use the version `1.0.0`.
24
+
25
+ For Rails 4 support use the `2.0.0` version.
26
+
27
+
28
+ ### Configurations
29
+
30
+ Create this configurations into Catarse database:
31
+
32
+ paypal_username, paypal_password and paypal_signature
33
+
34
+ In Rails console, run this:
35
+
36
+ Configuration.create!(name: "paypal_username", value: "USERNAME")
37
+ Configuration.create!(name: "paypal_password", value: "PASSWORD")
38
+ Configuration.create!(name: "paypal_signature", value: "SIGNATURE")
39
+
40
+ ## Development environment setup
41
+
42
+ Clone the repository:
43
+
44
+ $ git clone git://github.com/devton/catarse_paypal_express.git
45
+
46
+ Add the catarse code into test/dummy:
47
+
48
+ $ git submodule init
49
+ $ git submodule update
50
+
51
+ And then execute:
52
+
53
+ $ bundle
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
62
+
63
+
64
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,38 @@
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 = 'CatarsePaypalExpress'
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
+
28
+ require 'rake/testtask'
29
+
30
+ Rake::TestTask.new(:test) do |t|
31
+ t.libs << 'lib'
32
+ t.libs << 'test'
33
+ t.pattern = 'test/**/*_test.rb'
34
+ t.verbose = false
35
+ end
36
+
37
+
38
+ task :default => :test
@@ -0,0 +1,6 @@
1
+ //= require ./catarse_paypal_express/user_document
2
+ //= require_tree ./catarse_paypal_express
3
+
4
+ $(function(){
5
+ app.createViewGetters();
6
+ });
@@ -0,0 +1,19 @@
1
+ App.addChild('PayPalForm', _.extend({
2
+ el: '#catarse_paypal_express_form',
3
+
4
+ events: {
5
+ 'click input[type=submit]': 'onSubmitToPayPal',
6
+ 'keyup #user_document' : 'onUserDocumentKeyup'
7
+ },
8
+
9
+ activate: function() {
10
+ this.loader = this.$('.loader img');
11
+ this.parent.contributionId = $('input#contribution_id').val();
12
+ this.parent.projectId = $('input#project_id').val();
13
+ },
14
+
15
+ onSubmitToPayPal: function(e) {
16
+ $(e.currentTarget).hide();
17
+ this.loader.show();
18
+ }
19
+ }, window.PayPal.UserDocument));
@@ -0,0 +1,111 @@
1
+ var PayPal = window.PayPal = { UserDocument: {
2
+ onContentClick: function(e){
3
+ window.setTimeout(function(){
4
+ this.moipForm.checkoutSuccessful({'StatusPagamento': 'Success'});
5
+ }, 2000);
6
+ },
7
+
8
+ onUserDocumentKeyup: function(e){
9
+ var $documentField = $(e.currentTarget);
10
+
11
+ var documentNumber = $documentField.val();
12
+ $documentField.prop('maxlength', 18);
13
+ var resultCpf = this.validateCpf(documentNumber);
14
+ var resultCnpj = this.validateCnpj(documentNumber.replace(/[\/.\-\_ ]/g, ''));
15
+ var numberLength = documentNumber.replace(/[.\-\_ ]/g, '').length
16
+ if(numberLength > 10) {
17
+ if($documentField.attr('id') != 'payment_card_cpf'){
18
+ if(numberLength == 11) {$documentField.mask('999.999.999-99?999'); }//CPF
19
+ else if(numberLength == 14 ){$documentField.mask('99.999.999/9999-99');}//CNPJ
20
+ if(numberLength != 14 || numberLength != 11){ $documentField.unmask()}
21
+ }
22
+
23
+ if(resultCpf || resultCnpj) {
24
+ $documentField.addClass('ok').removeClass('error');
25
+
26
+ $.post('/projects/' + this.parent.projectId + '/contributions/' + this.parent.contributionId + '/update_info', {
27
+ contribution: { payer_document: documentNumber }
28
+ });
29
+
30
+ } else {
31
+ $documentField.addClass('error').removeClass('ok');
32
+ }
33
+ }
34
+ else{
35
+ $documentField.addClass('error').removeClass('ok');
36
+ }
37
+
38
+ },
39
+
40
+ validateCpf: function(cpfString){
41
+ var product = 0, i, digit;
42
+ cpfString = cpfString.replace(/[.\-\_ ]/g, '');
43
+ var aux = Math.floor(parseFloat(cpfString) / 100);
44
+ var cpf = aux * 100;
45
+ var quotient;
46
+
47
+ for(i=0; i<=8; i++){
48
+ product += (aux % 10) * (i+2);
49
+ aux = Math.floor(aux / 10);
50
+ }
51
+ digit = product % 11 < 2 ? 0 : 11 - (product % 11);
52
+ cpf += (digit * 10);
53
+ product = 0;
54
+ aux = Math.floor(cpf / 10);
55
+ for(i=0; i<=9; i++){
56
+ product += (aux % 10) * (i+2);
57
+ aux = Math.floor(aux / 10);
58
+ }
59
+ digit = product % 11 < 2 ? 0 : 11 - (product % 11);
60
+ cpf += digit;
61
+ return parseFloat(cpfString) === cpf;
62
+ },
63
+
64
+ validateCnpj: function(cnpj) {
65
+ var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
66
+ digitos_iguais = 1;
67
+ if (cnpj.length < 14 && cnpj.length < 15)
68
+ return false;
69
+ for (i = 0; i < cnpj.length - 1; i++)
70
+ if (cnpj.charAt(i) != cnpj.charAt(i + 1))
71
+ {
72
+ digitos_iguais = 0;
73
+ break;
74
+ }
75
+ if (!digitos_iguais)
76
+ {
77
+ tamanho = cnpj.length - 2
78
+ numeros = cnpj.substring(0,tamanho);
79
+ digitos = cnpj.substring(tamanho);
80
+ soma = 0;
81
+ pos = tamanho - 7;
82
+ for (i = tamanho; i >= 1; i--)
83
+ {
84
+ soma += numeros.charAt(tamanho - i) * pos--;
85
+ if (pos < 2)
86
+ pos = 9;
87
+ }
88
+ resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
89
+ if (resultado != digitos.charAt(0))
90
+ return false;
91
+ tamanho = tamanho + 1;
92
+ numeros = cnpj.substring(0,tamanho);
93
+ soma = 0;
94
+ pos = tamanho - 7;
95
+ for (i = tamanho; i >= 1; i--)
96
+ {
97
+ soma += numeros.charAt(tamanho - i) * pos--;
98
+ if (pos < 2)
99
+ pos = 9;
100
+ }
101
+ resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
102
+ if (resultado != digitos.charAt(1))
103
+ return false;
104
+ return true;
105
+ }
106
+ else
107
+ return false;
108
+ }
109
+ }};
110
+
111
+