White-Label Custom Domain Guide for the Card2Crypto API

In this tutorial you'll learn how to run the Card2Crypto payment gateway on your own custom domain — instead of api.card2crypto.org and pay.card2crypto.org — using a free Cloudflare Worker. Your customers never see the Card2Crypto brand; every request is silently proxied through your own domain. You can also apply through our White-Label Affiliate program to earn a share of every transaction that runs through your branded gateway.

There are 4 steps:

  1. Move your domain's DNS to Cloudflare (the free plan works fine).
  2. Create a free Cloudflare Worker with a small proxy script.
  3. Route your domain(s) to that Worker.
  4. Optional: register for the White-Label Affiliate program so your commission wallet is baked into every transaction.

Step 1 — Move your domain to Cloudflare DNS

  1. Create a free Cloudflare account.
  2. Add your domain to Cloudflare's free DNS service.
  3. Cloudflare will give you two custom nameservers (NS records) unique to your account.
  4. Go to your domain registrar and replace the existing nameservers with the ones Cloudflare gave you.
    Cloudflare Nameservers
    Example of the custom nameservers Cloudflare assigns to your account.
  5. Once propagated, your domain will show as "Active" in Cloudflare.
  6. Create a proxied (orange cloud) DNS A record for every subdomain you plan to use with the Card2Crypto API. The IP address itself doesn't matter — Cloudflare will proxy it through your Worker instead. In this example we're using api.yourdomain.com and payment.yourdomain.com (Replace yourdomain.com)
    Cloudflare DNS records
    Add one proxied A record per subdomain you want to white-label.
  7. Repeat for every subdomain you need — one A record per domain/subdomain.
    Cloudflare A record
    The IP address is a placeholder only — routing happens at the Worker level.

Step 2 — Create a Cloudflare Worker

  1. From your Cloudflare dashboard, go back to the main account page.
    Cloudflare dashboard
  2. Open the Workers & Pages tab.
    Cloudflare workers
  3. Click Create application to spin up a new Worker.
  4. Open the new Worker's settings and click Edit code.
    Edit Cloudflare worker code
  5. Select all the default code in the editor, delete it, and paste in the worker code from below. Just change payment.yourdomain.com to your own domain. But do not change api.card2crypto.org in worker code.
    worker.js
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    async function handleRequest(request) {
      // Define the target URL to cloak (Don't change this)
      const targetUrl = 'https://api.card2crypto.org';
      const url = new URL(request.url);
      url.hostname = new URL(targetUrl).hostname;
      // Add the domain parameter to the URL while preserving the existing search params
      if (!url.pathname.includes('process-payment.php')) {
        url.search += (url.search ? '&' : '') + 'domain=payment.yourdomain.com';
      }
      const modifiedRequest = new Request(url.toString(), {
        method: request.method,
        headers: {
          ...Object.fromEntries(request.headers),
          'PGTO-IPCountry': request.cf?.country || 'XX'
        },
        body: request.body ? request.clone().body : null,
        redirect: 'manual'
      });
      // Make a request to the target URL
      const response = await fetch(modifiedRequest);
      if (response.status >= 300 && response.status < 400) {
        return response;
      }
      // Check if the response status code is in the 40X range and redirect to custom error page
      if (response.status >= 400) {
        return Response.redirect('yourdomain.com/404', 302);
      }
      // Clone the response to modify headers
      const modifiedResponse = new Response(response.body, response);
      // Set headers to cloak the origin
      modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');
      return modifiedResponse;
    }
  6. Click Deploy. The free Cloudflare plan includes 100,000 requests/day at no cost.
Before you deploy: Leave api.card2crypto.org untouched — that's the upstream endpoint the Worker is cloaking.

Step 3 — Route your domain to the Worker

  1. From your Worker's settings, add a custom domain or a custom route.
  2. Add a route for each subdomain using a wildcard, e.g. api.yourdomain.com/* and pay.yourdomain.com/*.
    Custom domain API
    The * wildcard makes the route match every path on that subdomain.
  3. Once saved, your domain behaves exactly like api.card2crypto.org and payment.card2crypto.org.
  4. Test it by calling any endpoint from the Card2Crypto API documentation against your own domain instead.

Re-branding plugins & modules

Our WooCommerce, WHMCS, PrestaShop, and OpenCart plugins are free to re-brand. Once your custom domain is live, simply replace every instance of api.card2crypto.org and pay.card2crypto.org inside the plugin code with your own domain. If your Worker script includes your embedded affiliate wallet, the commission is applied automatically on every transaction — your sub-merchants never see it and can't remove it.

Earning on sub-merchant volume: the White-Label Affiliate program lets you set your own commission on top of every payment that runs through your branded gateway, with your wallet hidden inside the Worker script instead of exposed in the plugin. Apply to become a partner →

Ready to launch your own branded gateway?

No KYC, no chargebacks, instant USDC settlement on Polygon — under your own domain.

Apply for White-Label →