Class: ActiveMerchant::Billing::ItransactGateway

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

Overview

iTransact, Inc. is an authorized reseller of the PaymentClearing gateway. If your merchant service provider uses PaymentClearing.com to process payments, you can use this module.

Please note, the username and API Access Key are not what you use to log into the Merchant Control Panel.

How to get your GatewayID and API Access Key

  1. If you don’t already have a Gateway Account, go to www.itransact.com/merchant/test.html to sign up.

  2. Go to support.paymentclearing.com and login or register, if necessary.

  3. Click on “Submit a Ticket.”

  4. Select “Merchant Support” as the department and click “Next”

  5. Enter both your company name and GatewayID. Put “API Access Key” in the subject. In the body, you can request a username, but it may already be in use.

Initialization

Once you have the username, API Access Key, and your GatewayId, you’re ready to begin. You initialize the Gateway like so:

gateway = ActiveMerchant::Billing::ItransactGateway.new(
  :login => "#{THE_USERNAME}",
  :password => "#{THE_API_ACCESS_KEY}",
  :gateway_id => "#{THE_GATEWAY_ID}"
)

Important Notes

  1. Recurring is not implemented

  2. CreditTransactions are not implemented (these are credits not related to a previously run transaction).

  3. TransactionStatus is not implemented

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

#options

Instance Method Summary collapse

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

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ ItransactGateway

Creates a new instance of the iTransact Gateway.

Parameters

  • options - A Hash of options

Options Hash

  • :login - A String containing your PaymentClearing assigned API Access Username

  • :password - A String containing your PaymentClearing assigned API Access Key

  • :gateway_id - A String containing your PaymentClearing assigned GatewayID

  • :test_mode - true or false. Run all transactions with the ‘TestMode’ element set to ‘TRUE’.



61
62
63
64
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 61

def initialize(options = {})
  requires!(options, :login, :password, :gateway_id)
  super
end

Instance Method Details

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

Performs an authorize transaction. In PaymentClearing’s documentation this is known as a “PreAuth” transaction.

Parameters

  • money - The amount to be captured. Should be an Integer amount in cents.

  • creditcard - The CreditCard details for the transaction

  • options - A Hash of options

Options Hash

The standard options apply here (:order_id, :ip, :customer, :invoice, :merchant, :description, :email, :currency, :address, :billing_address, :shipping_address), as well as:

  • :order_items - An Array of Hash objects with the keys :description, :cost (in cents!), and :quantity. If this is provided, :description and money will be ignored.

  • :vendor_data - An Array of Hash objects with the keys being the name of the VendorData element and value being the value.

  • :send_customer_email - true or false. Runs the transaction with the ‘SendCustomerEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :send_merchant_email - true or false. Runs the transaction with the ‘SendMerchantEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :email_text - An Array of (up to ten (10)) String objects to be included in emails

  • :test_mode - true or false. Runs the transaction with the ‘TestMode’ element set to ‘TRUE’ or ‘FALSE’.

Examples

response = gateway.authorize(1000, creditcard,
  :order_id => '1212', :address => {...}, :email => '[email protected]',
  :order_items => [
    {:description => 'Line Item 1', :cost => '8.98', :quantity => '6'},
    {:description => 'Line Item 2', :cost => '6.99', :quantity => '4'}
  ],
  :vendor_data => [{'repId' => '1234567'}, {'customerId' => '9886'}],
  :send_customer_email => true,
  :send_merchant_email => true,
  :email_text => ['line1', 'line2', 'line3'],
  :test_mode => true
)


97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 97

def authorize(money, payment_source, options = {})
  payload = Nokogiri::XML::Builder.new do |xml|
    xml.AuthTransaction {
      xml.Preauth
      add_customer_data(xml, payment_source, options)
      add_invoice(xml, money, options)
      add_payment_source(xml, payment_source)
      add_transaction_control(xml, options)
      add_vendor_data(xml, options)
    }
  end.doc

  commit(payload)
end

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

Captures the funds from an authorize transaction. In PaymentClearing’s documentation this is known as a “PostAuth” transaction.

Parameters

  • money - The amount to be captured. Should be an Integer amount in cents

  • authorization - The authorization returned from the previous capture or purchase request

  • options - A Hash of options, all are optional.

Options Hash

The standard options apply here (:order_id, :ip, :customer, :invoice, :merchant, :description, :email, :currency, :address, :billing_address, :shipping_address), as well as:

  • :vendor_data - An Array of Hash objects with the keys being the name of the VendorData element and value being the value.

  • :send_customer_email - true or false. Runs the transaction with the ‘SendCustomerEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :send_merchant_email - true or false. Runs the transaction with the ‘SendMerchantEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :email_text - An Array of (up to ten (10)) String objects to be included in emails

  • :test_mode - true or false. Runs the transaction with the ‘TestMode’ element set to ‘TRUE’ or ‘FALSE’.

Examples

response = gateway.capture(1000, creditcard,
  :vendor_data => [{'repId' => '1234567'}, {'customerId' => '9886'}],
  :send_customer_email => true,
  :send_merchant_email => true,
  :email_text => ['line1', 'line2', 'line3'],
  :test_mode => true
)


182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 182

