lib/active_merchant/billing/gateways/nab_transact.rb in activemerchant-1.43.3 vs lib/active_merchant/billing/gateways/nab_transact.rb in activemerchant-1.44.0

- old
+ new

@@ -14,32 +14,25 @@ self.live_url = 'https://transact.nab.com.au/live/xmlapi/payment' self.test_periodic_url = 'https://transact.nab.com.au/xmlapidemo/periodic' self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic' self.supported_countries = ['AU'] - - # The card types supported by the payment gateway - # Note that support for Diners, Amex, and JCB require extra - # steps in setting up your account, as detailed in the NAB Transact API self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb] self.homepage_url = 'http://transact.nab.com.au' self.display_name = 'NAB Transact' - - cattr_accessor :request_timeout - self.request_timeout = 60 - self.money_format = :cents self.default_currency = 'AUD' #Transactions currently accepted by NAB Transact XML API TRANSACTIONS = { - :purchase => 0, #Standard Payment - :refund => 4, #Refund - :void => 6, #Client Reversal (Void) - :authorization => 10, #Preauthorise - :capture => 11 #Preauthorise Complete (Advice) + :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, :editcrn => 5, @@ -64,10 +57,14 @@ options[:billing_id] = credit_card_or_stored_id.to_s commit_periodic build_periodic_item(:trigger, money, nil, options) end end + def credit(money, credit_card, options = {}) + commit :unmatched_refund, build_purchase_request(money, credit_card, options) + end + def refund(money, authorization, options = {}) commit :refund, build_reference_request(money, authorization, options) end def authorize(money, credit_card, options = {}) @@ -138,11 +135,11 @@ def build_request(action, body) xml = Builder::XmlMarkup.new xml.instruct! xml.tag! 'NABTransactMessage' do xml.tag! 'MessageInfo' do - xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30) + xml.tag! 'messageID', SecureRandom.hex(15) xml.tag! 'messageTimestamp', generate_timestamp xml.tag! 'timeoutValue', request_timeout xml.tag! 'apiVersion', API_VERSION end @@ -189,11 +186,11 @@ def build_periodic_request(body) xml = Builder::XmlMarkup.new xml.instruct! xml.tag! 'NABTransactMessage' do xml.tag! 'MessageInfo' do - xml.tag! 'messageID', ActiveMerchant::Utils.generate_unique_id.slice(0, 30) + xml.tag! 'messageID', SecureRandom.hex(15) xml.tag! 'messageTimestamp', generate_timestamp xml.tag! 'timeoutValue', request_timeout xml.tag! 'apiVersion', PERIODIC_API_VERSION end @@ -270,9 +267,13 @@ # YYYYDDMMHHNNSSKKK000sOOO def generate_timestamp time = Time.now.utc time.strftime("%Y%d%m%H%M%S#{time.usec}+000") + end + + def request_timeout + @options[:request_timeout] || 60 end end end end