Class: ActiveMerchant::Billing::NabTransactGateway

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

Overview

The National Australia Bank provide a payment gateway that seems to be a rebadged Securepay Australia service, though some differences exist.

Constant Summary collapse

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

Transactions currently accepted by NAB Transact XML API

{
  purchase: 0,           # Standard Payment
  refund: 4,             # Refund
  void: 6,               # Client Reversal (Void)
  unmatched_refund: 666, # Unmatched Refund
  authorization: 10,     # Preauthorise
  capture: 11            # Preauthorise Complete (Advice)
}
PERIODIC_TYPES =
{
  addcrn: 5,
  deletecrn: 5,
  trigger: 8
}
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 CreditCardFormatting

#format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ NabTransactGateway

Returns a new instance of NabTransactGateway.



44
45
46
47
# File 'lib/active_merchant/billing/gateways/nab_transact.rb', line 44

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

Instance Method Details

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



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

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

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



69
70
71
# File 'lib/active_merchant/billing/gateways/nab_transact.rb', line 69

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

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



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

def credit(money, credit_card, options = {})
  commit :unmatched_refund, build_purchase_request(money, credit_card, options)
end

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



49
50
51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/nab_transact.rb', line 49

def purchase(money, credit_card_or_stored_id, options = {})
  if credit_card_or_stored_id.respond_to?(:number)
    commit :purchase, build_purchase_request(money, credit_card_or_stored_id, options)
  else
    commit_periodic(:trigger, build_purchase_using_stored_card_request(money, credit_card_or_stored_id, options))
  end
end

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



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

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

#scrub(transcript) ⇒ Object



85
86
87
88
89
90
91
92
# File 'lib/active_merchant/billing/gateways/nab_transact.rb', line 85

def scrub(transcript)
  return '' if transcript.blank?

  transcript.
    gsub(%r((<cardNumber>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<cvv>)[^<]+(<))i, '\1[FILTERED]\2').
    gsub(%r((<password>)[^<]+(<))i, '\1[FILTERED]\2')
end

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



73
74
75
# File 'lib/active_merchant/billing/gateways/nab_transact.rb', line 73

def store(credit_card, options = {})
  commit_periodic(:addcrn, build_store_request(credit_card, options))
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


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

def supports_scrubbing?
  true
end

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



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

def unstore(identification, options = {})
  commit_periodic(:deletecrn, build_unstore_request(identification, options))
end