docs: def finalize(self,**kwargs):
          '''
          This method is called when the payment process has been completed and a registration
          is ready to be finalized.  It also fires the post-registration signal
          '''
          dateTime = kwargs.pop('dateTime', timezone.now())
  
          # If sendEmail is passed as False, then we won't send an email
          sendEmail = kwargs.pop('sendEmail', True)
  
          customer, created = Customer.objects.update_or_create(
              first_name=self.firstName,last_name=self.lastName,
              email=self.email,defaults={'phone': self.phone}
          )
  
          regArgs = {
              'customer': customer,
              'firstName': self.firstName,
              'lastName': self.lastName,
              'dateTime': dateTime,
              'temporaryRegistration': self
          }
          for key in ['comments', 'howHeardAboutUs', 'student', 'priceWithDiscount','payAtDoor']:
              regArgs[key] = kwargs.pop(key, getattr(self,key,None))
  
          # All other passed kwargs are put into the data JSON
          regArgs['data'] = self.data
          regArgs['data'].update(kwargs)
  
          realreg = Registration(**regArgs)
          realreg.save()
          logger.debug('Created registration with id: ' + str(realreg.id))
  
          for er in self.temporaryeventregistration_set.all():
              logger.debug('Creating eventreg for event: ' + str(er.event.id))
              realer = EventRegistration(registration=realreg,event=er.event,
                                         customer=customer,role=er.role,
                                         price=er.price,
                                         dropIn=er.dropIn,
                                         data=er.data
                                         )
              realer.save()
  
          # Mark this temporary registration as expired, so that it won't
          # be counted twice against the number of in-progress registrations
          # in the future when another customer tries to register.
          self.expirationDate = timezone.now()
          self.save()
  
          # This signal can, for example, be caught by the vouchers app to keep track of any vouchers
          # that were applied
          post_registration.send(
              sender=TemporaryRegistration,
              registration=realreg
          )
  
          if sendEmail:
              if getConstant('email__disableSiteEmails'):
                  logger.info('Sending of confirmation emails is disabled.')
              else:
                  logger.info('Sending confirmation email.')
                  template = getConstant('email__registrationSuccessTemplate')
  
                  realreg.email_recipient(
                      subject=template.subject,
                      content=template.content,
                      html_content=template.html_content,
                      send_html=template.send_html,
                      from_address=template.defaultFromAddress,
                      from_name=template.defaultFromName,
                      cc=template.defaultCC,
                  )
  
          # Return the newly-created finalized registration object
          return realreg