Skip to content

Implementing a new provider

This project aims to be compatible with as many registrars as possible, giving users a choice when creating a Connector.

Adding a new Provider is straightforward. Simply follow the steps below.

This guide explains how to add support for a new domain registrar. You’ll implement both the Backend (Provider logic) and the Frontend (configuration form).

  1. Read the API documentation of the new Provider and identify the sections related to user authentication and domain name registration.
  2. Set up your development environment.

In this section, you’ll implement the logic required to interact with the new Provider’s API.

  1. Create a new DTO class to validate user authentication data.

    • Directorysrc
      • DirectoryDto.Connector
        • DefaultProviderDto.php default DTO, which will also be used
        • MySuperRegistrarProviderDto.php your new DTO class
  2. Add the necessary class properties and assertions. The DTO class must extend DefaultProviderDto.

    Only include properties required for user authentication, domain name registration, and any legally required consents.

    MySuperRegistrarProviderDto.php
    namespace App\Dto\Connector;
    class MySuperRegistrarProviderDto extends DefaultProviderDto
  3. Create a new Provider class.

    • Directorysrc
      • DirectoryService
        • DirectoryProvider
          • AbstractProvider.php defines the signature of methods
          • MySuperRegistrarProvider.php your new Provider
  4. The class must extend AbstractProvider. Refer to the existing Providers for implementation examples.

    MySuperRegistrarProvider.php
    namespace App\Service\Provider;
    #[Autoconfigure(public: true)]
    class MySuperRegistrarProvider extends AbstractProvider
    {
    protected string $dtoClass = MySuperRegistrarProviderDto::class;
    /** @var MySuperRegistrarProviderDto */
    protected DefaultProviderDto $authData;
  5. Implement the assertAuthentication method.

    This method validates user authentication data. Make a request to the Provider’s API to verify that the user’s credentials are valid.

    The method must return void when authentication succeeds.

    MySuperRegistrarProvider.php
    protected function assertAuthentication(): void
    {
    // TODO: Implement assertAuthentication() method.
    }
  6. Implement the getCachedTldList method.

    MySuperRegistrarProvider.php
    protected function getCachedTldList(): CacheItemInterface
    {
    return $this->cacheItemPool->getItem('app.provider.my-super-registrar.supported-tld');
    }

    This method returns the cache entry holding the list of TLDs supported by this Provider. Even if the API does not currently provide this information, implement the method for future compatibility.

  7. Implement the getSupportedTldList method.

    If the Provider API does not offer a way to retrieve supported TLDs, return an empty array []. Otherwise, call the API and return the list of supported TLDs.

    MySuperRegistrarProvider.php
    protected function getSupportedTldList(): array
    {
    // TODO: Implement getSupportedTldList() method.
    }
  8. Implement the isSupported method (if necessary). Override isSupported only if the Provider API cannot list supported TLDs. In that case, return true to indicate that all TLDs are potentially valid.

  9. Implement the orderDomain method.

    Follow the Provider’s API documentation to implement domain ordering using the required properties.

    MySuperRegistrarProvider.php
    public function orderDomain(Domain $domain, bool $dryRun): void
    {
    // TODO: Implement orderDomain() method.
    }
  10. Add your Provider to the ConnectorProvider enumeration.

    src/Config/ConnectorProvider.php
    namespace AppConfig;
    enum ConnectorProvider: string
    {
    // ...
    case MY_SUPER_REGISTRAR = 'my-super-registrar';
    public function getConnectorProvider(): string
    {
    return match ($this) {
    // ...
    ConnectorProvider::MY_SUPER_REGISTRAR => MySuperRegistrarProvider::class,
    };
    }

Well done! 🎉

You have now completed the Backend implementation. Let’s continue with the Frontend! 🚀

  1. Create a form containing the necessary fields for your Provider.

    • Directoryassets
      • Directoryutils
        • Directoryproviders
          • Directoryforms
            • DefaultConnectorFormItems.tsx fields shared by all
            • MySuperRegistrarConnectorForm.tsx
  2. Add the fields corresponding to the DTO you created earlier. Check existing forms for reference. If the Provider API does not allow retrieving supported TLDs, display this information as in the other forms.

  3. Add your Provider to the ConnectorProvider enumeration. The value must exactly match the one defined in PHP.

    assets/utils/api/connectors.ts
    export enum ConnectorProvider {
    // ...
    MY_SUPER_REGISTRAR = 'my-super-registrar'
    }
  4. Add the API terms of service link and the reference to your new form in the index.ts configuration file.

    assets/utils/providers/index.ts
    export const providersConfig: Record<ConnectorProvider, ProviderConfig> = {
    // ...
    [ConnectorProvider.MY_SUPER_REGISTRAR]: {
    tosLink: 'https://...',
    form: MySuperRegistrarConnectorForm
    }
    }
  5. Ensure the interface renders correctly and fix any display issues.

Great job! 🎉

Your Frontend implementation is now complete.

  1. Add the corresponding test function in the Provider test collection.

    tests/Service/Provider/AbstractProviderTest.php
    #[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
    public function testMySuperRegistrar()
    {
    $token = static::getContainer()->getParameter('my_super_registrar_token');
    if (!$token) {
    $this->markTestSkipped('Missing My Super Registrar token');
    }
    $this->testGenericProvider(ConnectorProvider::MY_SUPER_REGISTRAR, [
    'waiveRetractationPeriod' => true,
    'acceptConditions' => true,
    'ownerLegalAge' => true,
    'token' => $token,
    ]);
    }
  2. Create a Symfony configuration parameter connecting the environment variable to the credentials.

  3. Run the tests with PHPUnit:

    Terminal window
    php vendor/bin/phpunit
  4. Ensure the test passes. If it fails, fix the implementation accordingly. Consider enabling code coverage to identify executed sections.

That’s it!

You’ve now finished implementing a new Provider. ✨