Class: ActiveMerchant::Billing::EwayManagedGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/eway_managed.rb

Defined Under Namespace

Classes: EwayResponse

Constant Summary collapse

TEST_URL =
'https://www.eway.com.au/gateway/ManagedPaymentService/test/managedCreditCardPayment.asmx'
LIVE_URL =
'https://www.eway.com.au/gateway/ManagedPaymentService/managedCreditCardPayment.asmx'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?

Methods included from Utils

#deprecated, generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ EwayManagedGateway

Returns a new instance of EwayManagedGateway.



24
25
26
27
28
29
30
31
32
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 24

def initialize(options = {})
  requires!(options, :login, :username, :password)
  @options = options

  # eWay returns 500 code for faults, which AM snaffles.
  # So, we tell it to allow them.
  @options[:ignore_http_status]=true
  super
end

Instance Method Details

#purchase(money, billing_id, options = {}) ⇒ Object

process payment for given amount from stored CC “ManagedCustomerID = billing_id”



72
73
74
75
76
77
78
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 72

def purchase(money, billing_id, options={})        
  post = {}  
  post[:managedCustomerID] = billing_id.to_s
  post[:amount]=money
       
  commit("ProcessPayment", post)
end

#store(creditcard, options = {}) ⇒ Object

add a new customer CC to your eway account and return unique ManagedCustomerID supports storing details required by eway see “add_creditcard” and “add_address”



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 36

def store(creditcard, options = {})
  post = {}
  
  # Handle our required fields
  requires!(options, :billing_address)

  # Handle eWay specific required fields.
  billing_address = options[:billing_address]
  eway_requires!(billing_address)
  
  add_creditcard(post, creditcard)
  add_address(post, billing_address)
  add_misc_fields(post, billing_address)
       
  commit("CreateCustomer", post)
end

#test?Boolean

TODO: eWay API also provides QueryCustomer TODO: eWay API also provides QueryPayment

Returns:

  • (Boolean)


83
84
85
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 83

def test?
  @options[:test] || Base.gateway_mode == :test
end

#update(billing_id, creditcard, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 53

def update(billing_id, creditcard, options={})
  post = {}
  
  # Handle our required fields
  requires!(options, :billing_address)

  # Handle eWay specific required fields.
  billing_address = options[:billing_address]
  eway_requires!(billing_address)
  
  post[:managedCustomerID]=billing_id
  add_creditcard(post, creditcard)
  add_address(post, billing_address)
  add_misc_fields(post, billing_address)
       
  commit("UpdateCustomer", post)
end