Skip to content

Commit

Permalink
WorldPay: Update xml tag for Credit Cards
Browse files Browse the repository at this point in the history
Update the xml tag for Credit Cards to be CARD-SSL
instead of being specific to card brand.

Remote:
100 tests, 416 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Unit:
109 tests, 637 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
Alma Malambo committed Jul 6, 2023
1 parent 3c34a61 commit 2566c8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
21 changes: 1 addition & 20 deletions lib/active_merchant/billing/gateways/worldpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ class WorldpayGateway < Gateway
network_token: 'NETWORKTOKEN'
}

CARD_CODES = {
'visa' => 'VISA-SSL',
'master' => 'ECMC-SSL',
'discover' => 'DISCOVER-SSL',
'american_express' => 'AMEX-SSL',
'jcb' => 'JCB-SSL',
'maestro' => 'MAESTRO-SSL',
'diners_club' => 'DINERS-SSL',
'elo' => 'ELO-SSL',
'naranja' => 'NARANJA-SSL',
'cabal' => 'CABAL-SSL',
'unionpay' => 'CHINAUNIONPAY-SSL',
'unknown' => 'CARD-SSL'
}

AVS_CODE_MAP = {
'A' => 'M', # Match
'B' => 'P', # Postcode matches, address not verified
Expand Down Expand Up @@ -646,7 +631,7 @@ def add_token_details(xml, options)
end

def add_card_details(xml, payment_method, options)
xml.tag! card_code_for(payment_method) do
xml.tag! 'CARD-SSL' do
add_card(xml, payment_method, options)
end
end
Expand Down Expand Up @@ -1034,10 +1019,6 @@ def currency_exponent(currency)
return 2
end

def card_code_for(payment_method)
CARD_CODES[card_brand(payment_method)] || CARD_CODES['unknown']
end

def eligible_for_0_auth?(payment_method, options = {})
payment_method.is_a?(CreditCard) && %w(visa master).include?(payment_method.brand) && options[:zero_dollar_auth]
end
Expand Down
16 changes: 8 additions & 8 deletions test/unit/gateways/worldpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_successful_authorize_without_name
end.check_request do |_endpoint, data, _headers|
assert_match(/4242424242424242/, data)
assert_no_match(/cardHolderName/, data)
assert_match(/VISA-SSL/, data)
assert_match(/CARD-SSL/, data)
end.respond_with(successful_authorize_response)
assert_success response
assert_equal 'R50704213207145707', response.authorization
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def test_successful_store
assert_match %r(4242424242424242), data
assert_no_match %r(<order>), data
assert_no_match %r(<paymentDetails>), data
assert_no_match %r(<VISA-SSL>), data
assert_no_match %r(<CARD-SSL>), data
end.respond_with(successful_store_response)

assert_success response
Expand Down Expand Up @@ -2136,7 +2136,7 @@ def sample_authorization_request
<amount value="100" exponent="2" currencyCode="HKD"/>
<orderContent>Products Products Products</orderContent>
<paymentDetails>
<VISA-SSL>
<CARD-SSL>
<cardNumber>4242424242424242</cardNumber>
<expiryDate>
<date month="09" year="2011"/>
Expand All @@ -2156,7 +2156,7 @@ def sample_authorization_request
<telephoneNumber>(555)555-5555</telephoneNumber>
</address>
</cardAddress>
</VISA-SSL>
</CARD-SSL>
<session id="asfasfasfasdgvsdzvxzcvsd" shopperIPAddress="127.0.0.1"/>
</paymentDetails>
<shopper>
Expand All @@ -2179,7 +2179,7 @@ def transcript
<description>Purchase</description>
<amount value="100" currencyCode="GBP" exponent="2"/>
<paymentDetails>
<VISA-SSL>
<CARD-SSL>
<cardNumber>4111111111111111</cardNumber>
<expiryDate>
<date month="09" year="2016"/>
Expand All @@ -2195,7 +2195,7 @@ def transcript
<countryCode>US</countryCode>
</address>
</cardAddress>
</VISA-SSL>
</CARD-SSL>
</paymentDetails>
<shopper>
<shopperEmailAddress>[email protected]</shopperEmailAddress>
Expand All @@ -2214,7 +2214,7 @@ def scrubbed_transcript
<description>Purchase</description>
<amount value="100" currencyCode="GBP" exponent="2"/>
<paymentDetails>
<VISA-SSL>
<CARD-SSL>
<cardNumber>[FILTERED]</cardNumber>
<expiryDate>
<date month="09" year="2016"/>
Expand All @@ -2230,7 +2230,7 @@ def scrubbed_transcript
<countryCode>US</countryCode>
</address>
</cardAddress>
</VISA-SSL>
</CARD-SSL>
</paymentDetails>
<shopper>
<shopperEmailAddress>[email protected]</shopperEmailAddress>
Expand Down

0 comments on commit 2566c8b

Please sign in to comment.