Skip to content

Commit 67eec2c

Browse files
authored
Merge pull request #2 from romatallinn/v0.0.3
v0.0.3
2 parents 49aadcc + ed29c0f commit 67eec2c

11 files changed

Lines changed: 52 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
## 0.0.3
2+
3+
The release contains multiple critical bug fixes and improvements.
4+
5+
- Bump project development status classifier to 4 - Beta
6+
- Add description to project config
7+
- Add `Address.district`
8+
- Fix base request's response handler
9+
- Fix API endpoints in Payments module
10+
- Fix API formatting of lists in `ObjectJSON`
11+
- Fix typo in `SplitPayment.subordinate_merchant_id`
12+
- Add `SplitMerchant.birthday_date` and `SplitMerchant.business_activity_id` as required for merchants registered by CPF document
13+
- Accept data via kwargs in payment's capture request (e.g., for split payment details)
14+
115
## 0.0.2
216

317
The release mostly meant to improve project & code quality.

braspag_sdk/apps/payments/data/address.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ def __init__(self):
66
self.street = None
77
self.number = None
88
self.complement = None
9+
self.district = None
910
self.zip_code = None
1011
self.city = None
1112
self.state = None

braspag_sdk/apps/payments/requests/create_sale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self, merchant_credentials: MerchantCredentials, environment: Payme
1111
self.environment = environment
1212

1313
def execute(self, sale):
14-
uri = '%s/sales' % self.environment.api
14+
uri = '%s/v2/sales' % self.environment.api
1515
response = self.send_request("POST", uri, sale)
1616
sale.update_return(response)
1717
return response

braspag_sdk/apps/payments/requests/query_sale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ def __init__(self, merchant_credentials: MerchantCredentials, environment: Payme
1111
self.environment = environment
1212

1313
def execute(self, payment_id):
14-
uri = '%s/sales/%s' % (self.environment.query_api, payment_id)
14+
uri = '%s/v2/sales/%s' % (self.environment.query_api, payment_id)
1515
return self.send_request("GET", uri)

braspag_sdk/apps/payments/requests/update_sale.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import json
2+
13
from braspag_sdk.utils import ApiBase
24

35
from braspag_sdk.apps.payments.environment import PaymentsEnvironment
@@ -14,11 +16,13 @@ def __init__(self, type: str, merchant_credentials: MerchantCredentials, environ
1416
self.type = type
1517
self.service_tax_amount = None
1618
self.amount = None
19+
self.data = None
1720

1821
def execute(self, payment_id):
1922

20-
uri = '%s/sales/%s/%s' % (self.environment.api, payment_id, self.type)
23+
uri = '%s/v2/sales/%s/%s' % (self.environment.api, payment_id, self.type)
2124

25+
data = {}
2226
params = {}
2327

2428
if self.amount:
@@ -27,4 +31,7 @@ def execute(self, payment_id):
2731
if self.service_tax_amount:
2832
params['serviceTaxAmount'] = self.service_tax_amount
2933

30-
return self.send_request('PUT', uri, params=params)
34+
if self.data:
35+
data = self.data
36+
37+
return self.send_request('PUT', uri, params=params, data=data)

braspag_sdk/apps/payments/services.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ def create_sale(self, sale: Sale):
1616
request = CreateSale(self.merchant_credentials, self._environment)
1717
return request.execute(sale)
1818

19-
def capture_sale(self, payment_id: str, amount=None, service_tax_amount=None):
19+
def capture_sale(self, payment_id: str, amount=None, service_tax_amount=None, **kwargs):
2020
request = UpdateSale('capture', self.merchant_credentials, self._environment)
2121
request.amount = amount
2222
request.service_tax_amount = service_tax_amount
23+
24+
data = None
25+
if kwargs:
26+
data = json.dumps(kwargs)
27+
request.data = data
28+
2329
return request.execute(payment_id)
2430

2531
def cancel_sale(self, payment_id: str, amount=None):

braspag_sdk/apps/split/data/split_merchant.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def __init__(self, *, master_merchant_id):
4545
self.corporate_name = None
4646
self.document_number = None
4747
self.document_type = None
48+
self.birthday_date = None
49+
self.business_activity_id = None
4850
self.address = None
4951
self.bank_account = None
5052
self.agreements = None

braspag_sdk/apps/split/data/split_payment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def __init__(self, mdr=None, fee=None):
1010

1111
class SplitPayment(ObjectJSON):
1212

13-
def __init__(self, subordinadate_merchant_id, amount, mdr=None, fee=None):
14-
self.subordinadate_merchant_id = subordinadate_merchant_id
13+
def __init__(self, subordinate_merchant_id, amount, mdr=None, fee=None):
14+
self.subordinate_merchant_id = subordinate_merchant_id
1515
self.amount = amount
1616
self.fares = SplitPaymentFares(mdr, fee)

braspag_sdk/utils/base_request.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def send_request(self, method, uri, data=None, params=None):
2727

2828
if not body:
2929
headers['Content-Length'] = '0'
30-
elif not isinstance(data, dict):
30+
elif not isinstance(data, str):
3131
body = body.toJSON()
3232

3333
if 'Content-Type' not in headers:
@@ -39,7 +39,7 @@ def send_request(self, method, uri, data=None, params=None):
3939

4040
response = s.send(prep)
4141

42-
if 'json' in response.headers['Content-Type'].lower():
42+
if 'json' in response.headers.get('Content-Type', '').lower():
4343
answers = response.json()
4444
else:
4545
answers = [{

braspag_sdk/utils/object_json.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ def __getattribute__(self, attribute):
2424

2525

2626
def process_name_key(dictionary):
27+
28+
# If it's a list, process each item.
29+
if isinstance(dictionary, list):
30+
new_list = []
31+
for item in dictionary:
32+
new_list.append(process_name_key(item))
33+
return new_list
34+
35+
# If it's not a dictionary (and not list), just return it as is.
2736
if not isinstance(dictionary, dict):
2837
return dictionary
2938

39+
# If it's a dictionary, process each key/value.
3040
new_dictionary = {}
31-
3241
for key in dictionary:
3342
new_dictionary[capitalize_key(key)] = process_name_key(dictionary[key])
34-
3543
return new_dictionary
3644

3745

0 commit comments

Comments
 (0)