docs: def form_valid(self,form):
          '''
          Create the gift certificate voucher with the indicated information and send
          the email as directed.
          '''
          emailTo = form.cleaned_data.get('emailTo')
          emailType = form.cleaned_data.get('emailType')
          recipientName = form.cleaned_data.get('recipientName')
          fromName = form.cleaned_data.get('fromName')
          message = form.cleaned_data.get('message')
  
          logger.info('Processing gift certificate.')
  
          try:
              voucher = Voucher.create_new_code(
                  prefix='GC_',
                  name=_('Gift certificate: %s%s for %s' % (getConstant('general__currencySymbol'),self.amount, emailTo)),
                  category=getConstant('vouchers__giftCertCategory'),
                  originalAmount=self.amount,
                  singleUse=False,
                  forFirstTimeCustomersOnly=False,
                  expirationDate=None,
              )
          except IntegrityError:
              logger.error('Error creating gift certificate voucher for Invoice #%s' % self.invoiceId)
              emailErrorMessage(_('Gift certificate transaction not completed'), self.invoiceId)
  
          template = getConstant('vouchers__giftCertTemplate')
  
          # Attempt to attach a PDF of the gift certificate
          rf = RequestFactory()
          pdf_request = rf.get('/')
  
          pdf_kwargs = {
              'currencySymbol': getConstant('general__currencySymbol'),
              'businessName': getConstant('contact__businessName'),
              'certificateAmount': voucher.originalAmount,
              'certificateCode': voucher.voucherId,
              'certificateMessage': message,
              'recipientName': recipientName,
              'fromName': fromName,
          }
          if recipientName:
              pdf_kwargs.update({})
  
          attachment = GiftCertificatePDFView(request=pdf_request).get(request=pdf_request,**pdf_kwargs).content or None
  
          if attachment:
              attachment_name = 'gift_certificate.pdf'
          else:
              attachment_name = None
  
          # Send a confirmation email
          email_class = EmailRecipientMixin()
          email_class.email_recipient(
              subject=template.subject,
              content=template.content,
              send_html=template.send_html,
              html_content=template.html_content,
              from_address=template.defaultFromAddress,
              from_name=template.defaultFromName,
              cc=template.defaultCC,
              to=emailTo,
              currencySymbol=getConstant('general__currencySymbol'),
              businessName=getConstant('contact__businessName'),
              certificateAmount=voucher.originalAmount,
              certificateCode=voucher.voucherId,
              certificateMessage=message,
              recipientName=recipientName,
              fromName=fromName,
              emailType=emailType,
              recipient_name=recipientName,
              attachment_name=attachment_name,
              attachment=attachment
          )
  
          # Remove the invoice session data
          self.request.session.pop(INVOICE_VALIDATION_STR,None)
  
          return HttpResponseRedirect(self.get_success_url())