summaryrefslogtreecommitdiff
path: root/billing/lib/braintree_test_app.rb
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-05-16 08:42:36 +0200
committerAzul <azul@leap.se>2014-05-16 08:42:36 +0200
commit8fbbb8717f0578536b97c2dc0883c632f120e976 (patch)
tree17aeb2b48ada703ac916a9a65fbf3c75a5dadb86 /billing/lib/braintree_test_app.rb
parent81555ec6244ed76f92e3629880f68104b8705817 (diff)
parenta4f7a410c536d88c91c834cab6ee950c71005ddd (diff)
Merge remote-tracking branch 'origin/develop'
Conflicts: app/assets/javascripts/srp test/nagios/soledad_sync.py test/nagios/webapp_login.py
Diffstat (limited to 'billing/lib/braintree_test_app.rb')
-rw-r--r--billing/lib/braintree_test_app.rb36
1 files changed, 0 insertions, 36 deletions
diff --git a/billing/lib/braintree_test_app.rb b/billing/lib/braintree_test_app.rb
deleted file mode 100644
index 41c327d..0000000
--- a/billing/lib/braintree_test_app.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# RackTest assumes all requests to be local.
-# Braintree requests need to go out to a different server though.
-# So we use a middleware to catch these and send them out again.
-
-class BraintreeTestApp
- def initialize(app)
- @app = app
- end
-
- def call(env)
- @env = env
- config = Braintree::Configuration.instantiate
- if request.path =~ /\/merchants\/#{config.merchant_id}\/transparent_redirect_requests$/
- #proxy post to braintree
- uri = URI.parse(config.protocol + "://" + config.server + ":" +
- config.port.to_s + request.path)
- http = Net::HTTP.new(uri.host, uri.port)
- res = http.post(uri.path, request.body.read)
-
- if res.code == "303"
- header_hash = res.header.to_hash
- header_hash["location"].first.gsub!("http://localhost:3000/", "http://www.example.com/")
- [303, {"location" => header_hash["location"].first}, ""]
- else
- raise "unexpected response from Braintree: expected a 303"
- end
- else
- @app.call(env)
- end
- end
-
- def request
- @request = Rack::Request.new(@env)
- end
-end
-