The storefront

A public sales website that ships inside the panel. Customers browse plans, register, pay and get a game server. This page shows how to install and run it.

What it is

The storefront is the billing module, in the panel's modules/billing folder. It is a small PHP site with its own pages: plans and prices, cart, sign up and sign in, checkout, invoices, My Servers, support tickets and a status page. You serve that folder as its own website, on its own domain, next to the panel.

It is not a separate program. It reads and writes the panel's database and calls the panel's own code, so an order made on the storefront becomes a panel account and a game server with no copying or syncing.

The module is required. The panel does not let you switch it off, and updates keep it in place. One result is that the storefront's status page can always show the Control Panel as online: if you can see the page, the panel that serves it is running.

How it fits together

PartWhere it runsWhat it does
Storefrontshop.example.comPublic pages: plans, sign up, cart, checkout, invoices, support, status.
Panelpanel.example.comAdministration, game server control, tickets and settings. Customers sign in here after they buy.
DatabaseThe panel's MySQL or MariaDB databaseOne database for both. The storefront reads the panel's database settings, so you do not enter them twice.
AgentsYour game hostsThe storefront asks the panel to create the game server. The panel tells the agent to install it.
Payment providerPayPal, Stripe or manualTakes the money and tells the storefront when it is paid.

The two sites can share one modules/billing code tree. Both the panel and the storefront read the same files from the same panel install, so one panel update updates both.

Before you start

Step 1: Point the domain at the server

At your DNS provider, add an A record for the storefront name that points to the public IPv4 address of the web server. Add an AAAA record as well if the server has a public IPv6 address.

TypeNameValue
AshopThe web server's public IPv4 address
Awww.shop (optional)The same address, or a CNAME to shop
ApanelThe same address, if the panel is on the same server

If you use the bare domain for the storefront, the name is @. Wait until the name resolves before you ask for a certificate; dig +short shop.example.com should print your address.

Step 2: Create the virtual host

The document root is the panel's modules/billing folder. Use your own install path in place of /var/www/html/GSE/Panel. The web server user must be able to read the whole panel tree, because the storefront loads panel code.

Apache

Enable the modules, add the file and enable it. AllowOverride All matters: the folder's .htaccess blocks the configuration, SQL and library folders, so without it those would be readable.

sudo a2enmod rewrite
sudo nano /etc/apache2/sites-available/shop.example.com.conf
sudo a2ensite shop.example.com
sudo apachectl configtest && sudo systemctl reload apache2

The file:

<VirtualHost *:80>
    ServerName shop.example.com
    ServerAlias www.shop.example.com
    DocumentRoot /var/www/html/GSE/Panel/modules/billing

    <Directory /var/www/html/GSE/Panel/modules/billing>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/shop.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/shop.example.com-access.log combined
</VirtualHost>

nginx

nginx does not read .htaccess, so the same protections are written into the server block. Do not leave them out. Change the PHP-FPM socket to match your PHP version.

server {
    listen 80;
    listen [::]:80;
    server_name shop.example.com www.shop.example.com;

    root /var/www/html/GSE/Panel/modules/billing;
    index index.php;
    autoindex off;

    access_log /var/log/nginx/shop.example.com-access.log;
    error_log  /var/log/nginx/shop.example.com-error.log;

    # Let Let's Encrypt reach its challenge files. This must come before the dot-file rule.
    location ^~ /.well-known/acme-challenge/ {
        allow all;
    }

    # nginx ignores .htaccess, so the same protections are written out here.
    location ~ ^/(_archived|classes|includes|sql|tools|data|logs|config)(/|$) {
        return 403;
    }
    location ~ ^/site_config(\.local|\.example)?\.php$ {
        return 403;
    }
    location ~ /\. {
        return 403;
    }
    location ~* \.(bak|backup|sql|md|json|log|txt|ya?ml|lock)$ {
        return 403;
    }

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
}

Save it in /etc/nginx/sites-available/, link it into sites-enabled, then run sudo nginx -t && sudo systemctl reload nginx.

HTTPS

With the host serving on port 80, ask for a certificate. certbot adds the port 443 block and the redirect for you.

sudo certbot --apache -d shop.example.com -d www.shop.example.com
# or, for nginx:
sudo certbot --nginx -d shop.example.com -d www.shop.example.com

Open the site. You should see the storefront home page. Then check that /site_config.php and /includes/ answer 403 Forbidden. If either one shows anything else, stop and fix the virtual host before you go on.

Step 3: Configure the storefront

Put your settings in modules/billing/site_config.local.php. It is not in git, so updates never overwrite it. site_config.php holds the defaults, and site_config.example.php lists the keys.

<?php
// modules/billing/site_config.local.php (not in git; overrides site_config.php)
return [
    // The storefront has its own host, so it sits at the domain root.
    'base_path' => '',
    // Where the panel lives on disk. Needed only if billing is copied outside the panel tree.
    'panel_path' => '',
    // Where the Control Panel link and shared pictures point.
    'panel_base' => 'https://panel.example.com',
    // Key file for the stored PayPal secret. Keep it outside the web root.
    'paypal_key_file' => '/etc/gse/paypal.key',
    // Which wording to use (see "Your own wording" below). Empty means the neutral default.
    'content_profile' => '',
    'brand' => [
        'name'        => 'Your Store Name',
        'company'     => 'Your Company',
        'tagline'     => 'Game server hosting with human support.',
        'email'       => 'support@example.com',
        'discord_url' => 'https://discord.gg/yourinvite',
    ],
];
KeyWhat it does
base_pathURL path the storefront is served from. Leave it empty on its own host. Use /panel/modules/billing only when you serve it from inside the panel's own site.
panel_pathPanel folder on disk, when the storefront code is outside the panel tree.
panel_basePanel address. Used for the Control Panel link, and for shared pictures and themes.
paypal_key_fileFile that holds the key used to encrypt the PayPal secret in the database. Create it outside the web root and let only the web server user read it.
content_profileName of a file in modules/billing/content/ that holds your own storefront wording. Empty uses the neutral default text.
brandName, company, tagline, support email and Discord link shown on the site. The name can also come from Panel Settings. Empty values fall back to the defaults.

