Add to your Website
You can integrate in two ways: a one-line drop-in script (easiest), or a server-side API call (most flexible).
Option A — Drop-in script
Add a single script tag and any element with data-fastpayglobal becomes a checkout button.
html
<!-- 1. Include the script -->
<script src="https://fastpayglobal.app/pay.js" defer></script>
<!-- 2. Add a button anywhere on your page -->
<button data-fastpayglobal
data-public-key="pk_live_xxxxxxxxxxxx"
data-amount="500"
data-currency="BDT"
data-order-id="ORDER-12345"
data-customer-name="John Doe"
data-customer-email="john@example.com">
Pay ৳500
</button>Programmatic usage:
html
<script src="https://fastpayglobal.app/pay.js" defer></script>
<script>
document.getElementById("buy").onclick = () => {
FastPay Global.checkout({
publicKey: "pk_live_xxxxxxxxxxxx",
amount: 500,
currency: "BDT",
orderId: "ORDER-12345",
customer: { name: "John", email: "john@example.com" },
mode: "redirect", // or omit for popup
});
};
</script>Option B — Server-side API
Call our API from your backend, then redirect the customer to the returned paymentUrl.
cURL
curl -X POST https://fastpayglobal.app/api/public/create-payment \
-H "content-type: application/json" \
-H "x-public-key: pk_live_xxxxxxxxxxxx" \
-d '{
"amount": 500,
"currency": "BDT",
"orderId": "ORDER-12345",
"customer": { "name": "John", "email": "john@example.com" }
}'Node.js
// Node.js (server-side)
const res = await fetch("https://fastpayglobal.app/api/public/create-payment", {
method: "POST",
headers: {
"content-type": "application/json",
"x-public-key": process.env.FASTPAYGLOBAL_PUBLIC_KEY,
},
body: JSON.stringify({
amount: 500,
currency: "BDT",
orderId: "ORDER-12345",
customer: { name: "John", email: "john@example.com" },
}),
});
const { paymentId, paymentUrl } = await res.json();
// Redirect the customer
return Response.redirect(paymentUrl, 302);PHP
<?php
$ch = curl_init("https://fastpayglobal.app/api/public/create-payment");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-Public-Key: " . getenv("FASTPAYGLOBAL_PUBLIC_KEY"),
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"amount" => 500,
"currency" => "BDT",
"orderId" => "ORDER-12345",
]));
$response = json_decode(curl_exec($ch), true);
header("Location: " . $response["paymentUrl"]);Verify the webhook
When the customer pays, we POST a signed webhook to your webhook_url. Verify the signature with your brand's webhook secret.
Express
// Verify FastPay Global webhook signature
import { createHmac, timingSafeEqual } from "node:crypto";
app.post("/webhooks/fastpayglobal", express.raw({ type: "*/*" }), (req, res) => {
const signature = req.header("x-fastpayglobal-signature") || "";
const expected = createHmac("sha256", process.env.FASTPAYGLOBAL_WEBHOOK_SECRET)
.update(req.body) // raw body
.digest("hex");
const ok = signature.length === expected.length &&
timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
if (!ok) return res.status(401).send("invalid signature");
const event = JSON.parse(req.body.toString());
if (event.event === "payment.succeeded") {
// mark order as paid in your DB using event.orderId
}
res.send("ok");
});