def capture(money, authorization, options = {})
  payload = Nokogiri::XML::Builder.new do |xml|
    xml.PostAuthTransaction {
      xml.OperationXID(authorization)
      add_invoice(xml, money, options)
      add_transaction_control(xml, options)
      add_vendor_data(xml, options)
    }
  end.doc

  commit(payload)
end

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

Performs an authorize and capture in single transaction. In PaymentClearing’s documentation this is known as an “Auth” or a “Sale” transaction

Parameters

  • money - The amount to be captured. Should be nil or an Integer amount in cents.

  • creditcard - The CreditCard details for the transaction

  • options - A Hash of options

Options Hash

The standard options apply here (:order_id, :ip, :customer, :invoice, :merchant, :description, :email, :currency, :address, :billing_address, :shipping_address), as well as:

  • :order_items - An Array of Hash objects with the keys :description, :cost (in cents!), and :quantity. If this is provided, :description and money will be ignored.

  • :vendor_data - An Array of Hash objects with the keys being the name of the VendorData element and value being the value.

  • :send_customer_email - true or false. Runs the transaction with the ‘SendCustomerEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :send_merchant_email - true or false. Runs the transaction with the ‘SendMerchantEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :email_text - An Array of (up to ten (10)) String objects to be included in emails

  • :test_mode - true or false. Runs the transaction with the ‘TestMode’ element set to ‘TRUE’ or ‘FALSE’.

Examples

response = gateway.purchase(1000, creditcard,
  :order_id => '1212', :address => {...}, :email => '[email protected]',
  :order_items => [
    {:description => 'Line Item 1', :cost => '8.98', :quantity => '6'},
    {:description => 'Line Item 2', :cost => '6.99', :quantity => '4'}
  ],
  :vendor_data => [{'repId' => '1234567'}, {'customerId' => '9886'}],
  :send_customer_email => true,
  :send_merchant_email => true,
  :email_text => ['line1', 'line2', 'line3'],
  :test_mode => true
)


143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 143

def purchase(money, payment_source, options = {})
  payload = Nokogiri::XML::Builder.new do |xml|
    xml.AuthTransaction {
      add_customer_data(xml, payment_source, options)
      add_invoice(xml, money, options)
      add_payment_source(xml, payment_source)
      add_transaction_control(xml, options)
      add_vendor_data(xml, options)
    }
  end.doc

  commit(payload)
end

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

This will reverse a previously run transaction which has settled.

Parameters

  • money - The amount to be credited. Should be an Integer amount in cents

  • authorization - The authorization returned from the previous capture or purchase request

  • options - A Hash of options, all are optional

Options Hash

The standard options (:order_id, :ip, :customer, :invoice, :merchant, :description, :email, :currency, :address, :billing_address, :shipping_address) are ignored.

  • :vendor_data - An Array of Hash objects with the keys being the name of the VendorData element and value being the value.

  • :send_customer_email - true or false. Runs the transaction with the ‘SendCustomerEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :send_merchant_email - true or false. Runs the transaction with the ‘SendMerchantEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :email_text - An Array of (up to ten (10)) String objects to be included in emails

  • :test_mode - true or false. Runs the transaction with the ‘TestMode’ element set to ‘TRUE’ or ‘FALSE’.

Examples

response = gateway.refund(555, '9999999999',
  :vendor_data => [{'repId' => '1234567'}, {'customerId' => '9886'}],
  :send_customer_email => true,
  :send_merchant_email => true,
  :email_text => ['line1', 'line2', 'line3'],
  :test_mode => true
)


254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 254

def refund(money, authorization, options = {})
  payload = Nokogiri::XML::Builder.new do |xml|
    xml.TranCredTransaction {
      xml.OperationXID(authorization)
      add_invoice(xml, money, options)
      add_transaction_control(xml, options)
      add_vendor_data(xml, options)
    }
  end.doc

  commit(payload)
end

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

This will reverse a previously run transaction which has not settled.

Parameters

  • authorization - The authorization returned from the previous capture or purchase request

  • options - A Hash of options, all are optional

Options Hash

The standard options (:order_id, :ip, :customer, :invoice, :merchant, :description, :email, :currency, :address, :billing_address, :shipping_address) are ignored.

  • :vendor_data - An Array of Hash objects with the keys being the name of the VendorData element and value being the value.

  • :send_customer_email - true or false. Runs the transaction with the ‘SendCustomerEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :send_merchant_email - true or false. Runs the transaction with the ‘SendMerchantEmail’ element set to ‘TRUE’ or ‘FALSE’.

  • :email_text - An Array of (up to ten (10)) String objects to be included in emails

  • :test_mode - true or false. Runs the transaction with the ‘TestMode’ element set to ‘TRUE’ or ‘FALSE’.

Examples

response = gateway.void('9999999999',
  :vendor_data => [{'repId' => '1234567'}, {'customerId' => '9886'}],
  :send_customer_email => true,
  :send_merchant_email => true,
  :email_text => ['line1', 'line2', 'line3'],
  :test_mode => true
)


218
219
220
221
222
223
224
225
226
227
228
# File 'lib/active_merchant/billing/gateways/itransact.rb', line 218

def void(authorization, options = {})
  payload = Nokogiri::XML::Builder.new do |xml|
    xml.VoidTransaction {
      xml.OperationXID(authorization)
      add_transaction_control(xml, options)
      add_vendor_data(xml, options)
    }
  end.doc

  commit(payload)
end