To change the logo, replace the PNG files in images/brand/ and keep the file names. The panel logo and name come from Panel Settings.

The storefront can be installed as an app. Visitors can add it to their phone or computer home screen, and it opens full screen with your icon. It needs HTTPS. The icons are gse-icon-192.png and gse-icon-mark.png (512 px) in images/brand/. Pages and forms are never stored on the device, so prices and orders are always current; only images, styles and scripts are kept, and an offline page appears when the connection drops.

Your own wording

Every text on the storefront comes from a content profile, not from the code. A new install uses content/default.php, which describes the product and says nothing about who runs it. To tell your own story, copy that file to modules/billing/content/yourname.php, keep only the texts you want to change, and set 'content_profile' => 'yourname' in site_config.local.php.

Step 4: Set up the catalogue and payment

Everything below is in the panel under Administration, in the Billing pages. Nothing is edited in files.

  1. Locations and plans. Choose which agents can take orders, and what each game plan costs, per slot and per period.
  2. Coupons (optional).
  3. A gateway. Choose how customers pay (see below).
  4. A test order. Place one yourself in sandbox mode before you open the shop.

PayPal

  1. In the billing admin, open the PayPal section and choose sandbox or live.
  2. Enter the client ID and secret from the PayPal developer dashboard, then press Test connection. The secret is stored encrypted with the key in paypal_key_file.
  3. In PayPal, register a webhook that points at https://shop.example.com/paypal/webhook.php. Subscribe it to CHECKOUT.ORDER.APPROVED, PAYMENT.CAPTURE.COMPLETED, PAYMENT.CAPTURE.DENIED, PAYMENT.CAPTURE.REFUNDED and PAYMENT.SALE.COMPLETED.
  4. Copy the webhook ID PayPal gives you into the billing admin. The storefront checks every webhook against it.

Refunds are made through PayPal and the storefront updates the invoice when the refund event arrives.

Stripe and manual payment

Stripe and a manual (offline) gateway are available beside PayPal. The gateway classes live in modules/billing/classes and one is chosen from the billing settings. With manual payment an admin marks the invoice paid after the money arrives.

Keep payment keys out of git. Enter them only in the billing admin or in site_config.local.php.

How an order becomes a game server

  1. The customer picks a game, slots, location and period, and adds it to the cart.
  2. Checkout creates an invoice first. Nothing is provisioned yet.
  3. The customer pays. PayPal returns the customer to the site, and the webhook confirms the payment in the background, so a customer who closes the tab still gets their server.
  4. The invoice is marked paid. The lifecycle service creates the game home on the chosen agent and activates it.
  5. The customer opens My Servers or the panel to start and manage the server.

Free orders skip the payment step. Servers an admin creates in the panel are not billed.

Services besides game servers

Under Administration, Billing, Services you can sell work as well as servers: server setup, custom development, or anything you name. Each service has a short description, a fixed price or a quote, the steps it is paid in, and the questions the customer answers. The storefront lists them on the Services page.

  1. The customer picks a service and answers its questions. A fixed price creates the invoice for the first step at once; a quote opens only the ticket.
  2. Every order opens a support ticket named after the service, so the work is tracked and answered in the usual Support tickets.
  3. For a quote, you enter the price on the Requests table. The customer then finds the invoice in the cart.
  4. A job can be paid in steps, for example 50% to start and 50% on delivery. When the work reaches the next step, press Bill next step.
  5. Paying a service invoice never creates a game server. It moves the request on and writes a note in the ticket.

The Support page has a Request type menu. It starts on Support Request; choosing a paid service takes the customer to that service's order form. The starter services come with example prices: set your own before you go live.

Accounts

The status page

The support page has a small status monitor. It shows the Control Panel, each remote agent and the game servers.

Scheduled jobs

Run the billing cron once a morning. It sends renewal invoices and expiry notices, suspends services at expiry and removes them after the grace period. It only touches services that have an expiry date.

0 6 * * * www-data php /var/www/html/GSE/Panel/cron/cron-shop.php

Updating

Update the panel as usual. The storefront is part of it, so nothing separate is needed. Your site_config.local.php, the key file and the billing settings in the database are kept. After an update, open the storefront and run one test order.

Troubleshooting

SymptomCheck
Blank page or 500 errorThe web server user cannot read the panel tree, or PHP is missing a module. Read the site's error log.
/includes/ or /site_config.php opensApache: AllowOverride All and mod_rewrite are on, and you updated the panel to a version with the current .htaccess. nginx: the deny rules are in the server block.
Pages or images have broken linksbase_path is wrong for how you serve the site, or panel_base is missing.
Paid, but no serverCheck the webhook delivery log in PayPal, then the invoice in the billing admin. The webhook URL must be HTTPS and reachable from the internet.
Sign-in works on one site onlyExpected. Each host has its own session. Sign in on both.
An agent shows offline on the status pageThe agent is down or the panel cannot reach it. Open its page under Remote Agents.

Security notes