mirror of
https://github.com/retailcrm/api-client-python.git
synced 2024-11-25 14:36:04 +03:00
Merge pull request #17 from gwinn/master
fixes #14 issue with payment_edit method
This commit is contained in:
commit
41084fd4be
@ -1 +0,0 @@
|
|||||||
3.7.3
|
|
@ -476,7 +476,7 @@ class Client(Base):
|
|||||||
|
|
||||||
return self.post('/orders/payments/' + str(uid) + '/delete')
|
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 payment: object
|
||||||
:param uid_type: string
|
:param uid_type: string
|
||||||
@ -484,13 +484,10 @@ class Client(Base):
|
|||||||
:return: Response
|
:return: Response
|
||||||
"""
|
"""
|
||||||
self.parameters['payment'] = json.dumps(payment)
|
self.parameters['payment'] = json.dumps(payment)
|
||||||
|
self.parameters['by'] = uid_type
|
||||||
if site is not None:
|
if site is not None:
|
||||||
self.parameters['site'] = site
|
self.parameters['site'] = site
|
||||||
|
|
||||||
if uid_type != 'externalId':
|
|
||||||
self.parameters['by'] = uid_type
|
|
||||||
|
|
||||||
return self.post('/orders/payments/' + str(payment[uid_type]) + '/edit')
|
return self.post('/orders/payments/' + str(payment[uid_type]) + '/edit')
|
||||||
|
|
||||||
def orders_statuses(self, ids, external_ids):
|
def orders_statuses(self, ids, external_ids):
|
||||||
|
1
setup.py
1
setup.py
@ -37,6 +37,7 @@ setup(
|
|||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
'Programming Language :: Python :: 3.5',
|
'Programming Language :: Python :: 3.5',
|
||||||
'Programming Language :: Python :: 3.6',
|
'Programming Language :: Python :: 3.6',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
'Programming Language :: Python :: 3 :: Only',
|
'Programming Language :: Python :: 3 :: Only',
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
]
|
]
|
||||||
|
@ -7,6 +7,7 @@ retailCRM API client v5 tests
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import retailcrm
|
import retailcrm
|
||||||
|
|
||||||
|
|
||||||
@ -72,3 +73,43 @@ class TestVersion5(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(response.is_successful(), True)
|
self.assertTrue(response.is_successful(), True)
|
||||||
self.assertTrue(response.get_status_code() < 400, 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)
|
||||||
|
Loading…
Reference in New Issue
Block a user