Get your dream built 10x faster

Replit and Worldpay Integration: 2026 Guide

We build custom applications 5x faster and cheaper 🚀

Book a Free Consultation
4.9
Clutch rating 🌟
600+
Happy partners
17+
Countries served
190+
Team members
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Stuck on an error? Book a 30-minute call with an engineer and get a direct fix + next steps. No pressure, no commitment.

Book a free consultation

How to Integrate Replit with Worldpay

To integrate Replit with Worldpay, you’ll connect your Repl (as your server backend) to Worldpay’s payment API or hosted payment pages. In Replit, you’ll typically use Node.js with Express or Python with Flask to create routes that accept checkout requests, verify webhooks from Worldpay, and securely handle API keys via Replit’s Secrets. Worldpay sends payment confirmation webhooks to your Repl’s public URL, so your Repl must be running and listen on 0.0.0.0 with an exposed port (like 3000). You securely store your Worldpay credentials (Service Key, Client Key, maybe installation ID if you’re using older setups) in Replit Secrets, and call Worldpay’s REST API from your application for transactions or token creation. The workflow is explicit — your Repl doesn’t magically “connect,” you use HTTPS requests (REST) or redirect users to Worldpay’s hosted checkout page, and handle success/failure data via webhooks or redirects.

 

Understand the Components

 

  • Worldpay API or hosted payment page: This is Worldpay’s system that processes your payments. You’ll use their REST endpoints (for JSON-based interactions) or redirect users to their checkout pages.
  • Your Repl server: Acts as your backend where you communicate to Worldpay (send requests, receive webhooks, store order info).
  • Environment Variables in Replit: Store secrets like WORLDPAY_SERVICE_KEY in the Secrets tab instead of hardcoding them.
  • Webhook URL: A route (like /worldpay/webhook) that receives payment status updates from Worldpay. This has to be accessible from outside — meaning your Repl must be running, and port exposed.

 

Setup in Replit

 

  • Create a Repl using Node.js (for this example).
  • Go to Tools → Secrets, and add your WORLDPAY_SERVICE_KEY and any other credentials.
  • Add Worldpay’s API endpoint to your code (for sandbox or live, depending on your account): for example, https://api.worldpay.com/v1/orders.

 

// Example: basic Node.js + Express server for Worldpay integration

import express from "express"
import fetch from "node-fetch"  // For REST API calls

const app = express()
app.use(express.json())

