Class: ActiveMerchant::Billing::FirstdataE4Gateway

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

Constant Summary collapse

TRANSACTIONS =
{
  sale:          "00",
  authorization: "01",
  verify:        "05",
  capture:       "32",
  void:          "33",
  credit:        "34",
  store:         "05"
}
POST_HEADERS =
{
  "Accepts" => "application/xml",
  "Content-Type" => "application/xml"
}
SUCCESS =
"true"
SENSITIVE_FIELDS =
[:verification_str2, :expiry_date, :card_number]
BRANDS =
{
  :visa => 'Visa',
  :master => "Mastercard",
  :american_express => "American Express",
  :jcb => "JCB",
  :discover => "Discover"
}
E4_BRANDS =
BRANDS.merge({:mastercard => "Mastercard"})

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #supported_countries, supported_countries, supported_countries=, supports?, #test?

Methods included from CreditCardFormatting

#format

Methods included from PostsData

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

Constructor Details

#initialize(options = {}) ⇒ FirstdataE4Gateway

Create a new FirstdataE4Gateway

The gateway requires that a valid login and password be passed in the options hash.

Options

  • :login – The EXACT ID. Also known as the Gateway ID.

    (Found in your administration terminal settings)
    
  • :password – The terminal password (not your account password)



53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 53

def initialize(options = {})
  requires!(options, :login, :password)
  @options = options

  super
end

Instance Method Details

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



60
61
62
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 60

def authorize(money, credit_card_or_store_authorization, options = {})
  commit(:authorization, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options))
end

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



68
69
70
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 68

def capture(money, authorization, options = {})
  commit(:capture, build_capture_or_credit_request(money, authorization, options))
end

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



64
65
66
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 64

def purchase(money, credit_card_or_store_authorization, options = {})
  commit(:sale, build_sale_or_authorization_request(money, credit_card_or_store_authorization, options))
end

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



76
77
78
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 76

def refund(money, authorization, options = {})
  commit(:credit, build_capture_or_credit_request(money, authorization, options))
end

#scrub(transcript) ⇒ Object



115
116
117
118
119
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 115

def scrub(transcript)
  transcript.
    gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2').
    gsub(%r((<VerificationStr2>).+(</VerificationStr2>)), '\1[FILTERED]\2')
end

#store(credit_card, options = {}) ⇒ Object

Tokenize a credit card with TransArmor

The TransArmor token and other card data necessary for subsequent transactions is stored in the response’s authorization attribute. The authorization string may be passed to authorize and purchase instead of a ActiveMerchant::Billing::CreditCard instance.

TransArmor support must be explicitly activated on your gateway account by FirstData. If your authorization string is empty, contact FirstData support for account setup assistance.

Example

# Generate token
result = gateway.store(credit_card)
if result.success?
  my_record.update_attributes(:authorization => result.authorization)
end

# Use token
result = gateway.purchase(1000, my_record.authorization)

firstdata.zendesk.com/entries/21303361-transarmor-tokenization



107
108
109
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 107

def store(credit_card, options = {})
  commit(:store, build_store_request(credit_card, options), credit_card)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 111

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object



80
81
82
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 80

def verify(credit_card, options = {})
  commit(:verify, build_sale_or_authorization_request(0, credit_card, options))
end

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



72
73
74
# File 'lib/active_merchant/billing/gateways/firstdata_e4.rb', line 72

def void(authorization, options = {})
  commit(:void, build_capture_or_credit_request(money_from_authorization(authorization), authorization, options))
end