Skip to content

Commit

Permalink
Elavon: Remove old Stored Credential method
Browse files Browse the repository at this point in the history
Remote:
40 tests, 178 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
95% passed
  • Loading branch information
Alma Malambo committed Aug 28, 2024
1 parent bbf1738 commit 05a4801
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* MercadoPago: Add idempotency key field [yunnydang] #5229
* Adyen: Update split refund method [yunnydang] #5218
* Adyen: Remove raw_error_message [almalee24] #5202
* Elavon: Remove old Stored Credential method [almalee24] #5219

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
40 changes: 4 additions & 36 deletions lib/active_merchant/billing/gateways/elavon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,8 @@ def add_auth_purchase_params(xml, payment_method, options)
xml.ssl_customer_number options[:customer_number] if options.has_key?(:customer_number)
xml.ssl_entry_mode entry_mode(payment_method, options) if entry_mode(payment_method, options)
add_custom_fields(xml, options) if options[:custom_fields]
if options[:stored_cred_v2]
add_stored_credential_v2(xml, payment_method, options)
add_installment_fields(xml, options)
else
add_stored_credential(xml, options)
end
add_stored_credential(xml, payment_method, options)
add_installment_fields(xml, options)
end

def add_custom_fields(xml, options)
Expand Down Expand Up @@ -368,25 +364,7 @@ def add_line_items(xml, level_3_data)
}
end

def add_stored_credential(xml, options)
return unless options[:stored_credential]

network_transaction_id = options.dig(:stored_credential, :network_transaction_id)
case
when network_transaction_id.nil?
return
when network_transaction_id.to_s.include?('|')
oar_data, ps2000_data = options[:stored_credential][:network_transaction_id].split('|')
xml.ssl_oar_data oar_data unless oar_data.nil? || oar_data.empty?
xml.ssl_ps2000_data ps2000_data unless ps2000_data.nil? || ps2000_data.empty?
when network_transaction_id.to_s.length > 22
xml.ssl_oar_data options.dig(:stored_credential, :network_transaction_id)
else
xml.ssl_ps2000_data options.dig(:stored_credential, :network_transaction_id)
end
end

def add_stored_credential_v2(xml, payment_method, options)
def add_stored_credential(xml, payment_method, options)
return unless options[:stored_credential]

network_transaction_id = options.dig(:stored_credential, :network_transaction_id)
Expand Down Expand Up @@ -416,15 +394,7 @@ def recurring_flag(options)

def merchant_initiated_unscheduled(options)
return options[:merchant_initiated_unscheduled] if options[:merchant_initiated_unscheduled]
return 'Y' if options.dig(:stored_credential, :initiator) == 'merchant' && merchant_reason_type(options)
end

def merchant_reason_type(options)
if options[:stored_cred_v2]
options.dig(:stored_credential, :reason_type) == 'unscheduled'
else
options.dig(:stored_credential, :reason_type) == 'unscheduled' || options.dig(:stored_credential, :reason_type) == 'recurring'
end
return 'Y' if options.dig(:stored_credential, :initiator) == 'merchant' && %w(unscheduled recurring).include?(options.dig(:stored_credential, :reason_type))
end

def add_installment_fields(xml, options)
Expand All @@ -436,8 +406,6 @@ def add_installment_fields(xml, options)

def entry_mode(payment_method, options)
return options[:entry_mode] if options[:entry_mode]
return 12 if options[:stored_credential] && options[:stored_cred_v2] != true