// Create a payment order route
app.post("/create-order", async (req, res) => {
  try {
    const response = await fetch("https://api.worldpay.com/v1/orders", {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${process.env.WORLDPAY_SERVICE_KEY}`, // Secure key from Secrets
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        amount: 1000, // Value in minor currency units (e.g., pence if GBP)
        currencyCode: "GBP",
        name: "Example Order",
        orderDescription: "Test purchase",
        customerOrderCode: "order123"
      })
    })
    const data = await response.json()
    res.send(data)
  } catch (err) {
    console.error(err)
    res.status(500).send({ error: "Payment creation failed" })
  }
})

// Webhook endpoint that receives payment updates from Worldpay
app.post("/worldpay/webhook", (req, res) => {
  // Verify the signature per Worldpay docs
  console.log("Webhook received:", req.body)
  res.sendStatus(200)
})

// Replit needs binding to 0.0.0.0
app.listen(3000, "0.0.0.0", () => {
  console.log("Server running on port 3000")
})

 

Test Sandbox and Expose Webhooks

 

  • Use Worldpay’s Sandbox keys first. It’s a test environment mimicking production transactions without charging real money.
  • When your Repl is running, copy your Repl’s public URL (something like https://your-repl-name.username.repl.co/worldpay/webhook).
  • Add that URL in your Worldpay account as the webhook notification URL so Worldpay can inform your backend when a transaction completes.

 

Secure and Deploy

 

  • Never expose your service keys publicly or send them to the frontend; only make payment intent or order creation calls from the backend.
  • Store all credentials in Replit Secrets and reference via process.env.
  • Once integration works in sandbox, switch to live keys for production.

 

Conceptual Flow Summary

 

  • Your Repl creates an order or payment intent using Worldpay’s API.
  • User completes payment on hosted page (or via client SDK if used).
  • Worldpay sends a webhook to your Replit endpoint with payment status.
  • Your app updates order state or acknowledges payment completion.

 

This integration is realistic, transparent, and aligned with how Replit actually runs full-stack web apps — through explicit HTTP routes, secret management, and exposed ports, connecting directly via Worldpay’s documented REST APIs.

Use Cases for Integrating Worldpay and Replit

1

Online Store Payment Checkout

Connect your Replit-hosted Node.js or Python app to Worldpay’s REST API for secure online payments. The app runs inside a Repl, serves via a port bound to 0.0.0.0, and handles checkout forms that send payment data to your back-end. You store sensitive keys like WORLDpay_SERVICE_KEY and WORLDpay_CLIENT_KEY in Replit Secrets, avoiding hardcoding credentials. Your backend creates payment orders, passes transaction details (amount, currency, description), and redirects the user once a valid payment response is received. The flow uses real-time API requests to start and confirm a transaction, allowing you to test payments directly within the Repl using Worldpay’s Sandbox environment.

  • Front-end calls your API endpoint hosted on Replit.
  • Server communicates with Worldpay using an HTTPS request and awaits result.
  • Webhook endpoint confirms success when Worldpay notifies payment outcome.
// Node.js example handling payment session creation
import express from "express";
import fetch from "node-fetch";
const app = express();

app.post("/create-session", async (req, res) => {
  const response = await fetch("https://try.access.worldpay.com/sessions", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.WORLDPAY_SERVICE_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      amount: 5000,
      currencyCode: "USD",
      orderType: "ECOM"
    })
  });
  const data = await response.json();
  res.json(data);
});

app.listen(3000, "0.0.0.0", () => console.log("Server running"));

2

Online Store Payment Checkout

In Replit, use Workflows and server routes to handle Worldpay webhooks. When a payment completes or fails, Worldpay sends a signed POST request to your webhook endpoint. You verify its authenticity by using HMAC hashing or JWT validation (per Worldpay docs). The Repl must be actively running for Worldpay to reach it — in development, use the Replit webview URL for webhook receiver tests. Store verification secrets as environment vars and log events in your console or database. Use this flow to keep order statuses in sync with your application automatically.

  • Expose secure endpoint like /webhook through mapped Replit port.
  • Verify incoming header signatures.
  • Update payment status in your Repl’s in-memory store or external DB.
// Express webhook endpoint verifying incoming payload
import crypto from "crypto";

app.post("/webhook", express.json(), (req, res) => {
  const signature = req.headers["x-worldpay-signature"];
  const expected = crypto
    .createHmac("sha256", process.env.WORLDPAY_WEBHOOK_SECRET)
    .update(JSON.stringify(req.body))
    .digest("hex");

  if (signature !== expected) return res.status(401).send("Invalid signature");

  console.log("Payment update received:", req.body);
  res.sendStatus(200);
});

3

Subscription or Membership Billing

Use Replit’s runtime to prototype a subscription management system connected to Worldpay’s recurring payments API. The app periodically creates, cancels, or retrieves existing subscriptions via HTTPS requests. Setup is simple: add Worldpay keys as Secrets, deploy with Workflows, and store customer references in a small hosted DB (for persistence, use external service). This integration enables safe recurring billing demos where subscription changes trigger Worldpay API calls and confirmation webhooks, which help simulate real SaaS billing flows for testing or onboarding prototypes.

  • Initialize recurring payment plans in Worldpay’s portal.
  • Trigger API calls from Replit backend to process renewals.
  • Handle webhook confirmations to refresh user access or status.
# Simple Python example for creating a recurring agreement
import os, requests

url = "https://try.access.worldpay.com/recurring/orders"
headers = {
    "Authorization": f"Bearer {os.environ['WORLDPAY_SERVICE_KEY']}",
    "Content-Type": "application/json"
}
payload = {
    "recurring": {"agreementType": "RECURRING"},
    "amount": 1000,
    "currencyCode": "USD",
    "orderType": "RECURRING"
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())

Book Your Free 30‑Minute Migration Call

Speak one‑on‑one with a senior engineer about your no‑code app, migration goals, and budget. In just half an hour you’ll leave with clear, actionable next steps—no strings attached.

Book a Free Consultation

Troubleshooting Worldpay and Replit Integration

1

Why is the Worldpay API key not loading correctly from Replit Secrets?

The Worldpay API key usually fails to load from Replit Secrets because the secret name or reference in your code doesn't exactly match what was defined, or the environment wasn’t refreshed after setting the secret. Always ensure the spelling and casing of the secret key name are identical, the Repl is restarted after adding new secrets, and you’re not trying to access it from the wrong context (like a stopped or inactive Deployment).

 

How to Diagnose and Fix

 

  • Open the Secrets panel (lock icon next to "Tools") and confirm the secret name, e.g. WORLDPAY_API_KEY.
  • Restart the Repl so environment variables are injected, otherwise process.env won’t update.
  • Check code spelling; environment variable names are case-sensitive.
  • Check runtime; Secrets only load when Repl is running, not in Deployments unless redeployed with new variables.

 

// Correct example for reading secret inside index.js
const worldpayKey = process.env.WORLDPAY_API_KEY;

if (!worldpayKey) {
  console.error("Worldpay API key not loaded. Check Replit Secrets and restart the Repl.");
} else {
  console.log("Worldpay key loaded successfully.");
}

 

The key principle: Replit injects secrets as environment variables at start. Any typo, missing restart, or mismatch between secret name and variable reference prevents them from loading.

2

How to fix callback URL mismatch between Worldpay dashboard and Replit web server URL?

The mismatch happens when the callback (redirect or webhook) URL configured in your Worldpay dashboard doesn’t exactly match the live URL of your Replit server. To fix this, copy your current running Repl’s public URL (the one that looks like https://your-repl-name.username.repl.co) and paste it as the callback URL in Worldpay’s settings, making sure the path also matches (for example /webhook/worldpay). Any protocol, trailing slash, or path mismatch will cause an error.

 

Check and Sync URLs Step-by-Step

 

  • Run your Repl — the URL shown in the browser bar is your actual public server URL.
  • Use exact path in your route; if Worldpay sends callbacks to /callback, make sure your Express app defines the same endpoint.
  • Update Worldpay dashboard → API settings → Callback or Redirect URL → paste your full Replit URL + path.
  • Restart your Repl and test using a dummy transaction or webhook tester to confirm that Worldpay reaches your endpoint.

 

// Example Express server handling Worldpay callback
import express from "express";
const app = express();
app.use(express.json());

app.post("/webhook/worldpay", (req, res) => {
  console.log(req.body); // Inspect payload
  res.sendStatus(200);   // Acknowledge receipt
});

app.listen(3000, "0.0.0.0", () => console.log("Server ready"));

 

Remember: if you fork or stop/start your Repl, the public URL may change; in that case, repeat updating it in Worldpay.

3

Why is the Replit Flask server timing out after redirect from Worldpay payment page?

The Replit Flask server times out after redirect from the Worldpay payment page because Replit projects (Repls) go to sleep or restart when idle or after short inactivity. When Worldpay sends the customer back to your callback URL, the Repl often isn’t running, so the request hits a cold container start, adding 5–10 seconds delay. Combined with payment gateway timeout limits, this causes a connection failure before Flask can respond.

 

How to Fix

 

  • Keep the Repl alive by running it continuously or deploy via Replit Deployments (always-on instances).
  • Use Worldpay’s test webhook (server-to-server callback) instead of browser redirect to verify the payment, since that works even if your frontend sleeps.
  • Ensure correct port binding — Replit requires app.run(host="0.0.0.0", port=8000) and port 8000 mapped in the “Expose” section for Workflows.
  • Log incoming requests to confirm Worldpay hits the right route.

 

from flask import Flask, request
app = Flask(__name__)

@app.route("/payment-return")
def payment_return():
    print("Worldpay redirect:", request.args)
    return "Received", 200

app.run(host="0.0.0.0", port=8000)  # required for Replit

 

For production, host the payment callback endpoint on an always-on service (like a small VPS or serverless function) and forward results back to Replit via API.

Book a Free Consultation

Schedule a 30‑Minute No‑Code‑to‑Code Consultation

Grab a quick video call to discuss the fastest, most cost‑efficient path from no‑code to production‑ready code. Zero sales fluff—just practical advice tailored to your project.

Contact us

Common Integration Mistakes: Replit + Worldpay

Unverified Webhook Signatures

Worldpay sends event notifications (like payment approvals) through webhooks. On Replit, developers often forget to verify these incoming payloads using Worldpay's HMAC signature. Without that check, anyone could trigger fake payment events. Always capture the Authorization header from Worldpay, compute your own HMAC with the shared secret key saved inside Replit Secrets, and compare values before processing.

  • Store your Worldpay webhook secret in Secrets (never plain text).
  • Bind your Express server to 0.0.0.0 and expose a port.
import express from "express";
import crypto from "crypto";

const app = express();
app.use(express.raw({ type: "application/json" }));

app.post("/webhook", (req, res) => {
  const signature = req.get("Authorization");
  const computed = crypto
    .createHmac("sha256", process.env.WORLDPAY_WEBHOOK_SECRET)
    .update(req.body)
    .digest("hex");
  if (signature !== computed) return res.status(401).end();
  res.sendStatus(200);
});

app.listen(3000, "0.0.0.0");

Missing HTTPS during OAuth or API Calls

Replit preview URLs use HTTPS, but local port URLs (like http://localhost:3000) don’t. Worldpay’s API requires secure endpoints for redirects, tokens, and callbacks. Testing insecure endpoints in Replit leads to invalid redirect URI errors. Always use the Replit-provided HTTPS URL when registering callbacks in the Worldpay dashboard, and confirm it matches your Repl domain exactly.

  • Don’t use http://localhost in production-like tests on Replit.
  • Copy the “Open in new tab” Replit URL (starts with https://) to register at Worldpay.

Exposing Secrets in Client Code

A frequent mistake is putting Worldpay keys directly into the frontend JavaScript. In Replit, code in script.js or public files is visible to anyone. Only backend (Node.js or Python) can safely read secrets from process.env through Replit Secrets. The client should talk to your Replit backend, which then communicates with Worldpay’s API using those hidden keys.

  • Use Secrets for WORLDPAY_SERVICE_KEY and WORLDPAY_CLIENT_KEY.
  • Proxy client actions via backend routes.
// server.js
app.post("/payment", async (req, res) => {
  const response = await fetch("https://try.access.worldpay.com/payments", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env.WORLDPAY_SERVICE_KEY,
      "Content-Type": "application/json"
    },
    body: JSON.stringify(req.body)
  });
  res.send(await response.json());
});

Not Handling Replit Runtime Restarts

Replit Repls idle and restart — in-memory sessions disappear. Developers sometimes keep payment session IDs or order statuses only in memory. When Replit restarts, those pending states vanish, breaking reconciliation with Worldpay. Always persist key data externally: lightweight database (like SQLite file in Replit filesystem) or external DB service. Store minimal reference data locally and periodically sync with Worldpay API.

  • Save pending order IDs or tokens in a file or remote DB.
  • Query Worldpay by order ID after restart to restore context.
import fs from "fs";

// Simple persistence example
function saveOrder(order) {
  const current = JSON.parse(fs.readFileSync("orders.json", "utf8") || "[]");
  current.push(order);
  fs.writeFileSync("orders.json", JSON.stringify(current, null, 2));
}

Still stuck?
Copy this prompt into ChatGPT and get a clear, personalized explanation.

This prompt helps an AI assistant understand your setup and guide you through the fix step by step, without assuming technical knowledge.

AI AI Prompt


Recognized by the best

Trusted by 600+ businesses globally

From startups to enterprises and everything in between, see for yourself our incredible impact.

RapidDev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with.

They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

Arkady
CPO, Praction
Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost.

He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Donald Muir
Co-Founder, Arc
RapidDev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space.

They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Mat Westergreen-Thorne
Co-CEO, Grantify
RapidDev is an excellent developer for custom-code solutions.

We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Emmanuel Brown
Co-Founder, Church Real Estate Marketplace
Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 

This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Samantha Fekete
Production Manager, Media Production Company
The pSEO strategy executed by RapidDev is clearly driving meaningful results.

Working with RapidDev has delivered measurable, year-over-year growth. Comparing the same period, clicks increased by 129%, impressions grew by 196%, and average position improved by 14.6%. Most importantly, qualified contact form submissions rose 350%, excluding spam.

Appreciation as well to Matt Graham for championing the collaboration!

Michael W. Hammond
Principal Owner, OCD Tech

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We’ll discuss your project and provide a custom quote at no cost.Â