Class: ActiveMerchant::Billing::SecurePayAuGateway

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

Constant Summary collapse

API_VERSION =
'xml-4.2'
PERIODIC_API_VERSION =
'spxml-3.0'
TRANSACTIONS =

0 Standard Payment 4 Refund 6 Client Reversal (Void) 10 Preauthorise 11 Preauth Complete (Advice)

{
  :purchase => 0,
  :authorization => 10,
  :capture => 11,
  :void => 6,
  :refund => 4
}
PERIODIC_ACTIONS =
{
  :add_triggered    => "add",
  :remove_triggered => "delete",
  :trigger          => "trigger"
}
PERIODIC_TYPES =
{
  :add_triggered    => 4,
  :remove_triggered => nil,
  :trigger          => nil
}
SUCCESS_CODES =
[ '00', '08', '11', '16', '77' ]

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 CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ SecurePayAuGateway

Returns a new instance of SecurePayAuGateway.



59
60
61
62
63
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 59

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

Instance Method Details

#authorize(money, credit_card, options = {}) ⇒ Object



79
80
81
82
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 79

def authorize(money, credit_card, options = {})
  requires!(options, :order_id)
  commit :authorization, build_purchase_request(money, credit_card, options)
end

#capture(money, reference, options = {}) ⇒ Object



84
85
86
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 84

def capture(money, reference, options = {})
  commit :capture, build_reference_request(money, reference)
end

#credit(money, reference, options = {}) ⇒ Object



92
93
94
95
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 92

def credit(money, reference, options = {})
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, reference)
end

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



69
70
71
72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 69

def purchase(money, credit_card_or_stored_id, options = {})
  if credit_card_or_stored_id.respond_to?(:number)
    requires!(options, :order_id)
    commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
  else
    options[:billing_id] = credit_card_or_stored_id.to_s
    commit_periodic(build_periodic_item(:trigger, money, nil, options))
  end
end

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



88
89
90
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 88

def refund(money, reference, options = {})
  commit :refund, build_reference_request(money, reference)
end

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



101
102
103
104
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 101

def store(creditcard, options = {})
  requires!(options, :billing_id, :amount)
  commit_periodic(build_periodic_item(:add_triggered, options[:amount], creditcard, options))
end

#test?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 65

def test?
  @options[:test] || super
end

#unstore(identification, options = {}) ⇒ Object



106
107
108
109
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 106

def unstore(identification, options = {})
  options[:billing_id] = identification
  commit_periodic(build_periodic_item(:remove_triggered, options[:amount], nil, options))
end

#void(reference, options = {}) ⇒ Object



97
98
99
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 97

def void(reference, options = {})
  commit :void, build_reference_request(nil, reference)
end