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

Paymentez: Read messages on Failure with no error #2850

Merged
merged 1 commit into from
May 18, 2018
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* Realex: Update Country List [nfarve] #2842
* QBMS: Support transcript scrubbing [curiousepic] #2849
* Adyen: Add support for installments [nfarve] #2839
* Paymentez: Read messages on Failure with no error [nfarve] #2850

== Version 1.78.0 (March 29, 2018)
* Litle: Add store for echecks [nfarve] #2779
Expand Down
6 changes: 5 additions & 1 deletion lib/active_merchant/billing/gateways/paymentez.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ def message_from(response)
if success_from(response)
response['transaction'] && response['transaction']['message']
else
response['error'] && response['error']['type']
if response['error']
response['error'] && response['error']['type']
else
response['transaction']['message']
Copy link
Contributor

@curiousepic curiousepic May 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth considering concatenating "transaction_message: error_type" in this case, which we do for some other gateways. Unless we know there is no transaction message if there is an error.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be misunderstanding, but it looks like its one or the other. We get back an error or a transaction.

end
end
end

Expand Down
37 changes: 37 additions & 0 deletions test/unit/gateways/paymentez_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def test_failed_purchase
assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
end

def test_expired_card
@gateway.expects(:ssl_post).returns(expired_card_response)

response = @gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_equal Gateway::STANDARD_ERROR_CODE[:card_declined], response.error_code
assert_equal 'Expired card', response.message
end

def test_successful_authorize
@gateway.stubs(:ssl_post).returns(successful_authorize_response)

Expand Down Expand Up @@ -373,4 +382,32 @@ def failed_store_response
}
)
end

def expired_card_response
%q(
{
"transaction":{
"status":"failure",
"payment_date":null,
"amount":1.0,
"authorization_code":null,
"installments":1,
"dev_reference":"ci123",
"message":"Expired card",
"carrier_code":"54",
"id":"PR-25",
"status_detail":9
},
"card":{
"bin":"528851",
"expiry_year":"2024",
"expiry_month":"4",
"transaction_reference":"PR-25",
"type":"mc",
"number":"9794",
"origin":"Paymentez"
}
}
)
end
end