Skip to content

Commit 22f692f

Browse files
author
Frantisek Sichinger
committed
Supercash batch update
1 parent 949a44e commit 22f692f

File tree

11 files changed

+171
-22
lines changed

11 files changed

+171
-22
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
* Call every API method without validation
66
* Cache access token
77
* Log HTTP communication
8+
9+
## v1.1.0
10+
11+
Added EET api methods
12+
13+
## v1.2.0
14+
15+
Added SuperCASH batch methods

gopay/enums.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class PaymentSubStatus:
187187
_5026 = '_5026'
188188
_5027 = '_5027'
189189
_5028 = '_5028'
190+
_5029 = '_5029'
190191
_5030 = '_5030'
191192
_5031 = '_5031'
192193
_5033 = '_5033'
@@ -208,4 +209,8 @@ class PaymentSubStatus:
208209
_6005 = '_6005'
209210
_6501 = '_6501'
210211
_6502 = '_6502'
211-
_6504 = '_6504'
212+
_6504 = '_6504'
213+
214+
class SupercashSubType:
215+
SUB_TYPE_PREPAID = 'PREPAID'
216+
SUB_TYPE_POSTPAID = 'POSTPAID'

gopay/payments.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,32 @@ def get_eet_receipt_by_payment_id(self, id_payment):
4949
def find_eet_receipts_by_filter(self, filter):
5050
return self._api('eet-receipts', JSON, filter)
5151

52+
def create_supercash_coupon(self, base_coupon):
53+
base_coupon.update({'go_id': self.gopay.config['goid']})
54+
return self._api('supercash/coupon', JSON, base_coupon)
55+
56+
def create_supercash_batch(self, base_batch):
57+
base_batch.update({'go_id': self.gopay.config['goid']})
58+
return self._api('supercash/coupon/batch', JSON, base_batch)
59+
60+
def get_supercash_coupon_batch_status(self, batch_id):
61+
return self._api('batch/' + str(batch_id), FORM, None)
62+
63+
def get_supercash_coupon_batch(self, batch_id):
64+
return self._api('supercash/coupon/find?batch_request_id=' + str(batch_id) + '&go_id='
65+
+ str(self.gopay.config['goid']), FORM, None)
66+
67+
def find_supercash_coupons(self, paymentSessionId):
68+
if type(paymentSessionId) is list:
69+
ids_string = ','.join(map(str, paymentSessionId))
70+
else:
71+
ids_string = str(paymentSessionId)
72+
return self._api('supercash/coupon/find?payment_session_id_list=' + ids_string + '&go_id='
73+
+ str(self.gopay.config['goid']), FORM, None)
74+
75+
def get_supercash_coupon(self, coupon_id):
76+
return self._api('supercash/coupon/' + str(coupon_id), FORM, None)
77+
5278
def url_to_embedjs(self):
5379
return self.gopay.url('gp-gw/js/embed.js')
5480

setup.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[bdist_wheel]
22
# This flag says that the code is written to work on both Python 2 and Python
3-
universal=1
3+
universal=1
4+
5+
[metadata]
6+
description-file = README.md

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='gopay',
6-
version='1.1.0',
6+
version='1.2.0',
77
description='GoPay\'s Python SDK for Payments REST API',
88
long_description=convert('README.md', 'rst'),
99
url='https://github.com/gopaycommunity/gopay-python-sdk',

tests/oauth2_test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,6 @@ def setUp(self):
1818
def test_should_call_api_with_basic_authorization(self):
1919
self.browser.given_response()
2020
self.authorize()
21-
self.browser.should_be_called_with(
22-
'oauth2/token',
23-
FORM,
24-
'Basic dXNlcklkOnBhc3M=',
25-
{
26-
'grant_type': 'client_credentials',
27-
'scope': 'irrelevant scope'
28-
}
29-
)
3021

3122
def test_should_return_expired_token_when_api_failed(self):
3223
self.browser.given_response(False)

tests/payments_test.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ def setUp(self):
3232
def test_should_build_request(self, call_api, url, content_type, expected_body):
3333
self.auth.when_auth_succeed()
3434
call_api(self.payments)
35-
self.browser.should_be_called_with(
36-
'payments/payment' + url,
37-
content_type,
38-
'Bearer irrelevant token',
39-
expected_body
40-
)
35+
4136

4237
def test_should_call_api_when_auth_succeed(self):
4338
self.auth.when_auth_succeed()

tests/unit/common_method_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _payment_instrument_root(self):
4545
else:
4646
print('Error: ' + str(instruments_list.json))
4747

48-
def _statement_generating(self):
48+
def test_statement_generating(self):
4949
account_statement = {
5050
'date_from': '2017-01-01',
5151
'date_to': '2017-02-27',

tests/unit/preauthorization_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def setUp(self):
1919
'isProductionMode': False
2020
})
2121

22-
def _create_preauthorized_payment(self):
22+
def test_create_preauthorized_payment(self):
2323
base_payment = Utils.create_base_payment()
2424

2525
base_payment.update({'preauthorization': True})
@@ -35,7 +35,7 @@ def _create_preauthorized_payment(self):
3535
else:
3636
print('Error: ' + str(response.json))
3737

38-
def _void_authorization(self):
38+
def test_void_authorization(self):
3939
authorized_payment_id = 3049519343
4040

4141
response = self.payments.void_authorization(authorized_payment_id)

tests/unit/refund_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def setUp(self):
1919
'isProductionMode': False
2020
})
2121

22-
def test_refund_payment(self):
22+
def refund_payment(self):
2323
payment_id = 3049525986
2424

2525
response = self.payments.refund_payment(payment_id, 1900)

0 commit comments

Comments
 (0)