Skip to content

Commit

Permalink
Revert "Ebanx: Add support for Stored Credentials"
Browse files Browse the repository at this point in the history
This reverts commit b789edf.
  • Loading branch information
Alma Malambo committed Aug 28, 2024
1 parent b789edf commit c37670f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 264 deletions.
1 change: 0 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* Adyen: Remove raw_error_message [almalee24] #5202
* Elavon: Remove old Stored Credential method [almalee24] #5219
* PayTrace: Update MultiResponse for Capture [almalee24] #5203
* Ebanx: Add support for Stored Credentials [almalee24] #5223

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
24 changes: 0 additions & 24 deletions lib/active_merchant/billing/gateways/ebanx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def purchase(money, payment, options = {})
add_address(post, options)
add_customer_responsible_person(post, payment, options)
add_additional_data(post, options)
add_stored_credentials(post, options)

commit(:purchase, post)
end
Expand All @@ -65,7 +64,6 @@ def authorize(money, payment, options = {})
add_address(post, options)
add_customer_responsible_person(post, payment, options)
add_additional_data(post, options)
add_stored_credentials(post, options)
post[:payment][:creditcard][:auto_capture] = false

commit(:authorize, post)
Expand Down Expand Up @@ -170,28 +168,6 @@ def add_customer_responsible_person(post, payment, options)
end
end

def add_stored_credentials(post, options)
return unless (stored_creds = options[:stored_credential])

post[:cof_info] = {
cof_type: stored_creds[:initial_transaction] ? 'initial' : 'stored',
initiator: stored_creds[:initiator] == 'cardholder' ? 'CIT' : 'MIT',
trans_type: add_trans_type(stored_creds),
mandate_id: stored_creds[:network_transaction_id]
}.compact
end

def add_trans_type(options)
case options[:reason_type]
when 'recurring'
'SCHEDULED_RECURRING'
when 'installment'
'INSTALLMENT'
else
options[:initiator] == 'cardholder' ? 'CUSTOMER_COF' : 'MERCHANT_COF'
end
end

def add_address(post, options)
if address = options[:billing_address] || options[:address]
post[:payment][:address] = address[:address1].split[1..-1].join(' ') if address[:address1]
Expand Down
92 changes: 0 additions & 92 deletions test/remote/gateways/remote_ebanx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,96 +344,4 @@ def test_successful_purchase_with_long_order_id
assert_success response
assert_equal 'Accepted', response.message
end

def test_successful_purchase_with_stored_credentials_cardholder_recurring
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'recurring',
network_transaction_id: nil
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_unscheduled
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'unscheduled',
network_transaction_id: nil
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_installment
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'installment',
network_transaction_id: nil
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_installment
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'installment',
network_transaction_id: '1234'
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_unscheduled
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'unscheduled',
network_transaction_id: '1234'
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_recurring
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'recurring',
network_transaction_id: '1234'
}
})
response = @gateway.purchase(@amount, @credit_card, options)

assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_not_initial
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'cardholder',
reason_type: 'unscheduled',
network_transaction_id: '1234'
}
})
response = @gateway.purchase(@amount, @credit_card, options)
assert_success response
end
end
147 changes: 0 additions & 147 deletions test/unit/gateways/ebanx_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,153 +46,6 @@ def test_successful_purchase_with_soft_descriptor
assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_recurring
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'recurring',
network_transaction_id: nil
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"initial\"}, data
assert_match %r{"initiator\":\"CIT\"}, data
assert_match %r{"trans_type\":\"SCHEDULED_RECURRING\"}, data
assert_not_match %r{"mandate_id\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_unscheduled
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'unscheduled',
network_transaction_id: nil
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"initial\"}, data
assert_match %r{"initiator\":\"CIT\"}, data
assert_match %r{"trans_type\":\"CUSTOMER_COF\"}, data
assert_not_match %r{"mandate_id\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_installment
options = @options.merge!({
stored_credential: {
initial_transaction: true,
initiator: 'cardholder',
reason_type: 'installment',
network_transaction_id: nil
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"initial\"}, data
assert_match %r{"initiator\":\"CIT\"}, data
assert_match %r{"trans_type\":\"INSTALLMENT\"}, data
assert_not_match %r{"mandate_id\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_installment
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'installment',
network_transaction_id: '1234'
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"stored\"}, data
assert_match %r{"initiator\":\"MIT\"}, data
assert_match %r{"trans_type\":\"INSTALLMENT\"}, data
assert_match %r{"mandate_id\":\"1234\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_unscheduled
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'unscheduled',
network_transaction_id: '1234'
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"stored\"}, data
assert_match %r{"initiator\":\"MIT\"}, data
assert_match %r{"trans_type\":\"MERCHANT_COF\"}, data
assert_match %r{"mandate_id\":\"1234\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_merchant_recurring
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'merchant',
reason_type: 'recurring',
network_transaction_id: '1234'
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"stored\"}, data
assert_match %r{"initiator\":\"MIT\"}, data
assert_match %r{"trans_type\":\"SCHEDULED_RECURRING\"}, data
assert_match %r{"mandate_id\":\"1234\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_successful_purchase_with_stored_credentials_cardholder_not_initial
options = @options.merge!({
stored_credential: {
initial_transaction: false,
initiator: 'cardholder',
reason_type: 'unscheduled',
network_transaction_id: '1234'
}
})
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match %r{"cof_type\":\"stored\"}, data
assert_match %r{"initiator\":\"CIT\"}, data
assert_match %r{"trans_type\":\"CUSTOMER_COF\"}, data
assert_match %r{"mandate_id\":\"1234\"}, data
end.respond_with(successful_purchase_response)

assert_success response
end

def test_failed_purchase
@gateway.expects(:ssl_request).returns(failed_purchase_response)

Expand Down

0 comments on commit c37670f

Please sign in to comment.