Class: ActiveMerchant::Billing::EvoCaGateway
- Defined in:
- lib/active_merchant/billing/gateways/evo_ca.rb
Overview
EVO Canada payment gateway.
EVO returns two different identifiers for most transactions, the authcode
and the transactionid
. Since transactionid
is used more often (i.e. for #capture, #refund, #void and #update) we store it in the Response#authorization attribute. The authcode
from the merchant account is accessible via Response#params.
Two different but related response messages are also returned from EVO. The message indicated by EVO’s response_code
parameter is returned as Response#message (Those messages can be seen in the MESSAGES hash.) The other, shorter message is available via Response#params.
It’s recommended to save the contents of the Response#params in your transaction log for future reference.
Sample Use
gateway = ActiveMerchant::Billing::EvoCaGateway.new(username: 'demo', password: 'password')
response = gateway.(1000, credit_card, )
puts response. # the transactionid
puts response.params['authcode'] # the authcode from the merchant account
puts response. # the 'pretty' response message
puts response.params['responsetext'] # the 'terse' response message
gateway.capture(1000, response.)
gateway.update(response., shipping_carrier: 'fedex')
gateway.refund(500, response.)
Constant Summary collapse
- MESSAGES =
{ 100 => 'Transaction was approved', 200 => 'Transaction was declined by processor', 201 => 'Do not honor', 202 => 'Insufficient funds', 203 => 'Over limit', 204 => 'Transaction not allowed', 220 => 'Incorrect payment data', 221 => 'No such card issuer', 222 => 'No card number on file with issuer', 223 => 'Expired card', 224 => 'Invalid expiration date', 225 => 'Invalid card security code', 240 => 'Call issuer for futher information', 250 => 'Pick up card', 251 => 'Lost card', 252 => 'Stolen card', 253 => 'Fraudulant card', 260 => 'Declined with further instructions available', 261 => 'Declined - stop all recurring payments', 262 => 'Declined - stop this recurring program', 263 => 'Declined - updated cardholder data available', 264 => 'Declined - retry in a few days', 300 => 'Transaction was rejected by gateway', 400 => 'Transaction error returned by processor', 410 => 'Invalid merchant configuration', 411 => 'Merchant account is inactive', 420 => 'Communication error', 421 => 'Communication error with issuer', 430 => 'Duplicate transaction at processor', 440 => 'Processor format error', 441 => 'Invalid transaction information', 460 => 'Processor feature not available', 461 => 'Unsupported card type' }
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, credit_card, options = {}) ⇒ Object
Transaction authorizations are authorized immediately but are not flagged for settlement.
-
#capture(money, authorization, options = {}) ⇒ Object
Transaction captures flag existing authorizations for settlement.
-
#credit(money, credit_card, options = {}) ⇒ Object
Transaction credits apply a negative amount to the cardholder’s card.
-
#initialize(options = {}) ⇒ EvoCaGateway
constructor
This gateway requires that a valid username and password be passed in the
options
hash. -
#purchase(money, credit_card_or_check, options = {}) ⇒ Object
Transaction sales are submitted and immediately flagged for settlement.
-
#refund(money, identification) ⇒ Object
Transaction refunds will reverse a previously settled transaction.
-
#update(identification, options) ⇒ Object
Transaction updates can be used to update previous transactions with specific order information, such as a tracking number and shipping carrier.
-
#void(identification) ⇒ Object
Transaction voids will cancel an existing sale or captured authorization.
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #scrub, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ EvoCaGateway
This gateway requires that a valid username and password be passed in the options
hash.
Required Options
-
:username
-
:password
89 90 91 92 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 89 def initialize( = {}) requires!(, :username, :password) super end |
Instance Method Details
#authorize(money, credit_card, options = {}) ⇒ Object
Transaction authorizations are authorized immediately but are not flagged for settlement. These transactions must be flagged for settlement using the capture transaction type. Authorizations typically remain activate for three to seven business days.
Payment source must be a CreditCard.
123 124 125 126 127 128 129 130 131 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 123 def (money, credit_card, = {}) post = {} add_invoice(post, ) add_order(post, ) add_paymentmethod(post, credit_card) add_address(post, ) add_customer_data(post, ) commit('auth', money, post) end |
#capture(money, authorization, options = {}) ⇒ Object
Transaction captures flag existing authorizations for settlement. Only authorizations can be captured. Captures can be submitted for an amount equal to or less than the original authorization.
The authorization
parameter is the transaction ID, retrieved from Response#authorization. See EvoCaGateway#purchase for the options
.
140 141 142 143 144 145 146 147 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 140 def capture(money, , = {}) post = { amount: amount(money), transactionid: } add_order(post, ) commit('capture', money, post) end |
#credit(money, credit_card, options = {}) ⇒ Object
Transaction credits apply a negative amount to the cardholder’s card. In most situations credits are disabled as transaction refunds should be used instead.
Note that this is different from a #refund (which is usually what you’ll be looking for).
166 167 168 169 170 171 172 173 174 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 166 def credit(money, credit_card, = {}) post = {} add_invoice(post, ) add_order(post, ) add_paymentmethod(post, credit_card) add_address(post, ) add_customer_data(post, ) commit('credit', money, post) end |
#purchase(money, credit_card_or_check, options = {}) ⇒ Object
Transaction sales are submitted and immediately flagged for settlement. These transactions will automatically be settled.
Payment source can be either a CreditCard or Check.
Additional Options
In addition to the standard options, this gateway supports
-
:tracking_number
- Shipping tracking number -
:shipping_carrier
- ups/fedex/dhl/usps -
:po_number
- Purchase order -
:tax
- Tax amount -
:shipping
- Shipping cost
107 108 109 110 111 112 113 114 115 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 107 def purchase(money, credit_card_or_check, = {}) post = {} add_invoice(post, ) add_order(post, ) add_paymentmethod(post, credit_card_or_check) add_address(post, ) add_customer_data(post, ) commit('sale', money, post) end |
#refund(money, identification) ⇒ Object
Transaction refunds will reverse a previously settled transaction. If the transaction has not been settled, it must be voided instead of refunded.
The identification
parameter is the transaction ID, retrieved from Response#authorization.
155 156 157 158 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 155 def refund(money, identification) post = { transactionid: identification } commit('refund', money, post) end |
#update(identification, options) ⇒ Object
Transaction updates can be used to update previous transactions with specific order information, such as a tracking number and shipping carrier. See EvoCaGateway#purchase for options
.
The identification
parameter is the transaction ID, retrieved from Response#authorization.
194 195 196 197 198 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 194 def update(identification, ) post = { transactionid: identification } add_order(post, ) commit('update', nil, post) end |
#void(identification) ⇒ Object
Transaction voids will cancel an existing sale or captured authorization. In addition, non-captured authorizations can be voided to prevent any future capture. Voids can only occur if the transaction has not been settled.
The identification
parameter is the transaction ID, retrieved from Response#authorization.
183 184 185 186 |
# File 'lib/active_merchant/billing/gateways/evo_ca.rb', line 183 def void(identification) post = { transactionid: identification } commit('void', nil, post) end |