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'
TEST_URL =
'https://www.securepay.com.au/test/payment'
LIVE_URL =
'https://www.securepay.com.au/xmlapi/payment'
TEST_PERIODIC_URL =
"https://test.securepay.com.au/xmlapi/periodic"
LIVE_PERIODIC_URL =
"https://api.securepay.com.au/xmlapi/periodic"
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.



56
57
58
59
60
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 56

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

Instance Method Details

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



76
77
78
79
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 76

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



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

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

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



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

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

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



66
67
68
69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 66

def purchase(money, credit_card_or_stored_id, options = {})
  if credit_card_or_stored_id.is_a?(ActiveMerchant::Billing::CreditCard)
    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



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

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

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



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

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)


62
63
64
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 62

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

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



103
104
105
106
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 103

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

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



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

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