Guest User

Untitled

a guest
Apr 18th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. require 'ruby-paypal'
  2.  
  3. username = 'logylaps_api1.gmail.com'
  4. password = 'ZEB8HQ7864F7U8NP'
  5. signature = 'A-e5.pfq.2r5Nckl4TECzF.sZDPMAMD7v48g2MpjJDf56CFbCxQD51nbL'
  6. paypal = Paypal.new username, password, signature, :production
  7.  
  8. # silence annoying output
  9. class CaptureOutput < IO
  10. def initialize
  11. super(2)
  12. end
  13. def write(text)
  14. # send text to logfile
  15. end
  16. end
  17. def silence
  18. raise unless block_given?
  19. dout, serr, sout = $defout, $stderr, $stdout
  20. buf = CaptureOutput.new
  21. begin
  22. $defout = buf
  23. $stderr = buf
  24. $stdout = buf
  25. yield
  26. ensure
  27. $defout, $stderr, $stdout = dout, serr, sout
  28. end
  29. end
  30.  
  31. silence do
  32. paypal = paypal.make_nvp_call 'METHOD' => 'GetBalance'
  33. end
  34.  
  35. if paypal.ack == 'Success'
  36. puts paypal['L_AMT0']
  37. end
Add Comment
Please, Sign In to add comment