def create(self, card: Card, **kwargs) -> NewCardResponse: """Store the card in the safe Args: card (Card): Customer card data """ response = self._post(self._format_url(), json=card._as_dict()) if "callback" in kwargs.keys(): kwargs["callback"](card._as_dict(), response, self._format_url()) return NewCardResponse(**response)
def testNumberTokenAsStr(self): data = sample.copy() data["number_token"] = "12345" card = Card(**data) self.assertIsInstance(card.number_token, CardToken) self.assertEqual(card.number_token.number_token, "12345")
def verify(self, card: Card, **kwargs) -> bool: """Checks if the card is valid Args: card (Card): Customer card data """ response = self._post( self._format_url(card_id="verification"), json=card._as_dict() ) if "callback" in kwargs.keys(): kwargs["callback"](card._as_dict(), response, self._format_url(card_id="verification")) return response.get("status") == "VERIFIED"
def create(self, card: Card) -> NewCardResponse: """Store the card in the safe Args: card (Card): Customer card data """ response = self._post(self._format_url(), json=card._as_dict()) return NewCardResponse(**response)
def verify(self, card: Card) -> bool: """Checks if the card is valid Args: card (Card): Customer card data """ response = self._post(self._format_url(card_id="verification"), json=card._as_dict()) return response.get("status") == "VERIFIED"
def test_number_token_as_str(card_sample: dict): card_sample["number_token"] = "12345" card = Card(**card_sample) assert isinstance(card.number_token, CardToken) assert "12345" == card.number_token.number_token
def testInvalidSecurityCode5(self): with self.assertRaises(TypeError): data = sample.copy() data["security_code"] = "12345" Card(**data)
def testInvalidCustomerId(self): with self.assertRaises(TypeError): data = sample.copy() data["customer_id"] = "1" * 101 Card(**data)
def testInvalidExpirationYear(self): with self.assertRaises(TypeError): data = sample.copy() data["expiration_year"] = 100 Card(**data)
def testInvalidExpirationMonth(self): with self.assertRaises(TypeError): data = sample.copy() data["expiration_month"] = 13 Card(**data)
def test_invalid_expiration_month(card_sample: dict): with pytest.raises(TypeError): card_sample["expiration_month"] = 13 Card(**card_sample)
def test_as_dict(card_sample: dict): card = Card(**card_sample) assert card_sample == card._as_dict()
def verify(self, card: Card) -> bool: response = self._post(self._format_url(card_id="verification"), json=card.as_dict()) return response.get("status") == "VERIFIED"
def testInvalidBrand(self): with self.assertRaises(TypeError): data = sample.copy() data["brand"] = "12345" Card(**data)
def test_invalid_security_code5(card_sample: dict): with pytest.raises(TypeError): card_sample["security_code"] = "12345" Card(**card_sample)
def test_invalid_customer_id(card_sample: dict): with pytest.raises(TypeError): card_sample["customer_id"] = "1" * 101 Card(**card_sample)
def test_invalid_expiration_year(card_sample: dict): with pytest.raises(TypeError): card_sample["expiration_year"] = 100 Card(**card_sample)
def create(self, card: Card) -> NewCardResponse: response = self._post(self._format_url(), json=card.as_dict()) return NewCardResponse(**response)
def testAsDict(self): card = Card(**sample) self.assertDictEqual(card.as_dict(), sample)
def test_invalid_brand(card_sample: dict): with pytest.raises(TypeError): card_sample["brand"] = "12345" Card(**card_sample)