Class Index [+]

Quicksearch

ActiveMerchant::Billing::NetRegistryGateway

Gateway for netregistry.com.au.

Note that NetRegistry itself uses gateway service providers. At the time of this writing, there are at least two (Quest and Ingenico). This module has only been tested with Quest.

Also note that NetRegistry does not offer a test mode, nor does it have support for the authorize/capture/void functionality by default (you may arrange for this as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]), and no # functionality is documented. As a result, the # and # have not yet been tested through a live gateway, and # will raise an error.

If you have this functionality enabled, please consider contributing to ActiveMerchant by writing tests/code for these methods, and submitting a patch.

In addition to the standard ActiveMerchant functionality, the response will contain a ‘receipt’ parameter (response.params[‘receipt’]) if a receipt was issued by the gateway.

Constants

URL
FILTERED_PARAMS
TRANSACTIONS

Public Class Methods

new(options = {}) click to toggle source

Create a new NetRegistry gateway.

Options :login and :password must be given.

    # File lib/active_merchant/billing/gateways/net_registry.rb, line 50
50:       def initialize(options = {})
51:         requires!(options, :login, :password)
52:         @options = options
53:         super
54:       end

Public Instance Methods

authorize(money, credit_card, options = {}) click to toggle source

Note that # and # only work if your account vendor is St George, and if your account has been setup as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]

    # File lib/active_merchant/billing/gateways/net_registry.rb, line 60
60:       def authorize(money, credit_card, options = {})
61:         params = {
62:           'AMOUNT'  => amount(money),
63:           'CCNUM'   => credit_card.number,
64:           'CCEXP'   => expiry(credit_card)
65:         }
66:         add_request_details(params, options)
67:         commit(:authorization, params)
68:       end
capture(money, authorization, options = {}) click to toggle source

Note that # and # only work if your account vendor is St George, and if your account has been setup as described in “Programming for NetRegistry’s E-commerce Gateway.” [rubyurl.com/hNG]

    # File lib/active_merchant/billing/gateways/net_registry.rb, line 74
74:       def capture(money, authorization, options = {})
75:         requires!(options, :credit_card)
76:         credit_card = options[:credit_card]
77: 
78:         params = {
79:           'PREAUTHNUM' => authorization,
80:           'AMOUNT'     => amount(money),
81:           'CCNUM'      => credit_card.number,
82:           'CCEXP'      => expiry(credit_card)
83:         }
84:         add_request_details(params, options)
85:         commit(:capture, params)
86:       end
credit(money, identification, options = {}) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 98
 98:       def credit(money, identification, options = {})
 99:         params = {
100:           'AMOUNT'  => amount(money),
101:           'TXNREF'  => identification
102:         }
103:         add_request_details(params, options)
104:         commit(:credit, params)
105:       end
purchase(money, credit_card, options = {}) click to toggle source
    # File lib/active_merchant/billing/gateways/net_registry.rb, line 88
88:       def purchase(money, credit_card, options = {})
89:         params = {
90:           'AMOUNT'  => amount(money),
91:           'CCNUM'   => credit_card.number,
92:           'CCEXP'   => expiry(credit_card)
93:         }
94:         add_request_details(params, options)
95:         commit(:purchase, params)
96:       end
status(identification) click to toggle source

Specific to NetRegistry.

Run a ‘status’ command. This lets you view the status of a completed transaction.

     # File lib/active_merchant/billing/gateways/net_registry.rb, line 112
112:       def status(identification)
113:         params = {
114:           'TXNREF'  => identification
115:         }
116:         
117:         commit(:status, params)
118:       end

Private Instance Methods

add_request_details(params, options) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 121
121:       def add_request_details(params, options)
122:         params['COMMENT'] = options[:description] unless options[:description].blank?
123:       end
authorization_from(response, command) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 179
179:       def authorization_from(response, command)
180:         case command
181:         when :purchase
182:           response['txn_ref']
183:         when :authorization
184:           response['transaction_no']
185:         end
186:       end
commit(action, params) click to toggle source

Post the a request with the given parameters and return the response object.

Login and password are added automatically, and the comment is omitted if nil.

     # File lib/active_merchant/billing/gateways/net_registry.rb, line 138
138:       def commit(action, params)
139:         # get gateway response
140:         response = parse( ssl_post(URL, post_data(action, params)) )
141:         
142:         Response.new(response['status'] == 'approved', message_from(response), response,          
143:           :authorization => authorization_from(response, action)
144:         )
145:       end
expiry(credit_card) click to toggle source

Return the expiry for the given creditcard in the required format for a command.

     # File lib/active_merchant/billing/gateways/net_registry.rb, line 127
127:       def expiry(credit_card)
128:         month = format(credit_card.month, :two_digits)
129:         year  = format(credit_card.year , :two_digits)
130:         "#{month}/#{year}"
131:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 175
175:       def message_from(response)
176:         response['response_text']
177:       end
parse(response) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 153
153:       def parse(response)
154:         params = {}
155:         
156:         lines = response.split("\n")
157:         
158:         # Just incase there is no real response returned
159:         params['status'] = lines[0]
160:         params['response_text'] = lines[1]
161:         
162:         started = false
163:         lines.each do |line|          
164:           if started
165:             key, val = line.chomp.split(/=/, 2)
166:             params[key] = val unless FILTERED_PARAMS.include?(key)
167:           end
168:           
169:           started = line.chomp =~ /^\.$/ unless started
170:         end
171:         
172:         params
173:       end
post_data(action, params) click to toggle source
     # File lib/active_merchant/billing/gateways/net_registry.rb, line 147
147:       def post_data(action, params)
148:         params['COMMAND'] = TRANSACTIONS[action]
149:         params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
150:         URI.encode(params.map{|k,v| "#{k}=#{v}"}.join('&'))
151:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.