How to use recurly - 10 common examples

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 / test_recurly.py View on Github external
def test_xml(self):
        import recurly
        account = recurly.Account()
        account.username = 'importantbreakfast'
        account_xml = ElementTree.tostring(account.to_element(), encoding='UTF-8')
        self.assertEqual(account_xml, xml('importantbreakfast'))
github recurly / recurly-client-python / tests / tests_errors.py View on Github external
def test_unexpected_errors_thrown(self):
        """ Test UnexpectedClientError class """
        transaction = Transaction(
            amount_in_cents=1000,
            currency='USD',
            account=Account(
                account_code='transactionmock'
            )
        )

        # Mock 'save transaction' request to throw unexpected client error
        with self.mock_request('transaction/error-teapot.xml'):
            try:
                transaction.save()
            except UnexpectedStatusError as e:
                error = e

        self.assertIsInstance(error, UnexpectedClientError)

        # Mock 'save transaction' request to throw another unexpected client error
        with self.mock_request('transaction/error-client.xml'):
            try:
github recurly / recurly-client-python / tests / test_js.py View on Github external
def test_sign(self):
        self.assertTrue(re.search('nonce=', recurly.js.sign()))
        self.assertTrue(re.search('timestamp=', recurly.js.sign()))
        self.assertEqual(
            recurly.js.sign({'timestamp': 1312701386, 'nonce': 1}),
            '015662c92688f387159bcac9bc1fb250a1327886|nonce=1&timestamp=1312701386'
        )
        self.assertEqual(
            recurly.js.sign(recurly.Account(account_code='1'), {'timestamp': 1312701386, 'nonce': 1}),
            '82bcbbd4deb8b1b663b7407d9085dc67e2922df7|account%5Baccount_code%5D=1&nonce=1&timestamp=1312701386'
        )
github recurly / recurly-client-python / tests / tests_errors.py View on Github external
def test_transaction_error_code_property(self):
        """ Test ValidationError class 'transaction_error_code' 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

        self.assertEqual(error.transaction_error_code, 'insufficient_funds')
github recurly / recurly-client-python / tests / test_recurly.py View on Github external
active
            2
            2000
            2009-11-22T13:10:38-08:00
            
            
            2009-11-22T13:10:38-08:00
            2009-11-29T13:10:38-08:00
            2009-11-22T13:10:38-08:00
            2009-11-29T13:10:38-08:00
          
        """)
        self.assertEqual(objs['type'], 'new_subscription_notification')
        self.assertTrue('account' in objs)
        self.assertTrue(isinstance(objs['account'], recurly.Account))
        self.assertEqual(objs['account'].username, 'verena')
        self.assertTrue('subscription' in objs)
        self.assertTrue(isinstance(objs['subscription'], recurly.Subscription))
        self.assertEqual(objs['subscription'].state, 'active')
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')
github recurly / recurly-client-python / tests / test_resource.py View on Github external
def cast(obj, class_name=None, resp=None):
    return Resource.cast_json(obj, class_name, resp)
github recurly / recurly-client-python / tests / mock_resources.py View on Github external
"my_bool": bool,
        "my_datetime": datetime,
        "my_sub_resource": "MySubResource",
        "my_sub_resources": ["MySubResource"],
    }


class MySubResource(Resource):
    schema = {"object": str, "my_string": str}


class Error(Resource):
    schema = {"object": str, "message": str, "params": list, "type": str}


class Empty(Resource):
    schema = {}
github recurly / recurly-client-python / tests / mock_resources.py View on Github external
from recurly import Resource
import datetime


class MyResource(Resource):
    schema = {
        "object": str,
        "my_string": str,
        "my_int": int,
        "my_float": float,
        "my_bool": bool,
        "my_datetime": datetime,
        "my_sub_resource": "MySubResource",
        "my_sub_resources": ["MySubResource"],
    }


class MySubResource(Resource):
    schema = {"object": str, "my_string": str}
github recurly / recurly-client-python / tests / mock_resources.py View on Github external
"object": str,
        "my_string": str,
        "my_int": int,
        "my_float": float,
        "my_bool": bool,
        "my_datetime": datetime,
        "my_sub_resource": "MySubResource",
        "my_sub_resources": ["MySubResource"],
    }


class MySubResource(Resource):
    schema = {"object": str, "my_string": str}


class Error(Resource):
    schema = {"object": str, "message": str, "params": list, "type": str}


class Empty(Resource):
    schema = {}