Class: ActiveMerchant::Billing::MonerisGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/moneris.rb

Overview

To learn more about the Moneris gateway, please contact [email protected] 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.

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ MonerisGateway

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  types at Moneris will allow this.
    Defaults to false.  (optional)
    


33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 33

def initialize(options = {})
  requires!(options, :login, :password)
  @cvv_enabled = options[:cvv_enabled]
  options = { :crypt_type => 7 }.merge(options)
  super
end

Instance Method Details

#authorize(money, creditcard_or_datakey, options = {}) ⇒ Object

Referred to as “PreAuth” in the Moneris integration guide, this action verifies and locks funds on a customer’s card, which then must be captured at a later date.

Pass in order_id and optionally a customer parameter.



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 45

def authorize(money, creditcard_or_datakey, options = {})
  requires!(options, :order_id)
  post = {}
  add_payment_source(post, creditcard_or_datakey)
  post[:amount]     = amount(money)
  post[:order_id]   = options[:order_id]
  post[:cust_id]    = options[:customer]
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
  action = (post[:data_key].blank?) ? 'preauth' : 'res_preauth_cc'
  commit(action, post)
end

#capture(money, authorization, options = {}) ⇒ Object

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



80
81
82
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 80

def capture(money, authorization, options = {})
  commit 'completion', crediting_params(authorization, :comp_amount => amount(money))
end

#credit(money, authorization, options = {}) ⇒ Object

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.)



113
114
115
116
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 113

def credit(money, authorization, options = {})
  deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, authorization, options)
end

#purchase(money, creditcard_or_datakey, options = {}) ⇒ Object

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



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 61

def purchase(money, creditcard_or_datakey, options = {})
  requires!(options, :order_id)
  post = {}
  add_payment_source(post, creditcard_or_datakey)
  post[:amount]     = amount(money)
  post[:order_id]   = options[:order_id]
  post[:cust_id]    = options[:customer]
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
  action = (post[:data_key].blank?) ? 'purchase' : 'res_purchase_cc'
  commit(action, post)
end

#refund(money, authorization, options = {}) ⇒ Object



118
119
120
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 118

def refund(money, authorization, options = {})
  commit 'refund', crediting_params(authorization, :amount => amount(money))
end

#store(credit_card, options = {}) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 122

def store(credit_card, options = {})
  post = {}
  post[:pan] = credit_card.number
  post[:expdate] = expdate(credit_card)
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
  commit('res_add_cc', post)
end

#unstore(data_key, options = {}) ⇒ Object



130
131
132
133
134
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 130

def unstore(data_key, options = {})
  post = {}
  post[:data_key] = data_key
  commit('res_delete', post)
end

#update(data_key, credit_card, options = {}) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 136

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

#void(authorization, options = {}) ⇒ Object

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.)



100
101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 100

def void(authorization, options = {})
  if options[:purchasecorrection]
    commit 'purchasecorrection', crediting_params(authorization)
  else
    capture(0, authorization, options)
  end
end