Class: ActiveMerchant::Billing::ElavonGateway
- Includes:
- Empty
- Defined in:
- lib/active_merchant/billing/gateways/elavon.rb
Overview
Elavon Virtual Merchant Gateway
Example use:
gateway = ActiveMerchant::Billing::ElavonGateway.new(
:login => "my_virtual_merchant_id",
:password => "my_virtual_merchant_pin",
:user => "my_virtual_merchant_user_id" # optional
)
# set up credit card obj as in main ActiveMerchant example
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => 'visa',
:number => '41111111111111111',
:month => 10,
:year => 2011,
:first_name => 'Bob',
:last_name => 'Bobsen'
)
# run request
response = gateway.purchase(1000, creditcard) # authorize and capture 10 USD
puts response.success? # Check whether the transaction was successful
puts response. # Retrieve the message returned by Elavon
puts response. # Retrieve the unique transaction ID returned by Elavon
Constant Summary
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
Authorize a credit card for a given amount.
-
#capture(money, authorization, options = {}) ⇒ Object
Capture authorized funds from a credit card.
-
#credit(money, creditcard, options = {}) ⇒ Object
Make a credit to a card.
-
#initialize(options = {}) ⇒ ElavonGateway
constructor
Initialize the Gateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
Make a purchase.
-
#refund(money, identification, options = {}) ⇒ Object
Refund a transaction.
- #store(creditcard, options = {}) ⇒ Object
- #update(token, creditcard, options = {}) ⇒ Object
- #verify(credit_card, options = {}) ⇒ Object
-
#void(identification, options = {}) ⇒ Object
Void a previous transaction.
Methods inherited from Gateway
#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 = {}) ⇒ ElavonGateway
Initialize the Gateway
The gateway requires that a valid login and password be passed in the options
hash.
Options
-
:login
– Merchant ID -
:password
– PIN -
:user
– Specify a subuser of the account (optional) -
:test => true or false
– Force test transactions
69 70 71 72 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 69 def initialize( = {}) requires!(, :login, :password) super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Authorize a credit card for a given amount.
Parameters
-
money
- The amount to be authorized as an Integer value in cents. -
credit_card
- The CreditCard details for the transaction. -
options
-
:billing_address
- The billing address for the cardholder.
-
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 98 def (money, creditcard, = {}) form = {} add_salestax(form, ) add_invoice(form, ) add_creditcard(form, creditcard) add_address(form, ) add_customer_data(form, ) add_test_mode(form, ) add_ip(form, ) commit(:authorize, money, form) end |
#capture(money, authorization, options = {}) ⇒ Object
Capture authorized funds from a credit card.
Parameters
-
money
- The amount to be captured as an Integer value in cents. -
authorization
- The approval code returned from the initial authorization. -
options
-
:credit_card
- The CreditCard details from the initial transaction (required).
-
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 117 def capture(money, , = {}) form = {} if [:credit_card] action = :capture add_salestax(form, ) add_approval_code(form, ) add_invoice(form, ) add_creditcard(form, [:credit_card]) add_customer_data(form, ) add_test_mode(form, ) else action = :capture_complete add_txn_id(form, ) add_partial_shipment_flag(form, ) add_test_mode(form, ) end commit(action, money, form) end |
#credit(money, creditcard, options = {}) ⇒ Object
Make a credit to a card. Use the refund method if you’d like to credit using previous transaction
Parameters
-
money
- The amount to be credited as an Integer value in cents. -
creditcard
- The credit card to be credited. -
options
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 172 def credit(money, creditcard, = {}) if creditcard.is_a?(String) raise ArgumentError, "Reference credits are not supported. Please supply the original credit card or use the #refund method." end form = {} add_invoice(form, ) add_creditcard(form, creditcard) add_address(form, ) add_customer_data(form, ) add_test_mode(form, ) commit(:credit, money, form) end |
#purchase(money, payment_method, options = {}) ⇒ Object
Make a purchase
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 75 def purchase(money, payment_method, = {}) form = {} add_salestax(form, ) add_invoice(form, ) if payment_method.is_a?(String) add_token(form, payment_method) else add_creditcard(form, payment_method) end add_address(form, ) add_customer_data(form, ) add_test_mode(form, ) add_ip(form, ) commit(:purchase, money, form) end |
#refund(money, identification, options = {}) ⇒ Object
Refund a transaction.
This transaction indicates to the gateway that money should flow from the merchant to the customer.
Parameters
-
money
– The amount to be credited to the customer as an Integer value in cents. -
identification
– The ID of the original transaction against which the refund is being issued. -
options
– A hash of parameters.
146 147 148 149 150 151 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 146 def refund(money, identification, = {}) form = {} add_txn_id(form, identification) add_test_mode(form, ) commit(:refund, money, form) end |
#store(creditcard, options = {}) ⇒ Object
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 193 def store(creditcard, = {}) form = {} add_creditcard(form, creditcard) add_address(form, ) add_customer_data(form, ) add_test_mode(form, ) add_verification(form, ) form[:add_token] = 'Y' commit(:store, nil, form) end |
#update(token, creditcard, options = {}) ⇒ Object
204 205 206 207 208 209 210 211 212 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 204 def update(token, creditcard, = {}) form = {} add_token(form, token) add_creditcard(form, creditcard) add_address(form, ) add_customer_data(form, ) add_test_mode(form, ) commit(:update, nil, form) end |
#verify(credit_card, options = {}) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 186 def verify(credit_card, = {}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#void(identification, options = {}) ⇒ Object
Void a previous transaction
Parameters
-
authorization
- The authorization returned from the previous request.
158 159 160 161 162 163 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 158 def void(identification, = {}) form = {} add_txn_id(form, identification) add_test_mode(form, ) commit(:void, nil, form) end |