White-label API Custom Domain Guide

In this tutorial you will learn how to use your own custom domain with our payment gateway API. You will be able to use your own domain instead of api.paygate.to and checkout.paygate.to. You will also be able to optionally insert your affiliate wallet to earn your desired percentage on every sale your sub-merchant receive.

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.
    ⚠️ Don't change the API domain name in the code you need to change the wallet address and set a custom error page only.
    Dedicated API endpoint
    api.paygate.to in the worker is PayGate's address, not your own domain; your domain is connected in the worker's Domains tab. For the best protection, replace only the targetUrl host with your free dedicated API endpoint. 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 you want to use instead of api.paygate.to, 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 instead of checkout.paygate.to. Your customers see this address on the hosted card and multi-coin crypto payment pages.
  4. After a minute or two your domain works the same way as api.paygate.to. Use it wherever you used api.paygate.to, for example in the API Domain (or Custom API Domain) setting of your PayGate plugin.
  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.

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. You can replace all instances of api.paygate.to and checkout.paygate.to within the code with your own custom domain 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.