How custom domains work
When a request arrives, OwnPay’sDomainMiddleware inspects the HTTP_HOST header and resolves it against the op_domains table. If it matches a brand’s custom domain, OwnPay injects that brand’s merchant_id into the request context and loads its visual identity.
Domain types
The master domain (configured via the
APP_DOMAIN environment variable) is the only domain that can access the admin panel (/admin/*). Custom domains return a 404 for admin routes - this is a security feature, not a bug.
DNS configuration
Point your custom domain to your OwnPay server using one of these records:If you already have an A record on the root domain, a CNAME for the
pay subdomain is usually the cleanest approach.Domain verification flow
1
Add the domain in OwnPay
Go to System > Domains, click Add Domain, and enter
pay.yourbrand.com. Set the domain type to checkout and assign it to your brand.2
Configure DNS
Add the A or CNAME record at your DNS provider. DNS propagation typically takes a few minutes to a few hours.
3
Verify DNS
Click Verify DNS in the OwnPay domain settings. OwnPay performs a DNS lookup and checks that the record points to your server. Once verified,
dns_verified is set to 1.4
SSL is provisioned
After DNS verification, OwnPay provisions an SSL certificate for the domain. Checkout pages are served over HTTPS automatically.
URL generation
All customer-facing and gateway-facing URLs are built byDomainUrlService - never hardcoded. The priority order is:
GATEWAY_CALLBACK_URLenvironment variable- Brand’s custom domain
APP_URLfrom.env- Current request host
If you need to generate a checkout or callback URL in your code, always use
DomainUrlService methods like buildCheckoutUrl() and buildCallbackUrl(). Hardcoding URLs will break when brands use custom domains.Related pages
- System - Domains - step-by-step setup guide with troubleshooting
- Appearance - Branding - customize logos, colors, and checkout design
- Brands - understand brand-level isolation and settings
- How OwnPay works - full architecture overview
- Payment flow - how the checkout page fits into the transaction lifecycle