diff --git a/.python-version b/.python-version deleted file mode 100644 index c1e43e6..0000000 --- a/.python-version +++ /dev/null @@ -1 +0,0 @@ -3.7.3 diff --git a/retailcrm/versions/v5.py b/retailcrm/versions/v5.py index 1749436..e7d7f47 100644 --- a/retailcrm/versions/v5.py +++ b/retailcrm/versions/v5.py @@ -476,7 +476,7 @@ class Client(Base): return self.post('/orders/payments/' + str(uid) + '/delete') - def order_payment_edit(self, payment, uid_type='externalId', site=None): + def order_payment_edit(self, payment, uid_type='id', site=None): """ :param payment: object :param uid_type: string @@ -484,13 +484,10 @@ class Client(Base): :return: Response """ self.parameters['payment'] = json.dumps(payment) - + self.parameters['by'] = uid_type if site is not None: self.parameters['site'] = site - if uid_type != 'externalId': - self.parameters['by'] = uid_type - return self.post('/orders/payments/' + str(payment[uid_type]) + '/edit') def orders_statuses(self, ids, external_ids): diff --git a/setup.py b/setup.py index 6d42008..43fc55f 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,7 @@ setup( 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3 :: Only', 'Topic :: Software Development :: Libraries :: Python Modules', ] diff --git a/tests/v5_tests.py b/tests/v5_tests.py index 03eef87..4badebf 100644 --- a/tests/v5_tests.py +++ b/tests/v5_tests.py @@ -7,6 +7,7 @@ retailCRM API client v5 tests import unittest import os +import random import retailcrm @@ -72,3 +73,43 @@ class TestVersion5(unittest.TestCase): self.assertTrue(response.is_successful(), True) self.assertTrue(response.get_status_code() < 400, True) + + def test_check_order_payment(self): + rand = random.randint(10000, 99999) + ex_id = 'test-case-payment' + str(rand) + order = { + 'firstName': 'John', + 'lastName': 'Doe', + 'phone': '+79000000000', + 'email': 'john@example.com', + 'orderMethod': 'call-request', + 'delivery': { + 'code': 'self-delivery' + }, + 'payments': [ + { + 'externalId': ex_id, + 'amount': 100, + 'type': 'cash' + } + ] + } + + response = self.client.order_create(order) + + response_data = response.get_response() + payment_id = response_data['order']['payments'][0]['id'] + print(payment_id) + + self.assertTrue(response.is_successful(), True) + self.assertTrue(response.get_status_code() < 400, True) + + payment_response = self.client.order_payment_edit({'externalId': ex_id, 'status': 'invoice'}, 'externalId') + + self.assertTrue(payment_response.is_successful(), True) + self.assertTrue(payment_response.get_status_code() < 400, True) + + payment_response = self.client.order_payment_edit({'id': payment_id, 'status': 'paid'}) + + self.assertTrue(payment_response.is_successful(), True) + self.assertTrue(payment_response.get_status_code() < 400, True)