Beispiel #1
0
    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)
Beispiel #2
0
    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")
Beispiel #3
0
    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"
Beispiel #4
0
    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)
Beispiel #5
0
    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"
Beispiel #6
0
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
Beispiel #7
0
 def testInvalidSecurityCode5(self):
     with self.assertRaises(TypeError):
         data = sample.copy()
         data["security_code"] = "12345"
         Card(**data)
Beispiel #8
0
 def testInvalidCustomerId(self):
     with self.assertRaises(TypeError):
         data = sample.copy()
         data["customer_id"] = "1" * 101
         Card(**data)
Beispiel #9
0
 def testInvalidExpirationYear(self):
     with self.assertRaises(TypeError):
         data = sample.copy()
         data["expiration_year"] = 100
         Card(**data)
Beispiel #10
0
 def testInvalidExpirationMonth(self):
     with self.assertRaises(TypeError):
         data = sample.copy()
         data["expiration_month"] = 13
         Card(**data)
Beispiel #11
0
def test_invalid_expiration_month(card_sample: dict):
    with pytest.raises(TypeError):
        card_sample["expiration_month"] = 13
        Card(**card_sample)
Beispiel #12
0
def test_as_dict(card_sample: dict):
    card = Card(**card_sample)
    assert card_sample == card._as_dict()
Beispiel #13
0
 def verify(self, card: Card) -> bool:
     response = self._post(self._format_url(card_id="verification"),
                           json=card.as_dict())
     return response.get("status") == "VERIFIED"
Beispiel #14
0
 def testInvalidBrand(self):
     with self.assertRaises(TypeError):
         data = sample.copy()
         data["brand"] = "12345"
         Card(**data)
Beispiel #15
0
def test_invalid_security_code5(card_sample: dict):
    with pytest.raises(TypeError):
        card_sample["security_code"] = "12345"
        Card(**card_sample)
Beispiel #16
0
def test_invalid_customer_id(card_sample: dict):
    with pytest.raises(TypeError):
        card_sample["customer_id"] = "1" * 101
        Card(**card_sample)
Beispiel #17
0
def test_invalid_expiration_year(card_sample: dict):
    with pytest.raises(TypeError):
        card_sample["expiration_year"] = 100
        Card(**card_sample)
Beispiel #18
0
 def create(self, card: Card) -> NewCardResponse:
     response = self._post(self._format_url(), json=card.as_dict())
     return NewCardResponse(**response)
Beispiel #19
0
 def testAsDict(self):
     card = Card(**sample)
     self.assertDictEqual(card.as_dict(), sample)
Beispiel #20
0
def test_invalid_brand(card_sample: dict):
    with pytest.raises(TypeError):
        card_sample["brand"] = "12345"
        Card(**card_sample)