Exemple #1
0
 def transfer(self, domain: Domain):
     if domain.epp_code is None:
         raise RegistrarConnectorException('EPP Code is missing')
     contact = domain.contact or domain.service.client
     owner_handle = self.find_or_create_customer(client=contact)
     nameserver_list = self._get_domain_nameservers_as_xml(domain)
     if not nameserver_list:
         raise RegistrarConnectorException(
             _('Nameservers for domain are required'))
     dom_req = E.createDomainRequest(
         self._xml_domain(domain), E.period(domain.registration_period),
         E.authCode(DomainUtils.decode_epp_code(domain.epp_code)),
         E.ownerHandle(owner_handle), E.adminHandle(owner_handle),
         E.techHandle(owner_handle), E.billingHandle(owner_handle),
         E.resellerHandle(''), E.nameServers(E.array(*nameserver_list)))
     response = self.api_request(data=dom_req)
     if response.data.status == 'ACT':
         domain.status = DomainStatus.active
         domain.registration_date = datetime.strptime(
             str(response.data.activationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.expiry_date = datetime.strptime(
             str(response.data.expirationDate), '%Y-%m-%d %H:%M:%S').date()
         domain.epp_code = DomainUtils.encode_epp_code(
             str(response.data.authCode))
         domain.save(update_fields=[
             'status', 'registration_date', 'expiry_date', 'epp_code'
         ])
         return _('Domain transfered')
     elif response.data.status == 'REQ':
         domain.status = DomainStatus.pending
         domain.save(update_fields=['status'])
         return _('Domain pending registration')
     else:
         raise RegistrarConnectorException(_('Domain registration unknown'))
Exemple #2
0
    def register(self, domain: Domain) -> (bool, str):
        """ Register a domain name."""
        api_params = self._prepare_register_params(domain, years=domain.registration_period)
        # TODO: Handle .asia .ca .coop .es .nl .pro .ru .us .au and others

        api_response = self.api_request('POST', self.REGISTER_DOMAIN_URL, api_params)
        # TODO(tomo): status can be Success, InvoicePaid and others. Fail if not Success ?
        message = self.get_actionstatusdesc(api_response)
        domain.status = DomainStatus.active

        # TODO: maybe we should set registration and expiry date based on information from registrar
        domain.registration_date = utcnow().date()
        domain.expiry_date = domain.registration_date + relativedelta(years=domain.registration_period)
        domain.save()
        return message
Exemple #3
0
    def renew(self, domain: Domain) -> str:
        domain_name = domain.name
        years = domain.registration_period

        order_details = self.search_orders_by_domain(domain_name, options='OrderDetails')

        api_params = {'order-id': order_details.get('orderid'),
                      'exp-date': order_details.get('endtime'),
                      'years': str(years),
                      'invoice-option': 'NoInvoice'
                      }
        api_response = self.api_request('POST', self.RENEW_DOMAIN_URL, api_params)
        # TODO: maybe we should set expiry date based on information from registrar
        domain.expiry_date = domain.expiry_date + relativedelta(years=domain.registration_period)
        domain.save()
        return self.get_actionstatusdesc(api_response)
    def renew_domain(domain: Domain):
        if domain.status != DomainStatus.active:
            return False

        domain.expiry_date = domain.expiry_date + relativedelta(years=domain.registration_period)
        domain.status = DomainStatus.active
        domain.save()

        plugin_dispatcher.call_function(
            'todo',
            'create_todo',
            title=_('New domain renew {} order').format(domain.name),
            description=_('A new order to renew domain {} has been placed.').format(domain.name),
        )

        return True
Exemple #5
0
 def renew(self, domain: Domain) -> str:
     """Renews a domain, adding the domain registration period years to the expiration date"""
     years = domain.registration_period
     json_response = self.api_request(
         request_method=RotldActions.RENEW_DOMAIN,
         params={
             'domain': domain.name,
             'domain_period': years
         })
     response_data = json_response.get('data', {})
     new_expiry_date = response_data.get('expiration_date', None)
     # set the new expiration date based on the one received
     if new_expiry_date:
         new_expiry_date = parser.parse(new_expiry_date)
         domain.expiry_date = new_expiry_date
         domain.save()
     return _('Success')
Exemple #6
0
    def register(self, domain: Domain) -> Union[str, dict]:
        """Register a domain name"""
        if domain.status != DomainStatus.pending:
            return _(
                'Cannot register domain that is not pending registration.')
        # check if the domain is available before creating contact and trying to register it
        is_available_for_registration, message = self.check_availability(
            domain=domain)
        if not is_available_for_registration:
            return message
        # try to create the registrant
        try:
            contact_id = self.create_contact(domain=domain)
        except RegistrarConnectorException as e:
            LOG.debug(e)
            return '{}'.format(e)
        params = {
            'domain': domain.name,
            'reservation': 0,  # NOTE: use 1 for reservation
            'c_registrant': contact_id,
            # 'domain_password': generated by rotld api if not provided,
            'domain_period': domain.registration_period
        }
        try:
            json_response = self.api_request(
                request_method=RotldActions.REGISTER_DOMAIN, params=params)
        except RegistrarConnectorException as e:
            LOG.debug(e)
            return '{}'.format(e)
        response_data = json_response.get('data', {})

        domain.status = DomainStatus.active
        domain.registration_date = utcnow().date()
        # set the expiration date based on the one received
        expiration_date = response_data.get('expiration_date', None)
        if expiration_date:
            expiration_date = parser.parse(expiration_date)
            domain.expiry_date = expiration_date
            domain.save()
        return response_data