Created
August 24, 2012 20:24
-
-
Save JKring/3455244 to your computer and use it in GitHub Desktop.
Ruby Net:HTTP Post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rvm use 1.9.2 | |
@api_parameters = {"USER"=>"our username", "PWD"=>"our password", "VERSION"=>"74.0", "SIGNATURE"=>"our sig", "METHOD"=>"MassPay", "RECEIVERTYPE"=>"EmailAddress", "CURRENCYCODE"=>"USD", "EMAILSUBJECT"=>"Scripted: Payment for Test", "L_EMAIL0"=>"kringj@gmail.com", "L_UNIQUEID0"=>"", "L_NOTE0"=>"", "L_AMT0"=>"1.0"} | |
@paypal_url = 'api-3t.paypal.com/nvp' | |
response = Net::HTTPS.post_form(URI("https://#{@paypal_url}"), @api_parameters) | |
response.body => "TIMESTAMP=2012%2d08%2d24T20%3a20%3a42Z&CORRELATIONID=1a3af9521ac71&ACK=Success&VERSION=74%2e0&BUILD=3556406" | |
# rvm use 1.9.3 | |
@api_parameters = {"USER"=>"our username", "PWD"=>"our password", "VERSION"=>"74.0", "SIGNATURE"=>"our sig", "METHOD"=>"MassPay", "RECEIVERTYPE"=>"EmailAddress", "CURRENCYCODE"=>"USD", "EMAILSUBJECT"=>"Scripted: Payment for Test", "L_EMAIL0"=>"kringj@gmail.com", "L_UNIQUEID0"=>"", "L_NOTE0"=>"", "L_AMT0"=>"1.0"} | |
@paypal_url = 'api-3t.paypal.com/nvp' | |
response = Net::HTTPS.post_form(URI("https://#{@paypal_url}"), @api_parameters) | |
response.body => "TIMESTAMP=2012%2d08%2d24T20%3a18%3a12Z&CORRELATIONID=acdc4eab943d3&ACK=Failure&VERSION=74%2e0&BUILD=3556406&L_ERRORCODE0=10004&L_SHORTMESSAGE0=Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e&L_LONGMESSAGE0=The%20number%20of%20input%20records%20is%20less%20than%20or%20equal%20to%20zero&L_SEVERITYCODE0=Error" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment