White-label API Custom Domain Guide

In this tutorial you will learn how to use your own custom domain with our payment gateway API. Your own domain and a dedicated API endpoint are now required: the shared api.paygate.to and checkout.paygate.to addresses no longer accept requests. You will also be able to optionally insert your affiliate wallet to earn your desired percentage on every sale your sub-merchant receive.

Get Your Dedicated API Endpoint

Every store and integration needs its own free dedicated API endpoint (also called a signer). It is a DDoS-protected PayGate address of your own, such as api-yourshop-1a2b3c4d5e6f7a8b9c0d1e2f.paygate.to. It takes a few seconds:

  1. Open the endpoint form on this page and enter your website (it is shown in your endpoint name).
  2. Tick the Verify you are human box, then press Get my dedicated endpoint.
    Dedicated API endpoint form with the website field, the human check and the Get my dedicated endpoint button
  3. Copy your endpoint. The form shows where to paste it in each plugin.
    The issued dedicated API endpoint with a Copy button and the plugin tabs that show where to paste it

Then choose how customers reach your checkout domain: with a free Cloudflare worker (the steps below), or with your own server.

Use a Cloudflare Worker

You need to make 4 steps:

  1. Your domain name must be using Cloudflare DNS service (free account plan will work fine).
  2. Create a free Cloudflare worker with our JS code to use our API.
  3. Connect your domain to the worker with one click (Add Domain). No DNS records or routes needed.
  4. Optionally you can insert your affiliate wallet within the code and redistribute our plugins to earn percentage on your sub-merchant sales.

Use Cloudflare DNS

  1. Create a free Cloudflare account
  2. Add your domain name to use the free Cloudflare DNS service (Domains → Add domain → Connect a domain).
    Cloudflare Connect your domain
  3. After adding your domain you will be instructed to change your domain’s nameservers (NS) records
  4. Go to your domain registrar where you registered your domain and use the custom nameservers provided in your Cloudflare account. Those nameservers are different for each account.
    Cloudflare Nameservers
  5. After completing the previous steps your domain should be actively using Cloudflare. You don't need to add any DNS records for the API: Cloudflare creates them when you connect the domain to your worker below.

Create a Cloudflare Worker

  1. In the Cloudflare dashboard sidebar open Compute → Workers & Pages.
    Cloudflare Compute, Workers & Pages
  2. Press the Create application button.
    Cloudflare Create application
  3. Choose Start with Hello World! This creates an empty worker you will replace with our code.
    Cloudflare Start with Hello World
  4. Name the worker (for example paygate-api) and press Deploy.
    Name and deploy the Cloudflare worker
  5. On the new worker's page press Edit code.
    Edit Cloudflare worker code.
  6. Select all the Hello World code in the editor, delete it and paste our worker.js code instead. We offer two versions: standard worker.js will allow you to use your own custom domain without an affiliate wallet injection this will simply allow you to use your custom domain with our API.
    Optionally you can use the affiliate version worker.js which will allow you to use your hidden affiliate USDC (Polygon) wallet to earn 0.5% on every sale that go through your custom domain. Make sure to replace the wallet in the example code with your own USDC wallet to receive earnings.
    ⚠️ Replace the targetUrl address with your own dedicated API endpoint, then change the wallet address and set a custom error page. Never put your own domain in targetUrl.
    Dedicated API endpoint
    The targetUrl in the worker is PayGate's address, not your own domain; your domain is connected in the worker's Domains tab. Set targetUrl to your free dedicated API endpoint (required: the shared address no longer accepts requests). The automatic generator above gets one for you and makes the change.
    API custom domain code
  7. Press Deploy in the editor to publish the code.
    Paste the code and deploy the Cloudflare worker
    The free Cloudflare plan will allow you to use 100,000 request per day with your own custom domain free of charge.

Connect Your Custom Domain to the Worker

  1. Open the worker's Domains tab and press Add Domain.
    Cloudflare worker Domains tab, Add Domain
  2. Choose your domain and enter the subdomain for your API, for example api.example.com. Cloudflare creates the DNS record and the SSL certificate automatically, so there are no DNS records or routes to set up. If that subdomain already has a DNS record, delete it first.
  3. Press Add Domain again for your payment page address, for example payment.example.com. Your customers see this address on the hosted card and multi-coin crypto payment pages.
  4. After a minute or two your domain answers every PayGate API request. Enter it in the API Domain (or Custom API Domain) setting of your PayGate plugin, and your payment page address as the plugin's checkout domain (Custom Domain).
  5. You can follow the API Docs for testing.
  6. Using the standard worker.js your domain will work exactly the same as the original API and in case you inserted the affiliate worker.js with your affiliate wallet hidden in the JS code; the parameter affiliate wallet will be added to each request.

Use Your Own Server Instead of Cloudflare

You can skip Cloudflare completely. Use your dedicated endpoint directly as the API Domain, and serve your checkout domain from a server you already run:

  1. Point a subdomain such as checkout.example8585859.com at your server and give it an HTTPS certificate.
  2. Set the subdomain up as a reverse proxy that forwards every request to https:// + your dedicated endpoint, keeping the path, the query string, the method and the body.
  3. Connect to your endpoint over HTTPS with the endpoint's own name as the host name (Host header and SNI), and pass the answer back unchanged, including redirects.
  4. Enter the subdomain as the checkout domain (Custom Domain) in your plugin. The plugins add it to every payment page link (the domain parameter), so the hosted pages build their links and requests on your domain.

The same proxy can also serve your own API domain (for example api.example8585859.com). Affiliate commissions that the worker files add for you are passed as request parameters instead; see the affiliate endpoints.

Earning Affiliate Commission and White-label Plugins and Modules

  • All our plugins and modules are open-source and available to be modified or re-branded you can visit our GitHub to access all code.
  • You can easily re-brand all  plugins or modules. Every plugin asks for your own API domain (or dedicated endpoint) and checkout domain in its settings, so your sub-merchants enter the custom domains configured in the previous steps.
  • When you use the affiliate worker.js for your custom domain the affiliate parameter wallet will be added to every request without the need to insert it in the plugin code. This maybe useful to prevent your sub-merchant from removing your wallet or bypass your commission.
  • Feel free to contact our support for any questions.

Which worker.js File to Select

There are different ready made worker.js files you will probably need one of them only per your use case.