return if payment_method.is_a?(String) || options[:ssl_token]
return 12 if options.dig(:stored_credential, :reason_type) == 'unscheduled'
end
Expand Down
3 changes: 0 additions & 3 deletions test/remote/gateways/remote_elavon_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ def test_authorize_and_successful_void
def test_stored_credentials_with_pass_in_card
# Initial CIT authorize
initial_params = {
stored_cred_v2: true,
stored_credential: {
initial_transaction: true,
reason_type: 'recurring',
Expand Down Expand Up @@ -275,7 +274,6 @@ def test_stored_credentials_with_tokenized_card

# Initial CIT authorize
initial_params = {
stored_cred_v2: true,
stored_credential: {
initial_transaction: true,
reason_type: 'recurring',
Expand Down Expand Up @@ -330,7 +328,6 @@ def test_stored_credentials_with_tokenized_card
def test_stored_credentials_with_manual_token
# Initial CIT get token request
get_token_params = {
stored_cred_v2: true,
add_recurring_token: 'Y',
stored_credential: {
initial_transaction: true,
Expand Down
13 changes: 1 addition & 12 deletions test/unit/gateways/elavon_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def setup

def test_successful_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge!(stored_cred_v2: true))
@gateway.purchase(@amount, @credit_card, @options)
end.check_request do |_endpoint, data, _headers|
assert_match(/<ssl_cvv2cvc2>123<\/ssl_cvv2cvc2>/, data)
end.respond_with(successful_purchase_response)
Expand Down Expand Up @@ -409,7 +409,6 @@ def test_oar_only_network_transaction_id

def test_stored_credential_pass_in_initial_recurring_request
recurring_params = {
stored_cred_v2: true,
stored_credential: {
initial_transaction: true,
reason_type: 'recurring',
Expand All @@ -431,7 +430,6 @@ def test_stored_credential_pass_in_initial_recurring_request

def test_stored_credential_pass_in_recurring_request
recurring_params = {
stored_cred_v2: true,
approval_code: '1234566',
stored_credential: {
reason_type: 'recurring',
Expand All @@ -454,7 +452,6 @@ def test_stored_credential_pass_in_recurring_request

def test_stored_credential_pass_in_installment_request
installment_params = {
stored_cred_v2: true,
installments: '4',
payment_number: '2',
approval_code: '1234566',
Expand All @@ -481,7 +478,6 @@ def test_stored_credential_pass_in_installment_request

def test_stored_credential_pass_in_unscheduled_with_additional_data_request
unscheduled_params = {
stored_cred_v2: true,
approval_code: '1234566',
par_value: '1234567890',
association_token_data: '1',
Expand All @@ -508,7 +504,6 @@ def test_stored_credential_pass_in_unscheduled_with_additional_data_request

def test_stored_credential_tokenized_card_initial_recurring_request
recurring_params = {
stored_cred_v2: true,
stored_credential: {
initial_transaction: true,
reason_type: 'recurring',
Expand All @@ -530,7 +525,6 @@ def test_stored_credential_tokenized_card_initial_recurring_request

def test_stored_credential_tokenized_card_recurring_request
recurring_params = {
stored_cred_v2: true,
stored_credential: {
reason_type: 'recurring',
initiator: 'merchant',
Expand All @@ -551,7 +545,6 @@ def test_stored_credential_tokenized_card_recurring_request

def test_stored_credential_tokenized_card_installment_request
installment_params = {
stored_cred_v2: true,
installments: '4',
payment_number: '2',
stored_credential: {
Expand All @@ -576,7 +569,6 @@ def test_stored_credential_tokenized_card_installment_request

def test_stored_credential_tokenized_card_unscheduled_with_additional_data_request
unscheduled_params = {
stored_cred_v2: true,
par_value: '1234567890',
association_token_data: '1',
stored_credential: {
Expand All @@ -601,7 +593,6 @@ def test_stored_credential_tokenized_card_unscheduled_with_additional_data_reque

def test_stored_credential_manual_token_recurring_request
recurring_params = {
stored_cred_v2: true,
ssl_token: '4421912014039990',
stored_credential: {
reason_type: 'recurring',
Expand All @@ -623,7 +614,6 @@ def test_stored_credential_manual_token_recurring_request

def test_stored_credential_manual_token_installment_request
installment_params = {
stored_cred_v2: true,
ssl_token: '4421912014039990',
installments: '4',
payment_number: '2',
Expand All @@ -649,7 +639,6 @@ def test_stored_credential_manual_token_installment_request

def test_stored_credential_manual_token_unscheduled_with_additional_data_request
unscheduled_params = {
stored_cred_v2: true,
ssl_token: '4421912014039990',
par_value: '1234567890',
association_token_data: '1',
Expand Down

0 comments on commit 05a4801

Please sign in to comment.