8000 Merge branch 'master' of github.com:balanced/balanced-python · balanced/balanced-python@48479c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 48479c7

Browse files
author
Pound Marshall
committed
Merge branch 'master' of github.com:balanced/balanced-python
2 parents 5149ea9 + ae620cb commit 48479c7

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

balanced/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.8.7'
1+
__version__ = '0.8.9'
22
from collections import defaultdict
33
import contextlib
44

balanced/config.py

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

66

77
def _make_user_agent():
8-
return 'balanced/python/' + __version__
8+
return 'balanced-python/' + __version__
99

1010

1111
class Config(threading.local, object):

balanced/resources.py

Lines changed: 27 additions & 23 deletions
< 57AE tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,13 @@ def debit(self, amount=None, appears_on_statement_as=None,
480480
source_uri=source_uri,
481481
).save()
482482

483-
def hold(self, amount, meta=None, source_uri=None):
483+
def hold(self, amount, description=None, meta=None, source_uri=None):
484484
meta = meta or {}
485485
return Hold(
486486
uri=self.holds_uri,
487487
amount=amount,
488488
meta=meta,
489+
description=description,
489490
source_uri=source_uri,
490491
).save()
491492

@@ -561,30 +562,30 @@ def create_card(self,
561562
country_code=None,
562563
phone_number=None,
563564
):
564-
return Card(
565-
card_number=card_number,
566-
expiration_month=expiration_month,
567-
expiration_year=expiration_year,
568-
name=name,
569-
security_code=security_code,
570-
street_address=street_address,
571-
postal_code=postal_code,
572-
city=city,
573-
region=region,
574-
country_code=country_code,
575-
phone_number=phone_number,
576-
).save()
565+
return Card(
566+
card_number=card_number,
567+
expiration_month=expiration_month,
568+
expiration_year=expiration_year,
569+
name=name,
570+
security_code=security_code,
571+
street_address=street_address,
572+
postal_code=postal_code,
573+
city=city,
574+
region=region,
575+
country_code=country_code,
576+
phone_number=phone_number,
577+
).save()
577578

578579
def create_bank_account(self,
579580
name,
580581
account_number,
581582
bank_code,
582583
):
583-
return BankAccount(
584-
name=name,
585-
account_number=account_number,
586-
bank_code=bank_code,
587-
).save()
584+
return BankAccount(
585+
name=name,
586+
account_number=account_number,
587+
bank_code=bank_code,
588+
).save()
588589

589590
def create_buyer(self, email_address, card_uri, name=None, meta=None):
590591
meta = meta or {}
@@ -625,12 +626,14 @@ def save(self):
625626
class Debit(Resource):
626627
__metaclass__ = resource_base(collection='debits')
627628

628-
def refund(self, amount=None, description=None):
629+
def refund(self, amount=None, description=None, meta=None):
630+
meta = meta or {}
629631
return Refund(
630632
uri=self.refunds_uri,
631633
debit_uri=self.uri,
632634
amount=amount,
633-
description=description
635+
description=description,
636+
meta=meta,
634637
).save()
635638

636639

@@ -682,12 +685,13 @@ def debit(self, amount=None, appears_on_statement_as=None,
682685
description=description,
683686
).save()
684687

685-
def hold(self, amount, meta=None):
688+
def hold(self, amount, meta=None, description=None):
686689
meta = meta or {}
687690
return Hold(
688691
uri=self.account.holds_uri,
689692
amount=amount,
690-
meta=meta
693+
meta=meta,
694+
description=description
691695
).save()
692696

693697

tests/suite.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,14 @@ def test_06_debit_buyer_account_and_refund(self):
199199
debit = account.debit(
200200
amount=1000,
201201
appears_on_statement_as='atest',
202-
meta={'fraud': 'yes'})
202+
meta={'fraud': 'yes'},
203+
description='Descripty')
203204
self.assertTrue(debit.id.startswith('W'))
204205
self.assertIsInstance(debit.account, balanced.Account)
205206
self.assertIsInstance(debit.hold, balanced.Hold)
207+
self.assertEqual(debit.description, 'Descripty')
206208
self.assertEqual(debit.fee, (1000 * 0.035))
207209
self.assertEqual(debit.appears_on_statement_as, 'atest')
208-
self.assertIsNone(debit.description)
209210

210211
refund = debit.refund(amount=100)
211212
#self.assertTrue(refund.id.startswith('RF'))
@@ -222,10 +223,11 @@ def test_06_debit_buyer_account_and_refund(self):
222223

223224
def test_07_create_hold_and_void_it(self):
224225
account = self._find_account('buyer')
225-
hold = account.hold(amount=1500)
226+
hold = account.hold(amount=1500, description='Hold me')
226227
self.assertEqual(hold.fee, 35)
227228
self.assertEqual(hold.account.uri, account.uri)
228229
self.assertFalse(hold.is_void)
230+
self.assertEqual(hold.description, 'Hold me')
229231
hold.void()
230232
self.assertTrue(hold.is_void)
231233
self.assertEqual(hold.fee, 35) # fee still the same

0 commit comments

Comments
 (0)
0