Skip to content

Commit

Permalink
Fixed required fields in add card validation, closes maxipago#9.
Browse files Browse the repository at this point in the history
The list of required fields doesn't match the documentation nor the underlying API, those fields aren't really required.
  • Loading branch information
Arthur Debert committed Apr 3, 2014
1 parent e845764 commit 5b4b5e6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
14 changes: 7 additions & 7 deletions maxipago/managers/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def add(self, **kwargs):
('expiration_month', {'translated_name': 'expirationMonth'}),
('expiration_year', {'translated_name': 'expirationYear'}),
('billing_name', {'translated_name': 'billingName'}),
('billing_address1', {'translated_name': 'billingAddress1'}),
('billing_address1', {'translated_name': 'billingAddress1', 'required': False}),
('billing_address2', {'translated_name': 'billingAddress2', 'required': False}),
('billing_city', {'translated_name': 'billingCity'}),
('billing_state', {'translated_name': 'billingState'}),
('billing_zip', {'translated_name': 'billingZip'}),
('billing_country', {'translated_name': 'billingCountry'}),
('billing_phone', {'translated_name': 'billingPhone'}),
('billing_email', {'translated_name': 'billingEmail'}),
('billing_city', {'translated_name': 'billingCity', 'required': False}),
('billing_state', {'translated_name': 'billingState', 'required': False}),
('billing_zip', {'translated_name': 'billingZip', 'required': False}),
('billing_country', {'translated_name': 'billingCountry', 'required': False}),
('billing_phone', {'translated_name': 'billingPhone', 'required': False}),
('billing_email', {'translated_name': 'billingEmail', 'required': False}),
('onfile_end_date', {'translated_name': 'onFileEndDate', 'required': False}),
('onfile_permissions', {'translated_name': 'onFilePermissions', 'required': False}),
('onfile_comment', {'translated_name': 'onFileComment', 'required': False}),
Expand Down
28 changes: 27 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

MAXIPAGO_ID = os.getenv('MAXIPAGO_ID')
MAXIPAGO_API_KEY = os.getenv('MAXIPAGO_API_KEY')

if not MAXIPAGO_ID:
raise ValueError("You must setup the maxipago id env variable.")
if not MAXIPAGO_API_KEY:
raise ValueError("You must setup the maxipago api key env variable.")

class MaxipagoTestCase(unittest.TestCase):

Expand Down Expand Up @@ -115,6 +118,29 @@ def test_add_card(self):

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

def test_add_card_minimal_fields(self):
CUSTOMER_ID = randint(1, 100000)

response = self.maxipago.customer.add(
customer_id=CUSTOMER_ID,
first_name=u'Fulano',
last_name=u'de Tal',
)

self.assertTrue(hasattr(response, 'id'))

maxipago_customer_id = response.id

response = self.maxipago.card.add(
customer_id=maxipago_customer_id,
number=u'4111111111111111',
expiration_month=u'02',
expiration_year=date.today().year + 3,
billing_name=u'Fulano de Tal',
)

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

def test_delete_card(self):
CUSTOMER_ID = randint(1, 100000)

Expand Down

0 comments on commit 5b4b5e6

Please sign in to comment.