Class: ActiveMerchant::Billing::ElavonGateway
- 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::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
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, creditcard, options = {}) ⇒ Object
Make a purchase.
-
#refund(money, identification, options = {}) ⇒ Object
Refund a transaction.
-
#void(identification, options = {}) ⇒ Object
Void a previous transaction.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from CreditCardFormatting
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
64 65 66 67 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 64 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.
-
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 88 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, ) 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).
-
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 106 def capture(money, , = {}) requires!(, :credit_card) form = {} add_salestax(form, ) add_approval_code(form, ) add_invoice(form, ) add_creditcard(form, [:credit_card]) add_customer_data(form, ) add_test_mode(form, ) commit(:capture, 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
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 155 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, creditcard, options = {}) ⇒ Object
Make a purchase
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 70 def purchase(money, creditcard, = {}) form = {} add_salestax(form, ) add_invoice(form, ) add_creditcard(form, creditcard) add_address(form, ) add_customer_data(form, ) add_test_mode(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.
129 130 131 132 133 134 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 129 def refund(money, identification, = {}) form = {} add_txn_id(form, identification) add_test_mode(form, ) commit(:refund, money, form) end |
#void(identification, options = {}) ⇒ Object
Void a previous transaction
Parameters
-
authorization
- The authorization returned from the previous request.
141 142 143 144 145 146 |
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 141 def void(identification, = {}) form = {} add_txn_id(form, identification) add_test_mode(form, ) commit(:void, nil, form) end |