From 27e1494955ff0969689cd39e0ad3026b3d546869 Mon Sep 17 00:00:00 2001 From: Benjamin Eckel Date: Mon, 14 May 2018 13:35:48 -0500 Subject: [PATCH 1/2] Bump API version 2.12 --- recurly/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recurly/__init__.py b/recurly/__init__.py index 6b889d40..7b81f9f2 100644 --- a/recurly/__init__.py +++ b/recurly/__init__.py @@ -41,7 +41,7 @@ API_KEY = None """The API key to use when authenticating API requests.""" -API_VERSION = '2.11' +API_VERSION = '2.12' """The API version to use when making API requests.""" CA_CERTS_FILE = None From ca34f50f64614d4a2604d4b4c1a5936874c5e44d Mon Sep 17 00:00:00 2001 From: Benjamin Eckel Date: Mon, 14 May 2018 14:31:20 -0500 Subject: [PATCH 2/2] Add pending method for purchases --- recurly/__init__.py | 11 ++ tests/fixtures/purchase/pending.xml | 166 ++++++++++++++++++++++++++++ tests/test_resources.py | 6 + 3 files changed, 183 insertions(+) create mode 100644 tests/fixtures/purchase/pending.xml diff --git a/recurly/__init__.py b/recurly/__init__.py index 7b81f9f2..b139bf26 100644 --- a/recurly/__init__.py +++ b/recurly/__init__.py @@ -909,6 +909,17 @@ def authorize(self): url = recurly.base_uri() + self.collection_path + '/authorize' return self.__invoice(url) + def pending(self): + """ + Use for Adyen HPP transaction requests. Runs validations + but does not run any transactions. + + Returns: + InvoiceCollection: The authorized collection of invoices + """ + url = recurly.base_uri() + self.collection_path + '/pending' + return self.__invoice(url) + def __invoice(self, url): # We must null out currency in subscriptions and adjustments # TODO we should deprecate and remove default currency support diff --git a/tests/fixtures/purchase/pending.xml b/tests/fixtures/purchase/pending.xml new file mode 100644 index 00000000..681963d0 --- /dev/null +++ b/tests/fixtures/purchase/pending.xml @@ -0,0 +1,166 @@ +POST https://api.recurly.com/v2/purchases/pending HTTP/1.1 +X-Api-Version: {api-version} +Accept: application/xml +Authorization: Basic YXBpa2V5Og== +User-Agent: {user-agent} +Content-Type: application/xml; charset=utf-8 + + + + + testmock + benjamin.dumonde@example.com + + + 123 Main St + New Orleans + US + Verena + Example + Work + LA + 70114 + + + + Verena + Example + 4111-1111-1111-1111 + 123 + 2020 + 11 + 123 Main St + New Orleans + LA + 70114 + US + USD + adyen + + + + + Item 1 + 1 + 1000 + + + Item 2 + 2 + 2000 + + + USD + + + gold + + + + +HTTP/1.1 200 OK +Content-Type: application/xml; charset=utf-8 +Location: https://api.recurly.com/v2/invoices/1021 + + + + + +
+ 123 Main St + + New Orleans + LA + 70114 + US + +
+ 40625fd700c1c2d90060744092b4a1b1 + pending + + + + + 6000 + 0 + 6000 + 6000 + USD + + + 2017-10-06T21:25:55Z + + + + + 0 + automatic + + + + 40625fd6fc46181e2f15044db38c1c82 + pending + gold + + gold + plan + 1000 + 1 + 0 + 0 + 1000 + USD + false + 2017-10-06T21:25:55Z + 2017-11-06T21:25:55Z + + + evenly + + + + 40625fd6e6a5817b59a2174b72a92fea + pending + Item 1 + + + debit + 1000 + 1 + 0 + 0 + 1000 + USD + false + 2017-10-06T21:25:55Z + + + + + + + + 40625fd6e9096c9922b52646e29f6d5e + pending + Item 2 + + + debit + 2000 + 2 + 0 + 0 + 4000 + USD + false + 2017-10-06T21:25:55Z + + + + + + + + +
+
diff --git a/tests/test_resources.py b/tests/test_resources.py index 95b3c477..21b7bfab 100644 --- a/tests/test_resources.py +++ b/tests/test_resources.py @@ -121,6 +121,12 @@ def test_purchase(self): collection = purchase.authorize() self.assertIsInstance(collection, InvoiceCollection) self.assertIsInstance(collection.charge_invoice, Invoice) + with self.mock_request('purchase/pending.xml'): + purchase.account.email = 'benjamin.dumonde@example.com' + purchase.account.billing_info.external_hpp_type = 'adyen' + collection = purchase.pending() + self.assertIsInstance(collection, InvoiceCollection) + self.assertIsInstance(collection.charge_invoice, Invoice) def test_account(self): account_code = 'test%s' % self.test_id