To learn more about the Moneris gateway, please contact eselectplus@moneris.com for a copy of their integration guide. For information on remote testing, please see “Test Environment Penny Value Response Table”, and “Test Environment eFraud (AVS and CVD) Penny Response Values”, available at Moneris’ eSelect Plus Documentation Centre.
This method retrieves locked funds from a customer’s account (from a PreAuth) and prepares them for deposit in a merchant’s account.
Note: Moneris requires both the order_id and the transaction number of the original authorization. To maintain the same interface as the other gateways the two numbers are concatenated together with a ; separator as the authorization number returned by authorization
# File lib/active_merchant/billing/gateways/moneris.rb, line 53 53: def capture(money, authorization, options = {}) 54: commit 'completion', crediting_params(authorization, :comp_amount => amount(money)) 55: end
Performs a refund. This method requires that the original transaction number and order number be included. Concatenate your transaction number and order_id by using a semicolon (’;’). This is to keep the Moneris interface consistent with other gateways. (See capture for details.)
# File lib/active_merchant/billing/gateways/moneris.rb, line 73 73: def credit(money, authorization, options = {}) 74: deprecated CREDIT_DEPRECATION_MESSAGE 75: refund(money, authorization, options) 76: end
This action verifies funding on a customer’s card, and readies them for deposit in a merchant’s account.
Pass in order_id and optionally a customer parameter
# File lib/active_merchant/billing/gateways/moneris.rb, line 42 42: def purchase(money, creditcard, options = {}) 43: debit_commit 'purchase', money, creditcard, options 44: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 78 78: def refund(money, authorization, options = {}) 79: commit 'refund', crediting_params(authorization, :amount => amount(money)) 80: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 82 82: def test? 83: @options[:test] || super 84: end
Voiding requires the original transaction ID and order ID of some open transaction. Closed transactions must be refunded. Note that the only methods which may be voided are capture and purchase.
Concatenate your transaction number and order_id by using a semicolon (’;’). This is to keep the Moneris interface consistent with other gateways. (See capture for details.)
# File lib/active_merchant/billing/gateways/moneris.rb, line 64 64: def void(authorization, options = {}) 65: commit 'purchasecorrection', crediting_params(authorization) 66: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 194 194: def actions 195: { 196: "purchase" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], 197: "preauth" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], 198: "command" => [:order_id], 199: "refund" => [:order_id, :amount, :txn_number, :crypt_type], 200: "indrefund" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], 201: "completion" => [:order_id, :comp_amount, :txn_number, :crypt_type], 202: "purchasecorrection" => [:order_id, :txn_number, :crypt_type], 203: "cavvpurcha" => [:order_id, :cust_id, :amount, :pan, :expdate, :cav], 204: "cavvpreaut" => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv], 205: "transact" => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type], 206: "Batchcloseall" => [], 207: "opentotals" => [:ecr_number], 208: "batchclose" => [:ecr_number] 209: } 210: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 127 127: def commit(action, parameters = {}) 128: response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(action, parameters))) 129: 130: Response.new(successful?(response), message_from(response[:message]), response, 131: :test => test?, 132: :authorization => authorization_from(response) 133: ) 134: end
Common params used amongst the credit, void and capture methods
# File lib/active_merchant/billing/gateways/moneris.rb, line 109 109: def crediting_params(authorization, options = {}) 110: { 111: :txn_number => split_authorization(authorization).first, 112: :order_id => split_authorization(authorization).last, 113: :crypt_type => options[:crypt_type] || @options[:crypt_type] 114: }.merge(options) 115: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 91 91: def debit_commit(commit_type, money, creditcard, options) 92: requires!(options, :order_id) 93: commit(commit_type, debit_params(money, creditcard, options)) 94: end
Common params used amongst the purchase and authorization methods
# File lib/active_merchant/billing/gateways/moneris.rb, line 97 97: def debit_params(money, creditcard, options = {}) 98: { 99: :order_id => options[:order_id], 100: :cust_id => options[:customer], 101: :amount => amount(money), 102: :pan => creditcard.number, 103: :expdate => expdate(creditcard), 104: :crypt_type => options[:crypt_type] || @options[:crypt_type] 105: } 106: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 87 87: def expdate(creditcard) 88: sprintf("%.4i", creditcard.year)[2..1] + sprintf("%.2i", creditcard.month) 89: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 156 156: def hashify_xml!(xml, response) 157: xml = REXML::Document.new(xml) 158: return if xml.root.nil? 159: xml.elements.each('//receipt/*') do |node| 160: response[node.name.underscore.to_sym] = normalize(node.text) 161: end 162: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 179 179: def message_from(message) 180: return 'Unspecified error' if message.blank? 181: message.gsub(/[^\w]/, ' ').split.join(" ").capitalize 182: end
Make a Ruby type out of the response string
# File lib/active_merchant/billing/gateways/moneris.rb, line 185 185: def normalize(field) 186: case field 187: when "true" then true 188: when "false" then false 189: when '', "null" then nil 190: else field 191: end 192: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 150 150: def parse(xml) 151: response = { :message => "Global Error Receipt", :complete => false } 152: hashify_xml!(xml, response) 153: response 154: end
# File lib/active_merchant/billing/gateways/moneris.rb, line 164 164: def post_data(action, parameters = {}) 165: xml = REXML::Document.new 166: root = xml.add_element("request") 167: root.add_element("store_id").text = options[:login] 168: root.add_element("api_token").text = options[:password] 169: transaction = root.add_element(action) 170: 171: # Must add the elements in the correct order 172: actions[action].each do |key| 173: transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank? 174: end 175: 176: xml.to_s 177: end
Tests for a successful response from Moneris’ servers
# File lib/active_merchant/billing/gateways/moneris.rb, line 144 144: def successful?(response) 145: response[:response_code] && 146: response[:complete] && 147: (0..49).include?(response[:response_code].to_i) 148: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.