Take the 2008 Git User's Survey and help out! [ hide ]

public
Description: Simple wrapper for the Braintree APIs that uses Camping
Homepage: http://developer.getbraintree.com
Clone URL: git://github.com/braintree/braintree-utili-tool.git
Search Repo:
adding some style and rearranging some content
ch0wda (author)
Tue Apr 08 13:12:59 -0700 2008
commit  14ae5bc13896436ce2e18937db6c35e29ff2d6f3
tree    405a6036659bdd9d986dce6849c127be091b076c
parent  fa4a1a8f02ea0bd3fbd38d6b7a86258eb965c34d
...
1
 
2
3
4
5
 
 
 
...
 
1
2
3
4
 
5
6
7
0
@@ -1,5 +1,7 @@
0
-*Usage:* QuickGet is a simple wrapper around the Direct Post authentication methods of the Payment Processing and SecureVault APIs. It's usage is very similar to typing out a query string in the browser, except you'll receive the response on this page in a table along with the query string, as it was generated.
0
+*Usage:* QuickGet is a simple wrapper around the Direct Post authentication methods of the Payment Processing and SecureVault APIs. It's usage is very similar to typing out a query string in the browser, except you'll receive the response on this page in a table along with the query string, as it was generated.
0
 
0
 Type in your username and password. Type out any @key=value@ pairs for the transaction you are completing. See the "Payment Processing API":http://developer.getbraintree.com/apis/1-payment-processing and the "SecureVault API":http://developer.getbraintree.com/apis/2-secure-vault for a complete list of values.
0
 
0
-A simple example would look like this: @type=sale&ccnumber=4111111111111111&amount=1.00&ccexp=1010@
0
+A simple example would look like this: @type=sale&ccnumber=4111111111111111&amount=1.00&ccexp=1010@.
0
+
0
+Make sure to escape the values, for example: @address1=1600 Pennsylvania Blvd@ should be @address1=1600%20Pennsylvania%20Blvd%@.
...
42
43
44
 
 
45
...
42
43
44
45
46
47
0
@@ -42,4 +42,6 @@ div#content { float: right; width: 595px; padding: 1em; background: #fff;
0
 div.static dt { font-weight: bold; }
0
 div.static dd { margin-bottom: 1em; }
0
 
0
+div.response { background: #ffffcc; padding: .25em 1em 0; margin-bottom: 1em;}
0
+
0
 div#footer { text-align: right; clear: both; margin: 2em 0; padding: 2em 0; }
...
1
2
3
4
 
5
6
7
...
54
55
56
57
58
59
60
 
 
 
61
62
63
64
65
66
 
 
67
68
69
 
 
70
71
72
...
287
288
289
290
291
 
 
292
293
294
...
302
303
304
305
306
307
308
309
310
311
312
 
 
 
 
 
 
 
 
 
 
313
314
315
...
336
337
338
339
340
341
342
343
344
345
346
347
348
 
 
 
 
 
 
 
 
 
 
 
 
 
349
350
351
...
1
2
 
 
3
4
5
6
...
53
54
55
 
 
 
 
56
57
58
59
60
61
62
63
 
64
65
66
67
 
68
69
70
71
72
...
287
288
289
 
 
290
291
292
293
294
...
302
303
304
 
 
 
 
 
 
 
 
305
306
307
308
309
310
311
312
313
314
315
316
317
...
338
339
340
 
 
 
 
 
 
 
 
 
 
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
0
@@ -1,7 +1,6 @@
0
 #!/usr/bin/env ruby
0
 
0
-# $:.unshift File.dirname(__FILE__) + "/../../lib"
0
-%w( rubygems mime/types camping
0
+%w( rubygems mime/types camping cgi
0
     digest/md5 net/https redcloth ).each { |lib| require lib }
0
 
0
 Camping.goes :UtiliTool
0
@@ -54,19 +53,20 @@ module UtiliTool::Models
0
       [self.url_base, self.uri_string].join("?")
0
     end
0
 
0
- def response
0
- self.send_request
0
- end
0
-
0
+ # Sending a request relies on net/https instead of open-uri because
0
+ # it's easier to skip the SSL validity checks. In Ruby 1.9, this
0
+ # won't be necessary.
0
     def send_request
0
       uri = URI.parse self.url
0
       server = Net::HTTP.new uri.host, uri.port
0
       server.use_ssl = uri.scheme == 'https'
0
       server.verify_mode = OpenSSL::SSL::VERIFY_NONE
0
- response = server.get uri.request_uri
0
+ # use POST instead of GET
0
+ response = server.post self.url_base, self.uri_string
0
       return response.body
0
     end
0
-
0
+ alias response send_request
0
+
0
     private
0
     def determine_api_url_base
0
       if api == "query"
0
@@ -287,8 +287,8 @@ module UtiliTool::Views
0
   end
0
 
0
   def _google_analytics
0
- script(:type => "text/javascript") do "
0
- var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
0
+ script(:type => "text/javascript") do
0
+ "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");
0
 document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));"
0
     end
0
   end
0
@@ -302,14 +302,16 @@ document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/
0
     h2 "Braintree MD5 Hash Generator"
0
     div.static do; static_content("hasher"); end
0
     if @hasher
0
- table.response do
0
- tr do
0
- td "The string to hash was:"
0
- td { code @hasher.string_to_hash}
0
- end
0
- tr do
0
- td "The MD5 hash generated was:"
0
- td { code @hasher.hash }
0
+ div.response do
0
+ table.response do
0
+ tr do
0
+ td "The string to hash was:"
0
+ td { code @hasher.string_to_hash}
0
+ end
0
+ tr do
0
+ td "The MD5 hash generated was:"
0
+ td { code @hasher.hash }
0
+ end
0
         end
0
       end
0
     end
0
@@ -336,16 +338,19 @@ document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/
0
     h2 "QuickGet Query"
0
     div.static do; static_content("quick_get"); end
0
     unless @gateway_response.nil?
0
- p { code { word_wrap(@gateway_request.uri_string) }}
0
- table.response(:cellspacing => "0") do
0
- tr.header do
0
- th "Param"
0
- th "Value"
0
- end
0
- @gateway_response.to_hash.each do |key, value|
0
- tr do
0
- td key
0
- td { code value }
0
+ div.response do
0
+ h3 "Gateway Response"
0
+ p { code { word_wrap(@gateway_request.uri_string) }}
0
+ table.response(:cellspacing => "0") do
0
+ tr.header do
0
+ th "Param"
0
+ th "Value"
0
+ end
0
+ @gateway_response.to_hash.each do |key, value|
0
+ tr do
0
+ td key
0
+ td { code value }
0
+ end
0
           end
0
         end
0
       end

Comments

    No one has commented yet.