Skip to content

Step 2: Deploy Cloudflare Workers Payment Gateway ​

FastTMA adheres to a zero-trust client security model: the client-side WebGL runtime never stores your Telegram Bot Token. All payment invoice links and transaction signatures are mediated securely through an official serverless gateway.


Phase 1: Create Worker in Cloudflare ​

  1. Log in to the Cloudflare Dashboard. In the left sidebar, navigate to Compute (Workers & Pages). Cloudflare Workers Menu

  2. Click Create application, select Create Worker, and choose "Let's start with Hello World!". Create Worker

  3. Name & Initial Deploy: Enter a name for the Worker (e.g., fasttma-payment-gateway), then click Deploy at the bottom-right corner. Deploy Worker


Phase 2: Deploy Gateway Middleware Code ​

  1. On the Worker details overview page, click Edit code in the top-right corner to open the Cloudflare Web IDE. Edit Code

  2. In your Unity project, locate and open Packages/com.fasttma.core/Serverless/cloudflare-worker.js, then copy all source code. Copy worker.js in Unity

  3. Return to the Cloudflare editor, overwrite all contents of worker.js with the copied code, and click Deploy in the top-right corner. Paste Code and Deploy


Phase 3: Configure BOT_TOKEN Environment Secret ​

  1. Return to the Worker management page, select the Settings tab, and click Runtime variables and secrets on the left. Variables Settings

  2. Click Add variable and configure the field:

    • Key: Enter BOT_TOKEN (uppercase, exact match).
    • Value: Paste the Bot API Token obtained from @BotFather in Step 1.
    • Type: Check Secret (encrypts the credential to prevent plain-text exposure). Add BOT_TOKEN Secret
  3. Click Add 1 variable (or Save and Deploy) to commit the configuration.


Phase 4: Unity Configuration & Connectivity Verification ​

  1. Copy Gateway Endpoint: On the Worker overview page, copy the public URL (formatted as https://fasttma-payment-gateway.<subdomain>.workers.dev). Copy Worker URL

Trailing Slash Rule

Do NOT include a trailing slash (/) at the end of the URL.

  1. Open Unity Settings Panel: In the Unity top menu bar, select Edit $\rightarrow$ Project Settings $\rightarrow$ FastTMA (or Tools $\rightarrow$ FastTMA $\rightarrow$ Settings). Open Settings in Unity

  2. Asset Self-Healing: If Asset Status displays a red Error indicating a missing asset, click Create / Rebuild Settings Asset to generate it instantly.

  3. Assign Gateway URL: Paste the Worker HTTPS URL into the Telegram Pay Url field (the address must begin with https://).

  4. Perform Connectivity Test: Click Apply on the right side. Unity will send a 2-second hard-timeout preflight probe to the gateway. Verify Connectivity

  5. Once the dialog confirms:

    ✅ Success! The Telegram Pay Gateway is online and reachable.

    The Asset Status indicator turns green (Success), verifying the payment infrastructure is online.

Empowering Telegram Mini App & WebGL developers worldwide.