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 =
%w[00 08 11 16 77]

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, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from Versionable

#fetch_version, included

Methods included from CreditCardFormatting

#format, #strftime_yyyymm

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ SecurePayAuGateway

Returns a new instance of SecurePayAuGateway.



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

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

Instance Method Details

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



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

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



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

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

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



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

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

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



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

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



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

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

#request_timeoutObject



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

def request_timeout
  @options[:request_timeout] || 60
end

#scrub(transcript) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/active_merchant/billing/gateways/secure_pay_au.rb', line 111

def scrub(transcript)
  transcript.
    gsub(%r((<merchantID>).+(</merchantID>)), '\1[FILTERED]\2').
    gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
    gsub(%r((<cardNumber>).+(</cardNumber>)), '\1[FILTERED]\2').
    gsub(%r((<cvv>).+(</cvv>)), '\1[FILTERED]\2')
end

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



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

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

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



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

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

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



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

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