How to use the recurly.ValidationError function in recurly

To help you get started, we’ve selected a few recurly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github recurly / recurly-client-python / tests / tests_errors.py View on Github external
def test_transaction_error_property(self):
        """ Test ValidationError class 'transaction_error' property"""
        transaction = Transaction(
            amount_in_cents=1000,
            currency='USD',
            account=Account(
                account_code='transactionmock'
            )
        )

        # Mock 'save transaction' request to throw declined
        # transaction validation error
        with self.mock_request('transaction/declined-transaction.xml'):
            try:
                transaction.save()
            except ValidationError as e:
                error = e

        transaction_error = error.transaction_error

        self.assertEqual(transaction_error.error_code, 'insufficient_funds')
        self.assertEqual(transaction_error.error_category, 'soft')
        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")
github recurly / recurly-client-python / tests / tests_errors.py View on Github external
def test_validationerror_printable(self):
        """ Make sure __str__/__unicode__ works correctly in Python 2/3"""
        error = recurly.ValidationError.Suberror('field', 'symbol', 'message')
        suberrors = dict()
        suberrors['field'] = error
        validation_error = recurly.ValidationError('')
        validation_error.__dict__['errors'] = suberrors
        str(validation_error)
github recurly / recurly-client-python / tests / tests_errors.py View on Github external
def test_validationerror_printable(self):
        """ Make sure __str__/__unicode__ works correctly in Python 2/3"""
        error = recurly.ValidationError.Suberror('field', 'symbol', 'message')
        suberrors = dict()
        suberrors['field'] = error
        validation_error = recurly.ValidationError('')
        validation_error.__dict__['errors'] = suberrors
        str(validation_error)