def retrieve_card_details(self): """ retrieve card details from instance """ form = CardDetailsForm(self.request.POST) if form.is_valid(): self.card_details = { 'CardNumber': form.cleaned_data['card_no'], 'CardStartDate': form.cleaned_data['start_date'], 'CardExpDate': form.cleaned_data['expiry_date'], 'CardSecCode': form.cleaned_data['sec_code'], 'CardIssue': form.cleaned_data['issue_number'], } return True else: logger.debug(form.errors) return False
def create_temp_form(self): """ create form from card details and check validity""" card_details = { 'card_no': self.card_details['CardNumber'], 'start_date': self.card_details['CardStartDate'], 'expiry_date': self.card_details['CardExpDate'], 'sec_code': self.card_details['CardSecCode'], 'issue_number': self.card_details['CardIssue'], 'transaction_id': self.client.response['TransactionId'] } form = CardDetailsForm(card_details) # make sure it's valid or let it raise a Validation Exception if form.is_valid(): logger.debug("valid") else: logger.debug(form.errors) return form