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

Constant Summary

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?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

- (EwayManagedGateway) initialize(options = {})

Returns a new instance of EwayManagedGateway



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

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

  # 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

- (Object) purchase(money, billing_id, options = {})

Process a payment in the given amount against the stored credit card given by billing_id

Parameters

  • money – The amount to be purchased as an Integer value in cents.

  • billing_id – The eWay provided card/customer token to charge (managedCustomerID)

  • options – A hash of optional parameters.

Options

  • :order_id – The order number, passed to eWay as the “Invoice Reference”

  • :invoice – The invoice number, passed to eWay as the “Invoice Reference” unless :order_id is also given

  • :description – A description of the payment, passed to eWay as the “Invoice Description”



83
84
85
86
87
88
89
90
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 83

def purchase(money, billing_id, options={})
  post = {}
  post[:managedCustomerID] = billing_id.to_s
  post[:amount]=money
  add_invoice(post, options)

  commit("ProcessPayment", post)
end

- (Object) retrieve(billing_id)

Get customer's stored credit card details given by billing_id

Parameters

  • billing_id – The eWay provided card/customer token to charge (managedCustomerID)



97
98
99
100
101
102
# File 'lib/active_merchant/billing/gateways/eway_managed.rb', line 97

def retrieve(billing_id)
  post = {}
  post[:managedCustomerID] = billing_id.to_s

  commit("QueryCustomer", post)
end

- (Object) store(creditcard, options = {})

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”



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

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, options)

  commit("CreateCustomer", post)
end

- (Object) update(billing_id, creditcard, options = {})



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

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, options)

  commit("UpdateCustomer", post)
end