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

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, card_brand, #card_brand, #generate_unique_id, inherited, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

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
# 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

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

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

#retrieve(billing_id) ⇒ Object

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

#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”



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

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



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