diff --git a/maxipago/managers/card.py b/maxipago/managers/card.py index 9d2ad8a..298f2f1 100644 --- a/maxipago/managers/card.py +++ b/maxipago/managers/card.py @@ -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}), diff --git a/tests.py b/tests.py index 35a2217..310c998 100644 --- a/tests.py +++ b/tests.py @@ -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): @@ -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)