Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 recurly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,7 @@ class TransactionError(recurly.Resource):
'customer_message',
'error_code',
'gateway_error_code',
'decline_code'
)

class TransactionFraudInfo(recurly.Resource):
Expand Down
7 changes: 7 additions & 0 deletions recurly/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def three_d_secure_action_token_id(self):
if el is not None:
return el.text

@property
def decline_code(self):
"""Decline code from the issuer"""
el = self.response_doc.find('decline_code')
if el is not None:
return el.text


class ValidationError(ClientError):

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/transaction/declined-transaction.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ Content-Type: application/xml; charset=utf-8
<customer_message lang="en-US">The transaction was declined due to insufficient funds in your account. Please use a different card or contact your bank.</customer_message>
<merchant_message lang="en-US">The card has insufficient funds to cover the cost of the transaction.</merchant_message>
<gateway_error_code>123</gateway_error_code>
<decline_code>insufficient_funds</decline_code>
</transaction_error>
</errors>
1 change: 1 addition & 0 deletions tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,7 @@ def failed_transaction(self):
self.assertEqual(transaction.customer_message, 'The transaction was declined due to insufficient funds in your account. Please use a different card or contact your bank.')
self.assertEqual(transaction.merchant_message, 'The card has insufficient funds to cover the cost of the transaction.')
self.assertEqual(transaction.gateway_error_code, '123')
self.assertEqual(transaction.decline_code, 'insufficient_funds')


def test_transaction_with_balance(self):
Expand Down
1 change: 1 addition & 0 deletions tests/tests_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_transaction_error_property(self):
self.assertEqual(transaction_error.customer_message, "The transaction was declined due to insufficient funds in your account. Please use a different card or contact your bank.")
self.assertEqual(transaction_error.merchant_message, "The card has insufficient funds to cover the cost of the transaction.")
self.assertEqual(transaction_error.gateway_error_code, "123")
self.assertEqual(transaction.decline_code, 'insufficient_funds')

def test_transaction_error_code_property(self):
""" Test ValidationError class 'transaction_error_code' property"""
Expand Down