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