def save_payment_data(self, holder_name: str, card_number: str, security_code: str) -> Response: """ Validate the user's payment data as a PaymentData object If the required fields are validated then process the information as a PaymentData object and store it in the Reservation :param holder_name: the name of the Card Holder, it doesn't need to be the same as the user's full name :param card_number: the card identification number << VALIDATED >> :param security_code: the card CVV << VALIDATED >> :return: Response code to notify the UI of the status of the Reservation object """ response = Response.INVALID_PAYMENT_DATA if Validator.validate_payment_data(holder_name, card_number, security_code): self._payment_data = self._process_payment_data( user_name=holder_name, card_number=card_number, security_code=security_code, credit_card_type=self._payment_method) response = Response.RESERVATION_DATA_UPDATED return response
def test_validate_payment_data(default_payment_data): """ Test case to check the validate_payment_data function EXPECTED BEHAVIOUR: Variables in given PaymentData instance match the checked regular expressions and return False """ assert Validator.validate_payment_data( default_payment_data.user_name, default_payment_data.card_number, default_payment_data.security_code) is True