Class: ActiveMerchant::Billing::EwayGateway

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

Overview

Public: For more information on the Eway Gateway please visit their Developers Area

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

#initialize(options = {}) ⇒ EwayGateway

Public: Create a new Eway Gateway. options - A hash of options:

:login     - Your Customer ID.
:password  - Your XML Refund Password that you
             specified on the Eway site. (optional)


21
22
23
24
# File 'lib/active_merchant/billing/gateways/eway.rb', line 21

def initialize(options = {})
  requires!(options, :login)
  super
end

Instance Method Details

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



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/active_merchant/billing/gateways/eway.rb', line 26

def purchase(money, creditcard, options = {})
  requires_address!(options)

  post = {}
  add_creditcard(post, creditcard)
  add_address(post, options)
  add_customer_id(post)
  add_invoice_data(post, options)
  add_non_optional_data(post)
  add_amount(post, money)
  post[:CustomerEmail] = options[:email]

  commit(purchase_url(post[:CVN]), money, post)
end

#refund(money, authorization, options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_merchant/billing/gateways/eway.rb', line 41

def refund(money, authorization, options={})
  post = {}

  add_customer_id(post)
  add_amount(post, money)
  add_non_optional_data(post)
  post[:OriginalTrxnNumber] = authorization
  post[:RefundPassword] = @options[:password]
  post[:CardExpiryMonth] = nil
  post[:CardExpiryYear] = nil

  commit(refund_url, money, post)
end