Permalink
Browse files

Merge pull request #79 from noisebridge/patrickod/paypal-notifications

Record Paypal IPN notifications
  • Loading branch information...
patrickod committed Feb 25, 2017
2 parents d8e6f94 + d7fb089 commit 1cad59aacfdf4f00d895db6f1b680f83c8c23be7
Showing with 355 additions and 262 deletions.
  1. +65 −0 .rubocop.yml
  2. +1 −1 .ruby-version
  3. +2 −2 .travis.yml
  4. +2 −1 Gemfile
  5. +19 −36 Gemfile.lock
  6. +0 −77 Guardfile
  7. +21 −0 app/controllers/api/paypal_notifications_controller.rb
  8. +24 −22 app/controllers/api/stripe_events_controller.rb
  9. +0 −1 app/controllers/application_controller.rb
  10. +10 −16 app/controllers/charges_controller.rb
  11. +7 −11 app/controllers/donations_controller.rb
  12. +3 −4 app/helpers/application_helper.rb
  13. +3 −4 app/helpers/donations_helper.rb
  14. +4 −6 app/lib/project.rb
  15. +3 −4 app/lib/suggested_donation_amount.rb
  16. +1 −6 app/mailers/receipt_mailer.rb
  17. +1 −1 app/models/application_record.rb
  18. +4 −6 app/models/charge.rb
  19. +3 −5 app/models/donor.rb
  20. +18 −0 app/models/paypal_notification.rb
  21. +7 −6 app/models/plan.rb
  22. +1 −4 app/models/stripe_event.rb
  23. +0 −1 app/models/subscription.rb
  24. +1 −1 app/views/projects/show.html.erb
  25. +6 −0 circle.yml
  26. +2 −2 config/environments/production.rb
  27. +4 −5 config/initializers/secure_headers.rb
  28. +1 −0 config/routes.rb
  29. +12 −0 db/migrate/20170220233007_create_paypal_notifications.rb
  30. +10 −1 db/schema.rb
  31. +51 −0 spec/controllers/api/paypal_notifications_controller_spec.rb
  32. +3 −3 spec/controllers/api/stripe_events_controller_spec.rb
  33. +14 −14 spec/controllers/charges_controller_spec.rb
  34. +1 −1 spec/factories/donor.rb
  35. +1 −1 spec/factories/stripe_event.rb
  36. +1 −1 spec/models/charge_spec.rb
  37. +9 −9 spec/models/donor_spec.rb
  38. +33 −0 spec/models/paypal_notification_spec.rb
  39. +0 −1 spec/models/plan_spec.rb
  40. +7 −9 spec/models/stripe_event_spec.rb
View
@@ -0,0 +1,65 @@
AllCops:
Exclude:
- "bin/*"
- 'config.ru'
- "config/initializers/*"
- "db/schema.rb"
- "Gemfile"
- "spec/rails_helper.rb"
- "spec/spec_helper.rb"
- "vendor/**/*"
Style/StringLiterals:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Exclude:
- "spec/**/*"
Style/NumericLiterals:
Enabled: false
Style/BlockDelimiters:
Exclude:
- "spec/**/*"
Style/AlignParameters:
Exclude:
- "spec/**/*"
Style/AlignHash:
Exclude:
- "spec/**/*"
Style/ClassAndModuleChildren:
Exclude:
- 'test/test_helper.rb'
Style/Documentation:
Enabled: false
Style/ElseAlignment:
Exclude:
- 'app/controllers/donations_controller.rb'
Style/IndentationWidth:
Exclude:
- 'app/controllers/donations_controller.rb'
Metrics/MethodLength:
Max: 20
Metrics/AbcSize:
Max: 24
Metrics/LineLength:
Max: 127
Metrics/BlockLength:
Exclude:
- "spec/**/*"
Lint/EndAlignment:
Exclude:
- 'app/controllers/donations_controller.rb'
View
@@ -1 +1 @@
2.3.0
2.4.0
View
@@ -22,6 +22,6 @@ before_install:
- mv .env .env.encrypted
# Lint codebase after successful spec run
# after_script:
# - bundle exec rubocop
after_script:
- bundle exec rubocop
View
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
gem 'autoprefixer-rails'
gem 'dotenv-rails'
gem 'httparty'
gem 'jquery-rails'
gem 'pg'
gem 'rails', '~> 5.0.0'
@@ -17,6 +18,7 @@ group :development, :test do
gem 'foreman'
gem 'pry'
gem 'spring'
gem 'rubocop', '~> 0.47.0'
end
group :development do
@@ -26,7 +28,6 @@ end
group :test do
gem 'rails-controller-testing'
gem 'factory_girl_rails'
gem 'guard-rspec', require: false
gem 'rspec-rails', '~> 3.1'
gem 'shoulda-matchers'
end
View
@@ -40,6 +40,7 @@ GEM
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
ast (2.3.0)
autoprefixer-rails (6.7.2)
execjs
binding_of_caller (0.7.2)
@@ -65,40 +66,21 @@ GEM
railties (>= 3.0.0)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.17)
foreman (0.83.0)
thor (~> 0.19.1)
formatador (0.2.5)
globalid (0.3.7)
activesupport (>= 4.1.0)
guard (2.14.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.8.0)
jquery-rails (4.2.2)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.0.3)
nokogiri (>= 1.5.9)
lumberjack (1.0.11)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
@@ -107,16 +89,16 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
nenv (0.3.0)
netrc (0.11.0)
nio4r (1.2.1)
nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
parser (2.4.0.0)
ast (~> 2.2)
pg (0.19.0)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@@ -153,19 +135,13 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.1)
rake (12.0.0)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
redis (3.3.3)
rest-client (2.0.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
@@ -183,7 +159,13 @@ GEM
rspec-mocks (~> 3.5.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
ruby_dep (1.5.0)
rubocop (0.47.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
sass (3.4.23)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
@@ -195,7 +177,6 @@ GEM
useragent
sentry-raven (2.3.0)
faraday (>= 0.7.6, < 1.0)
shellany (0.0.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
sidekiq (4.2.9)
@@ -227,6 +208,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
unicode-display_width (1.1.3)
useragent (0.16.8)
web-console (2.3.0)
activemodel (>= 4.0)
@@ -245,13 +227,14 @@ DEPENDENCIES
dotenv-rails
factory_girl_rails
foreman
guard-rspec
httparty
jquery-rails
pg
pry
rails (~> 5.0.0)
rails-controller-testing
rspec-rails (~> 3.1)
rubocop (~> 0.47.0)
sass-rails (~> 5.0)
secure_headers
sentry-raven
@@ -264,4 +247,4 @@ DEPENDENCIES
web-console (~> 2.0)
BUNDLED WITH
1.12.5
1.14.4
View

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,21 @@
module Api
class PaypalNotificationsController < ApplicationController
skip_before_action :verify_authenticity_token
rescue_from ActiveRecord::RecordNotUnique, with: :duplicate_notification
def create
if PaypalNotification.verify_raw_payload(request.raw_post)
PaypalNotification.create_from_payload(params)
render plain: 'VERIFIED', status: 200
else
render plain: 'UNVERIFIED', status: 400
end
end
private def duplicate_notification
Rails.logger.info("Received duplicate notification: #{params['txn_id']}")
render plain: 'INVALID', status: 400
end
end
end
Oops, something went wrong.

0 comments on commit 1cad59a

Please sign in to comment.