class ActiveMerchant::Billing::MonerisGateway
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.
Constants
- WALLETS
Public Class Methods
Initialize the Gateway
The gateway requires that a valid login and password be passed in the options
hash.
Options¶ ↑
-
:login
– Your Store ID -
:password
– Your API Token -
:cvv_enabled
– Specify that you would like the CVV passed to the gateway.Only particular account types at Moneris will allow this. Defaults to false. (optional)
ActiveMerchant::Billing::Gateway::new
# File lib/active_merchant/billing/gateways/moneris.rb, line 34 def initialize(options = {}) requires!(options, :login, :password) @cvv_enabled = options[:cvv_enabled] @avs_enabled = options[:avs_enabled] options[:crypt_type] = 7 unless options.has_key?(:crypt_type) super end
Public Instance Methods
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 100 def capture(money, authorization, options = {}) commit 'completion', crediting_params(authorization, comp_amount: amount(money)) 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 133 def credit(money, authorization, options = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, authorization, options) 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 72 def purchase(money, creditcard_or_datakey, options = {}) requires!(options, :order_id) post = {} add_payment_source(post, creditcard_or_datakey, options) post[:amount] = amount(money) post[:order_id] = format_order_id(post[:wallet_indicator], options[:order_id]) post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] add_external_mpi_fields(post, options) add_stored_credential(post, options) add_cust_id(post, options) action = if post[:cavv] || options[:three_d_secure] 'cavv_purchase' elsif post[:data_key].blank? 'purchase' else 'res_purchase_cc' end commit(action, post, options) end
# File lib/active_merchant/billing/gateways/moneris.rb, line 138 def refund(money, authorization, options = {}) commit 'refund', crediting_params(authorization, amount: amount(money)) end
# File lib/active_merchant/billing/gateways/moneris.rb, line 197 def scrub(transcript) transcript. gsub(%r((<store_id>).+(</store_id>)), '\1[FILTERED]\2'). gsub(%r((<api_token>).+(</api_token>)), '\1[FILTERED]\2'). gsub(%r((<pan>).+(</pan>)), '\1[FILTERED]\2'). gsub(%r((<cvd_value>).+(</cvd_value>)), '\1[FILTERED]\2'). gsub(%r((<cavv>).+(</cavv>)), '\1[FILTERED]\2') end
When passing a :duration option (time in seconds) you can create a temporary vault record to avoid incurring Moneris vault storage fees
developer.moneris.com/Documentation/NA/E-Commerce%20Solutions/API/Vault#vaulttokenadd
# File lib/active_merchant/billing/gateways/moneris.rb, line 162 def store(credit_card, options = {}) post = {} post[:pan] = credit_card.number post[:expdate] = expdate(credit_card) post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] add_stored_credential(post, options) if options[:duration] post[:duration] = options[:duration] commit('res_temp_add', post) else commit('res_add_cc', post) end end
# File lib/active_merchant/billing/gateways/moneris.rb, line 193 def supports_scrubbing? true end
# File lib/active_merchant/billing/gateways/moneris.rb, line 178 def unstore(data_key, options = {}) post = {} post[:data_key] = data_key commit('res_delete', post) end
# File lib/active_merchant/billing/gateways/moneris.rb, line 184 def update(data_key, credit_card, options = {}) post = {} post[:pan] = credit_card.number post[:expdate] = expdate(credit_card) post[:data_key] = data_key post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] commit('res_update_cc', post) end
# File lib/active_merchant/billing/gateways/moneris.rb, line 142 def verify(credit_card, options = {}) requires!(options, :order_id) post = {} add_payment_source(post, credit_card, options) post[:order_id] = options[:order_id] post[:address] = options[:billing_address] || options[:address] post[:crypt_type] = options[:crypt_type] || @options[:crypt_type] add_stored_credential(post, options) action = if post[:data_key].blank? 'card_verification' else 'res_card_verification_cc' end commit(action, post) end
Voiding requires the original transaction ID and order ID of some open transaction. Closed transactions must be refunded.
Moneris supports the voiding of an unsettled capture or purchase via its purchasecorrection
command. This action can only occur on the same day as the capture/purchase prior to 22:00-23:00 EST. If you want to do this, pass :purchasecorrection => true
as an option.
Fun, Historical Trivia: Voiding an authorization in Moneris is a relatively new feature (September, 2011). It is actually done by doing a $0 capture.
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 120 def void(authorization, options = {}) if options[:purchasecorrection] commit 'purchasecorrection', crediting_params(authorization) else capture(0, authorization, options) end end