lib/active_merchant/billing/gateways/nab_transact.rb in activemerchant-1.29.3 vs lib/active_merchant/billing/gateways/nab_transact.rb in activemerchant-1.30.0

- old
+ new

@@ -32,11 +32,11 @@ self.default_currency = 'AUD' #Transactions currently accepted by NAB Transact XML API TRANSACTIONS = { :purchase => 0, #Standard Payment - :credit => 4, #Refund + :refund => 4, #Refund :void => 6, #Client Reversal (Void) :authorization => 10, #Preauthorise :capture => 11 #Preauthorise Complete (Advice) } @@ -64,10 +64,14 @@ options[:billing_id] = credit_card_or_stored_id.to_s commit_periodic build_periodic_item(:trigger, money, nil, options) end end + def refund(money, authorization, options = {}) + commit :refund, build_reference_request(money, authorization) + end + def store(creditcard, options = {}) requires!(options, :billing_id, :amount) commit_periodic(build_periodic_item(:addcrn, options[:amount], creditcard, options)) end @@ -102,14 +106,27 @@ add_metadata(xml, options) xml.target! end + def build_reference_request(money, reference) + xml = Builder::XmlMarkup.new + + transaction_id, order_id, preauth_id, original_amount = reference.split('*') + + xml.tag! 'amount', (money ? amount(money) : original_amount) + xml.tag! 'currency', options[:currency] || currency(money) + xml.tag! 'txnID', transaction_id + xml.tag! 'purchaseOrderNo', order_id + xml.tag! 'preauthID', preauth_id + + xml.target! + end + #Generate payment request XML # - API is set to allow multiple Txn's but currentlu only allows one # - txnSource = 23 - (XML) - def build_request(action, body) xml = Builder::XmlMarkup.new xml.instruct! xml.tag! 'NABTransactMessage' do xml.tag! 'MessageInfo' do @@ -208,10 +225,10 @@ def success?(response) SUCCESS_CODES.include?(response[:response_code]) end def authorization_from(response) - response[:txn_id] + [response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*') end def message_from(response) response[:response_text] || response[:status_description] end