Skip to content

Commit

Permalink
FirstData Payeezy: Set default ECI value for auth/purchase transactions
Browse files Browse the repository at this point in the history
I've heard from a few users that this gateway (and/or their processors
behind it) are now soft-requiring the ECI indicator to always be set.
Typical of this gateway, [documentation is unclear at
best](https://support.payeezy.com/hc/en-us/articles/206601408-First-Data-Payeezy-Gateway-Web-Service-API-Reference-Guide).

I've done this in such a way that all previous cases were accounted for,
and a 3DS/network transaction's embedded value will always take
precedence.

Closes #2448
  • Loading branch information
jasonwebster committed Jun 8, 2017
1 parent ccfc678 commit b70159a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Ebanx: Reduce supported countries to Brazil and Mexico [davidsantoso]
* Payeezy: Add customer_id_type and customer_id_number fields [davidsantoso] #2454
* Payeezy: Add client_email field for telecheck [davidsantoso] #2455
* FirstData Payeezy: Set default ECI value for auth/purchase transactions [jasonwebster] #2448

== Version 1.66.0 (May 4, 2017)
* Support Rails 5.1 [jhawthorn] #2407
Expand Down
8 changes: 5 additions & 3 deletions lib/active_merchant/billing/gateways/firstdata_e4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class FirstdataE4Gateway < Gateway

E4_BRANDS = BRANDS.merge({:mastercard => "Mastercard"})

DEFAULT_ECI = "07"

self.supported_cardtypes = BRANDS.keys
self.supported_countries = ["CA", "US"]
self.default_currency = "USD"
Expand Down Expand Up @@ -235,6 +237,9 @@ def add_credit_card(xml, credit_card, options)
xml.tag! "CardHoldersName", credit_card.name
xml.tag! "CardType", card_type(credit_card.brand)

eci = (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
xml.tag! "Ecommerce_Flag", eci

add_credit_card_verification_strings(xml, credit_card, options)
end
end
Expand All @@ -256,8 +261,6 @@ def add_credit_card_verification_strings(xml, credit_card, options)
end

def add_network_tokenization_credit_card(xml, credit_card)
xml.tag!("Ecommerce_Flag", credit_card.eci)

case card_brand(credit_card).to_sym
when :visa
xml.tag!("XID", credit_card.transaction_id) if credit_card.transaction_id
Expand All @@ -275,7 +278,6 @@ def add_network_tokenization_credit_card(xml, credit_card)
def add_card_authentication_data(xml, options)
xml.tag! "CAVV", options[:cavv]
xml.tag! "XID", options[:xid]
xml.tag! "Ecommerce_Flag", options[:eci]
end

def add_credit_card_token(xml, store_authorization)
Expand Down
16 changes: 16 additions & 0 deletions test/unit/gateways/firstdata_e4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ def test_customer_ref_is_sent
end.respond_with(successful_purchase_response)
end

def test_eci_default_value
stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |endpoint, data, headers|
assert_match "<Ecommerce_Flag>07</Ecommerce_Flag>", data
end.respond_with(successful_purchase_response)
end

def test_eci_option_value
stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(eci: "05"))
end.check_request do |endpoint, data, headers|
assert_match "<Ecommerce_Flag>05</Ecommerce_Flag>", data
end.respond_with(successful_purchase_response)
end

def test_network_tokenization_requests_with_visa
stub_comms do
credit_card = network_tokenization_credit_card('4111111111111111',
Expand Down

0 comments on commit b70159a

Please sign in to comment.