Class: ActiveMerchant::Billing::MonerisGateway
- 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::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#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.
-
#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.
-
#credit(money, authorization, options = {}) ⇒ Object
Performs a refund.
-
#initialize(options = {}) ⇒ MonerisGateway
constructor
Initialize the Gateway.
-
#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.
- #refund(money, authorization, options = {}) ⇒ Object
- #scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
When passing a :duration option (time in seconds) you can create a temporary vault record to avoid incurring Moneris vault storage fees.
- #supports_scrubbing? ⇒ Boolean
- #unstore(data_key, options = {}) ⇒ Object
- #update(data_key, credit_card, options = {}) ⇒ Object
- #verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
Voiding requires the original transaction ID and order ID of some open transaction.
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
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 account types at Moneris will allow this. Defaults to false. (optional)
32 33 34 35 36 37 38 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 32 def initialize( = {}) requires!(, :login, :password) @cvv_enabled = [:cvv_enabled] @avs_enabled = [:avs_enabled] [:crypt_type] = 7 unless .has_key?(:crypt_type) 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 56 57 58 59 60 61 62 63 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 45 def (money, creditcard_or_datakey, = {}) requires!(, :order_id) post = {} add_payment_source(post, creditcard_or_datakey, ) post[:amount] = amount(money) post[:order_id] = [:order_id] post[:address] = [:billing_address] || [:address] post[:crypt_type] = [:crypt_type] || @options[:crypt_type] add_external_mpi_fields(post, ) add_stored_credential(post, ) action = if post[:cavv] || [:three_d_secure] 'cavv_preauth' elsif post[:data_key].blank? 'preauth' else 'res_preauth_cc' end 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
96 97 98 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 96 def capture(money, , = {}) commit 'completion', crediting_params(, 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.)
129 130 131 132 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 129 def credit(money, , = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, , ) 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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 69 def purchase(money, creditcard_or_datakey, = {}) requires!(, :order_id) post = {} add_payment_source(post, creditcard_or_datakey, ) post[:amount] = amount(money) post[:order_id] = [:order_id] post[:address] = [:billing_address] || [:address] post[:crypt_type] = [:crypt_type] || @options[:crypt_type] add_external_mpi_fields(post, ) add_stored_credential(post, ) action = if post[:cavv] || [:three_d_secure] 'cavv_purchase' elsif post[:data_key].blank? 'purchase' else 'res_purchase_cc' end commit(action, post, ) end |
#refund(money, authorization, options = {}) ⇒ Object
134 135 136 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 134 def refund(money, , = {}) commit 'refund', crediting_params(, amount: amount(money)) end |
#scrub(transcript) ⇒ Object
193 194 195 196 197 198 199 200 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 193 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 |
#store(credit_card, options = {}) ⇒ Object
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
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 158 def store(credit_card, = {}) post = {} post[:pan] = credit_card.number post[:expdate] = expdate(credit_card) post[:address] = [:billing_address] || [:address] post[:crypt_type] = [:crypt_type] || @options[:crypt_type] add_stored_credential(post, ) if [:duration] post[:duration] = [:duration] commit('res_temp_add', post) else commit('res_add_cc', post) end end |
#supports_scrubbing? ⇒ Boolean
189 190 191 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 189 def supports_scrubbing? true end |
#unstore(data_key, options = {}) ⇒ Object
174 175 176 177 178 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 174 def unstore(data_key, = {}) post = {} post[:data_key] = data_key commit('res_delete', post) end |
#update(data_key, credit_card, options = {}) ⇒ Object
180 181 182 183 184 185 186 187 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 180 def update(data_key, credit_card, = {}) post = {} post[:pan] = credit_card.number post[:expdate] = expdate(credit_card) post[:data_key] = data_key post[:crypt_type] = [:crypt_type] || @options[:crypt_type] commit('res_update_cc', post) end |
#verify(credit_card, options = {}) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 138 def verify(credit_card, = {}) requires!(, :order_id) post = {} add_payment_source(post, credit_card, ) post[:order_id] = [:order_id] post[:address] = [:billing_address] || [:address] post[:crypt_type] = [:crypt_type] || @options[:crypt_type] add_stored_credential(post, ) action = if post[:data_key].blank? 'card_verification' else 'res_card_verification_cc' end commit(action, 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.)
116 117 118 119 120 121 122 |
# File 'lib/active_merchant/billing/gateways/moneris.rb', line 116 def void(, = {}) if [:purchasecorrection] commit 'purchasecorrection', crediting_params() else capture(0, , ) end end |