Class Index [+]

Quicksearch

ActiveMerchant::Billing::SecurePayAuGateway

Constants

API_VERSION
TEST_URL
LIVE_URL
TRANSACTIONS

0 Standard Payment 4 Refund 6 Client Reversal (Void) 10 Preauthorise 11 Preauth Complete (Advice)

SUCCESS_CODES

Public Class Methods

new(options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 41
41:       def initialize(options = {})
42:         requires!(options, :login, :password)
43:         @options = options
44:         super
45:       end

Public Instance Methods

authorize(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 56
56:       def authorize(money, credit_card, options = {})
57:         requires!(options, :order_id)
58:         commit :authorization, build_purchase_request(money, credit_card, options)
59:       end
capture(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 61
61:       def capture(money, reference, options = {})
62:         commit :capture, build_reference_request(money, reference)
63:       end
credit(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 69
69:       def credit(money, reference, options = {})
70:         deprecated CREDIT_DEPRECATION_MESSAGE
71:         refund(money, reference)
72:       end
purchase(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 51
51:       def purchase(money, credit_card, options = {})
52:         requires!(options, :order_id)
53:         commit :purchase, build_purchase_request(money, credit_card, options)
54:       end
refund(money, reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 65
65:       def refund(money, reference, options = {})
66:         commit :refund, build_reference_request(money, reference)
67:       end
test?() click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 47
47:       def test?
48:         @options[:test] || super
49:       end
void(reference, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 74
74:       def void(reference, options = {})
75:         commit :void, build_reference_request(nil, reference)
76:       end

Private Instance Methods

authorization_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 153
153:       def authorization_from(response)
154:         [response[:txn_id], response[:purchase_order_no], response[:preauth_id], response[:amount]].join('*')
155:       end
build_purchase_request(money, credit_card, options) click to toggle source
    # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 80
80:       def build_purchase_request(money, credit_card, options)
81:         xml = Builder::XmlMarkup.new
82:         
83:         xml.tag! 'amount', amount(money)
84:         xml.tag! 'currency', options[:currency] || currency(money)              
85:         xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
86:         
87:         xml.tag! 'CreditCardInfo' do
88:           xml.tag! 'cardNumber', credit_card.number
89:           xml.tag! 'expiryDate', expdate(credit_card)
90:           xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
91:         end
92:         
93:         xml.target!
94:       end
build_reference_request(money, reference) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 96
 96:       def build_reference_request(money, reference)
 97:         xml = Builder::XmlMarkup.new
 98:         
 99:         transaction_id, order_id, preauth_id, original_amount = reference.split("*")
100:         xml.tag! 'amount', (money ? amount(money) : original_amount)
101:         xml.tag! 'currency', options[:currency] || currency(money)
102:         xml.tag! 'txnID', transaction_id
103:         xml.tag! 'purchaseOrderNo', order_id
104:         xml.tag! 'preauthID', preauth_id
105:         
106:         xml.target!
107:       end
build_request(action, body) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 109
109:       def build_request(action, body)
110:         xml = Builder::XmlMarkup.new
111:         xml.instruct!
112:         xml.tag! 'SecurePayMessage' do
113:           xml.tag! 'MessageInfo' do
114:             xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30)
115:             xml.tag! 'messageTimestamp', generate_timestamp
116:             xml.tag! 'timeoutValue', request_timeout
117:             xml.tag! 'apiVersion', API_VERSION
118:           end
119:           
120:           xml.tag! 'MerchantInfo' do
121:             xml.tag! 'merchantID', @options[:login]
122:             xml.tag! 'password', @options[:password]
123:           end
124:           
125:           xml.tag! 'RequestType', 'Payment'
126:           xml.tag! 'Payment' do
127:             xml.tag! 'TxnList', "count" => 1 do
128:               xml.tag! 'Txn', "ID" => 1 do
129:                 xml.tag! 'txnType', TRANSACTIONS[action]
130:                 xml.tag! 'txnSource', 23
131:                 xml << body
132:               end
133:             end
134:           end
135:         end
136:         
137:         xml.target!
138:       end
commit(action, request) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 140
140:       def commit(action, request)
141:         response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, build_request(action, request)))
142:         
143:         Response.new(success?(response), message_from(response), response, 
144:           :test => test?, 
145:           :authorization => authorization_from(response)
146:         )
147:       end
expdate(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 161
161:       def expdate(credit_card)
162:         "#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
163:       end
generate_timestamp() click to toggle source

YYYYDDMMHHNNSSKKK000sOOO

     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 186
186:       def generate_timestamp
187:         time = Time.now.utc
188:         time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
189:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 157
157:       def message_from(response)
158:         response[:response_text] || response[:status_description]
159:       end
parse(body) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 165
165:       def parse(body)
166:         xml = REXML::Document.new(body)
167: 
168:         response = {}
169:         
170:         xml.root.elements.to_a.each do |node|
171:           parse_element(response, node)
172:         end
173: 
174:         response
175:       end
parse_element(response, node) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 177
177:       def parse_element(response, node)
178:         if node.has_elements?
179:           node.elements.each{|element| parse_element(response, element) }
180:         else
181:           response[node.name.underscore.to_sym] = node.text
182:         end
183:       end
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/secure_pay_au.rb, line 149
149:       def success?(response)
150:         SUCCESS_CODES.include?(response[:response_code])
151:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.