Module System

CloudBill Pro's module system lets you extend the platform with custom payment gateways, server provisioners, domain registrars, and more.

Module Types

TypeDirectoryPurpose
Gatewaymodules/gateways/{name}/Accept payments (Stripe, PayPal, etc.)
Servermodules/servers/{name}/Provision hosting accounts (cPanel, Plesk, etc.)
Registrarmodules/registrars/{name}/Register/manage domains (eNom, Namecheap, etc.)
Mailmodules/mail/{name}/Email delivery providers (SMTP, Mailgun, etc.)
Fraudmodules/fraud/{name}/Fraud detection checks
Notificationmodules/notifications/{name}/Slack, Telegram, SMS alerts
Addonmodules/addons/{name}/Custom admin panel features

Module Structure

Every module needs at least two files:

modules/
  gateways/
    mygateway/
      config.php      ← Module metadata and settings definition
      mygateway.php   ← Main class file

Creating a Gateway Module

1. config.php

 'mygateway',
    'display_name' => 'My Payment Gateway',
    'description'  => 'Accept payments via My Gateway',
    'version'      => '1.0.0',
    'author'       => 'Your Name',
    'type'         => 'gateway',
    'supports'     => ['one_time', 'refund'],
    'fields'       => [
        'api_key' => [
            'label'     => 'API Key',
            'type'      => 'password',
            'required'  => true,
            'encrypted' => true,
        ],
        'test_mode' => [
            'label'   => 'Sandbox Mode',
            'type'    => 'checkbox',
            'default' => true,
        ],
    ],
];

2. mygateway.php

app = $app;
        // Load settings from database
        $db = $app->db();
        $rows = $db->fetchAll("SELECT name, value FROM `{$db->table('gateway_settings')}` WHERE gateway = 'mygateway'");
        foreach ($rows as $r) {
            $this->settings[$r['name']] = $r['value'];
        }
    }

    /**
     * Render the payment form HTML for an invoice
     */
    public function renderPaymentForm(array $invoice): string
    {
        $callbackUrl = $this->app->baseUrl('/gateway/callback/mygateway');
        return <<
    
    
    
    

HTML;
    }

    /**
     * Handle the gateway callback (POST from gateway)
     * Return array with invoice_id, amount, transaction_id on success
     * Return false on failure
     */
    public function handleCallback(array $data): array|false
    {
        $invoiceId = (int)($data['invoice_id'] ?? 0);
        $amount    = (float)($data['amount'] ?? 0);

        // Verify the payment with your gateway API
        $isValid = $this->verifyPayment($data);
        if (!$isValid) return false;

        return [
            'invoice_id'     => $invoiceId,
            'amount'         => $amount,
            'transaction_id' => $data['transaction_id'] ?? uniqid(),
        ];
    }

    private function verifyPayment(array $data): bool
    {
        // Add your verification logic here
        return !empty($data['invoice_id']) && !empty($data['amount']);
    }
}

Creating a Server Module

Server modules must implement: create(), suspend(), unsuspend(), terminate(), changePassword(), getUsage(), testConnection().

See the included modules/servers/cpanel/cpanel.php for a complete example.

Creating a Registrar Module

Registrar modules must implement: checkAvailability(), register(), renew(), updateNameservers(), getExpiryDate().

See the included modules/registrars/enom/enom.php for a complete example.

Installing a Module

  1. Upload the module folder to the appropriate directory (e.g., modules/gateways/mygateway/)
  2. Navigate to Admin → Gateways (or Servers/Registrars)
  3. Your module will appear automatically — click Configure
  4. Fill in the required settings and click Save
  5. Enable the module with the toggle