Class: ActiveMerchant::Billing::FirstdataE4V27Gateway

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

Constant Summary collapse

TRANSACTIONS =
{
  sale:          '00',
  authorization: '01',
  verify:        '05',
  capture:       '32',
  void:          '33',
  credit:        '34',
  store:         '05'
}
SUCCESS =
'true'
SENSITIVE_FIELDS =
%i[cvdcode expiry_date card_number]
BRANDS =
{
  visa: 'Visa',
  master: 'Mastercard',
  american_express: 'American Express',
  jcb: 'JCB',
  discover: 'Discover'
}
DEFAULT_ECI =
'07'
STANDARD_ERROR_CODE_MAPPING =
{
  # Bank error codes: https://support.payeezy.com/hc/en-us/articles/203730509-First-Data-Global-Gateway-e4-Bank-Response-Codes
  '201' => STANDARD_ERROR_CODE[:incorrect_number],
  '531' => STANDARD_ERROR_CODE[:invalid_cvc],
  '503' => STANDARD_ERROR_CODE[:invalid_cvc],
  '811' => STANDARD_ERROR_CODE[:invalid_cvc],
  '605' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  '522' => STANDARD_ERROR_CODE[:expired_card],
  '303' => STANDARD_ERROR_CODE[:card_declined],
  '530' => STANDARD_ERROR_CODE[:card_declined],
  '401' => STANDARD_ERROR_CODE[:call_issuer],
  '402' => STANDARD_ERROR_CODE[:call_issuer],
  '501' => STANDARD_ERROR_CODE[:pickup_card],
  # Ecommerce error codes: https://support.payeezy.com/hc/en-us/articles/203730499-eCommerce-Response-Codes-ETG-e4-Transaction-Gateway-Codes
  '22' => STANDARD_ERROR_CODE[:invalid_number],
  '25' => STANDARD_ERROR_CODE[:invalid_expiry_date],
  '31' => STANDARD_ERROR_CODE[:incorrect_cvc],
  '44' => STANDARD_ERROR_CODE[:incorrect_zip],
  '42' => STANDARD_ERROR_CODE[:processing_error]
}

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, #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 = {}) ⇒ FirstdataE4V27Gateway

Returns a new instance of FirstdataE4V27Gateway.



58
59
60
61
62
63
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 58

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

  super
end

Instance Method Details

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



65
66
67
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 65

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



73
74
75
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 73

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



69
70
71
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 69

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



81
82
83
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 81

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

#scrub(transcript) ⇒ Object



114
115
116
117
118
119
120
121
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 114

def scrub(transcript)
  transcript.
    gsub(%r((<Card_Number>).+(</Card_Number>)), '\1[FILTERED]\2').
    gsub(%r((<CVDCode>).+(</CVDCode>)), '\1[FILTERED]\2').
    gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
    gsub(%r((<CAVV>).+(</CAVV>)), '\1[FILTERED]\2').
    gsub(%r((CARD NUMBER\s+: )#+\d+), '\1[FILTERED]')
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.

support.payeezy.com/hc/en-us/articles/203731189-TransArmor-Tokenization



101
102
103
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 101

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

#supports_network_tokenization?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 123

def supports_network_tokenization?
  true
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 110

def supports_scrubbing?
  true
end

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



85
86
87
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 85

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

#verify_credentialsObject



105
106
107
108
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 105

def verify_credentials
  response = void('0')
  response.message != 'Unauthorized Request. Bad or missing credentials.'
end

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



77
78
79
# File 'lib/active_merchant/billing/gateways/firstdata_e4_v27.rb', line 77

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