Skip to content

Commit 5b4b5e6

Browse files
author
Arthur Debert
committed
Fixed required fields in add card validation, closes maxipago/Python-integration-lib#9.
The list of required fields doesn't match the documentation nor the underlying API, those fields aren't really required.
1 parent e845764 commit 5b4b5e6

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

maxipago/managers/card.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def add(self, **kwargs):
1313
('expiration_month', {'translated_name': 'expirationMonth'}),
1414
('expiration_year', {'translated_name': 'expirationYear'}),
1515
('billing_name', {'translated_name': 'billingName'}),
16-
('billing_address1', {'translated_name': 'billingAddress1'}),
16+
('billing_address1', {'translated_name': 'billingAddress1', 'required': False}),
1717
('billing_address2', {'translated_name': 'billingAddress2', 'required': False}),
18-
('billing_city', {'translated_name': 'billingCity'}),
19-
('billing_state', {'translated_name': 'billingState'}),
20-
('billing_zip', {'translated_name': 'billingZip'}),
21-
('billing_country', {'translated_name': 'billingCountry'}),
22-
('billing_phone', {'translated_name': 'billingPhone'}),
23-
('billing_email', {'translated_name': 'billingEmail'}),
18+
('billing_city', {'translated_name': 'billingCity', 'required': False}),
19+
('billing_state', {'translated_name': 'billingState', 'required': False}),
20+
('billing_zip', {'translated_name': 'billingZip', 'required': False}),
21+
('billing_country', {'translated_name': 'billingCountry', 'required': False}),
22+
('billing_phone', {'translated_name': 'billingPhone', 'required': False}),
23+
('billing_email', {'translated_name': 'billingEmail', 'required': False}),
2424
('onfile_end_date', {'translated_name': 'onFileEndDate', 'required': False}),
2525
('onfile_permissions', {'translated_name': 'onFilePermissions', 'required': False}),
2626
('onfile_comment', {'translated_name': 'onFileComment', 'required': False}),

tests.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
MAXIPAGO_ID = os.getenv('MAXIPAGO_ID')
1111
MAXIPAGO_API_KEY = os.getenv('MAXIPAGO_API_KEY')
12-
12+
if not MAXIPAGO_ID:
13+
raise ValueError("You must setup the maxipago id env variable.")
14+
if not MAXIPAGO_API_KEY:
15+
raise ValueError("You must setup the maxipago api key env variable.")
1316

1417
class MaxipagoTestCase(unittest.TestCase):
1518

@@ -115,6 +118,29 @@ def test_add_card(self):
115118

116119
self.assertTrue(getattr(response, 'token', False))
117120

121+
def test_add_card_minimal_fields(self):
122+
CUSTOMER_ID = randint(1, 100000)
123+
124+
response = self.maxipago.customer.add(
125+
customer_id=CUSTOMER_ID,
126+
first_name=u'Fulano',
127+
last_name=u'de Tal',
128+
)
129+
130+
self.assertTrue(hasattr(response, 'id'))
131+
132+
maxipago_customer_id = response.id
133+
134+
response = self.maxipago.card.add(
135+
customer_id=maxipago_customer_id,
136+
number=u'4111111111111111',
137+
expiration_month=u'02',
138+
expiration_year=date.today().year + 3,
139+
billing_name=u'Fulano de Tal',
140+
)
141+
142+
self.assertTrue(getattr(response, 'token', False))
143+
118144
def test_delete_card(self):
119145
CUSTOMER_ID = randint(1, 100000)
120146

0 commit comments

Comments
 (0)