Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirstdataE4: Update handling 503 Service Unavailable error code #4861

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/active_merchant/billing/gateways/firstdata_e4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,12 @@ def message_from(response)
end

def parse_error(error)
error_body = error.code == 503 ? error.message : error.body
{
transaction_approved: 'false',
error_number: error.code,
error_description: error.body,
ecommerce_error_code: error.body.gsub(/[^\d]/, '')
error_description: error_body,
ecommerce_error_code: error_body.gsub(/[^\d]/, '')
}
end

Expand Down
5 changes: 3 additions & 2 deletions lib/active_merchant/billing/gateways/firstdata_e4_v27.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,12 @@ def message_from(response)
end

def parse_error(error)
error_body = error.code == 503 ? error.message : error.body
{
transaction_approved: 'false',
error_number: error.code,
error_description: error.body,
ecommerce_error_code: error.body.gsub(/[^\d]/, '')
error_description: error_body,
ecommerce_error_code: error_body.gsub(/[^\d]/, '')
}
end

Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/firstdata_e4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ def test_failed_purchase
assert_equal response.error_code, 'invalid_expiry_date'
end

def test_failed_purchase_with_error_code_503
@gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.1, 503, 'Service Unavailable'))

assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_failure response
assert_equal response.error_code, nil
assert_equal response.message, 'Service Unavailable'
end

def test_successful_verify
response = stub_comms do
@gateway.verify(@credit_card)
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/firstdata_e4_v27_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ def test_failed_purchase
assert_equal response.error_code, 'invalid_expiry_date'
end

def test_failed_purchase_with_error_code_503
@gateway.expects(:raw_ssl_request).returns(Net::HTTPBadRequest.new(1.1, 503, 'Service Unavailable'))

assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_failure response
assert_equal response.error_code, nil
assert_equal response.message, 'Service Unavailable'
end

def test_successful_verify
response = stub_comms do
@gateway.verify(@credit_card)
Expand Down
Loading