Guest User

Untitled

a guest
Jan 14th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #! /usr/bin/env ruby
  2. ##
  3. #
  4. require 'date'
  5. require 'rubygems'
  6. require 'faker'
  7. require 'active_merchant'
  8.  
  9. ##
  10. #
  11. instructions = <<-__
  12.  
  13. these instructions need to describe, to a user, how to setup the config
  14. below. they should walk the user through logging into whatever web
  15. console and jumping through whatever hoops the gateway makes you jump
  16. through to get a valid config...
  17.  
  18. __
  19.  
  20. ##
  21. #
  22. gateway_class = ActiveMerchant::Billing::InspireGateway
  23. config = { :login => 'XXX', :password => 'XXX' }
  24.  
  25. #gateway_class = ActiveMerchant::Billing::AuthorizeNetGateway
  26. #config = { :login => 'XXX', :password => 'XXX' }
  27.  
  28. #gateway_class = ActiveMerchant::Billing::SageGateway
  29. #config = { :login => 'XXX', :password => 'XXX' }
  30.  
  31.  
  32. gateway = gateway_class.new(config)
  33.  
  34. p gateway
  35. puts
  36.  
  37. ##
  38. #
  39. credit_card = ActiveMerchant::Billing::CreditCard.new(
  40. :type => 'visa',
  41. :number => '4111111111111111',
  42. :year => 2012,
  43. :month => 13,
  44. :first_name => 'Ara',
  45. :last_name => 'Howard',
  46. :verification_value => '123'
  47. )
  48. p credit_card
  49. p credit_card.valid?
  50. puts
  51.  
  52. ##
  53. #
  54. amount = [1000, rand(10_000)].max
  55. response = gateway.authorize(amount, credit_card, options = {})
  56.  
  57. p response
  58. puts
  59.  
  60. puts(response.success? ? 'SUCCESS' : 'FAILURE')
Add Comment
Please, Sign In to add comment