Class: ActiveMerchant::Billing::UsaEpaySoapGateway
- Defined in:
- lib/active_merchant/billing/gateways/usa_epay_soap.rb
Constant Summary
Constants inherited from Gateway
Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ UsaEpaySoapGateway
constructor
A new instance of UsaEpaySoapGateway.
- #purchase(money, customer_number, options = {}) ⇒ Object
- #store(creditcard, options = {}) ⇒ Object
- #unstore(customer_number, options = {}) ⇒ Object
- #update(customer_number, creditcard, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ UsaEpaySoapGateway
Returns a new instance of UsaEpaySoapGateway.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/active_merchant/billing/gateways/usa_epay_soap.rb', line 12 def initialize( = {}) requires!(, :login) requires!(, :password) @options = PaySimple.key = [:login] PaySimple.pin = [:password] super end |
Instance Method Details
#purchase(money, customer_number, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_merchant/billing/gateways/usa_epay_soap.rb', line 56 def purchase(money, customer_number, = {}) success = false begin @paysimple_response = PaySimple::Subscription.charge(customer_number, :Amount => sprintf("%.2f", money.to_f/100)) if @paysimple_response["Result"] == "Approved" success = true end rescue Exception => @error puts "An error occurred: #{@error.}" end parse_paysimple_response(success, @paysimple_response) end |
#store(creditcard, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/active_merchant/billing/gateways/usa_epay_soap.rb', line 23 def store(creditcard, = {}) @error = nil begin @paysimple_response = PaySimple::Subscription.create( :CustomerID => "#{Time.now.to_i}#{rand(999999)}", :BillingAddress => { :FirstName => creditcard.first_name, :LastName => creditcard.last_name }, :CreditCardData => { :CardNumber => creditcard.number, :CardExpiration => expdate(creditcard) }, :Schedule => :monthly, :Next => "2008-09-05", # in the past, paysimple seems to need this :Enabled => false ) rescue Exception => @error puts "An error occurred: #{@error.}" end success = @error ? false : true = @paysimple_response if @error = @error end USAEpaySoapResponse.new(success == true, , {:token => @paysimple_response}) end |
#unstore(customer_number, options = {}) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/active_merchant/billing/gateways/usa_epay_soap.rb', line 73 def unstore(customer_number, ={}) @error = nil begin @paysimple_response = PaySimple::Subscription.delete(customer_number) puts "Subscription removed from active use." rescue Exception => @error puts "An error occurred: #{@error.}" end success = @error ? false : true = @paysimple_response if @error = @error end USAEpaySoapResponse.new(success == true, , {:token => @paysimple_response}) end |
#update(customer_number, creditcard, options = {}) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/active_merchant/billing/gateways/usa_epay_soap.rb', line 93 def update(customer_number, creditcard, = {}) @error = nil begin @paysimple_response = PaySimple::Subscription.update( customer_number, :CreditCardData => { :CardNumber => creditcard.number, :CardExpiration => expdate(creditcard) } ) rescue Exception => @error puts "An error occurred: #{@error.}" end success = @error ? false : true parse_paysimple_response(success, @paysimple_response.to_s) end |