TakaElo

Developers

Integrate in an afternoon

One API call to create a checkout, four webhooks to handle, tested examples in eight languages — and a free sandbox to try it all.

How it works

  1. 1

    Get a test key

    Every account has a free sandbox key (sk_test_…) from the first minute.

  2. 2

    Create a checkout

    Send the amount and your order id. You get back a checkout URL on your shop address.

  3. 3

    Redirect the customer

    They pick bKash, Nagad, Rocket or Upay and send money the way they always do.

  4. 4

    Handle one webhook

    When the money arrives we POST payment.completed to you, signed. Then the customer comes back to your site.

  5. 5

    Go live

    Swap sk_test_ for sk_live_. Nothing else changes.

Create a checkout

curl https://api.takaelo.com/v1/checkouts \
  -H "Authorization: Bearer $TAKAELO_SECRET_KEY" \
  -H "Idempotency-Key: order-4821-1" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 1250,
    "reference": "ORD-4821",
    "success_url": "https://yourshop.com/orders/4821/thanks",
    "cancel_url": "https://yourshop.com/cart",
    "customer": { "name": "Rahim Uddin", "phone": "01712345678" },
    "metadata": { "order_id": "4821" }
  }'
<?php
$ch = curl_init('https://api.takaelo.com/v1/checkouts');
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('TAKAELO_SECRET_KEY'),
        'Idempotency-Key: order-4821-1',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'amount'      => 1250,
        'reference'   => 'ORD-4821',
        'success_url' => 'https://yourshop.com/orders/4821/thanks',
        'cancel_url'  => 'https://yourshop.com/cart',
        'customer'    => ['name' => 'Rahim Uddin', 'phone' => '01712345678'],
        'metadata'    => ['order_id' => '4821'],
    ]),
]);
$body = json_decode(curl_exec($ch), true);

if (empty($body['success'])) {
    throw new RuntimeException($body['code'] . ': ' . $body['message']);
}

$checkout = $body['data'];
echo $checkout['id'] . ' ' . $checkout['url'] . PHP_EOL;
// In a web request, send the customer to pay:
// header('Location: ' . $checkout['url'], true, 303);
// Node 18+ (built-in fetch). Save as checkout.mjs and run: node checkout.mjs
const res = await fetch("https://api.takaelo.com/v1/checkouts", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TAKAELO_SECRET_KEY}`,
    "Idempotency-Key": "order-4821-1",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    amount: 1250,
    reference: "ORD-4821",
    success_url: "https://yourshop.com/orders/4821/thanks",
    cancel_url: "https://yourshop.com/cart",
    customer: { name: "Rahim Uddin", phone: "01712345678" },
    metadata: { order_id: "4821" },
  }),
});
const body = await res.json();
if (!body.success) throw new Error(`${body.code}: ${body.message}`);

const checkout = body.data;
console.log(checkout.id, checkout.url);
// In Express: res.redirect(303, checkout.url);
import json
import os
import urllib.error
import urllib.request

payload = {
    "amount": 1250,
    "reference": "ORD-4821",
    "success_url": "https://yourshop.com/orders/4821/thanks",
    "cancel_url": "https://yourshop.com/cart",
    "customer": {"name": "Rahim Uddin", "phone": "01712345678"},
    "metadata": {"order_id": "4821"},
}
request = urllib.request.Request(
    "https://api.takaelo.com/v1/checkouts",
    method="POST",
    data=json.dumps(payload).encode(),
    headers={
        "Authorization": "Bearer " + os.environ["TAKAELO_SECRET_KEY"],
        "Idempotency-Key": "order-4821-1",
        "Content-Type": "application/json",
    },
)
try:
    with urllib.request.urlopen(request) as response:
        checkout = json.load(response)["data"]
except urllib.error.HTTPError as e:
    error = json.load(e)
    raise SystemExit(f"{error['code']}: {error['message']}")

print(checkout["id"], checkout["url"])
# In Django / Flask: return redirect(checkout["url"])
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
)

func main() {
	payload, _ := json.Marshal(map[string]any{
		"amount":      1250,
		"reference":   "ORD-4821",
		"success_url": "https://yourshop.com/orders/4821/thanks",
		"cancel_url":  "https://yourshop.com/cart",
		"customer":    map[string]string{"name": "Rahim Uddin", "phone": "01712345678"},
		"metadata":    map[string]string{"order_id": "4821"},
	})
	req, _ := http.NewRequest(http.MethodPost, "https://api.takaelo.com/v1/checkouts", bytes.NewReader(payload))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("TAKAELO_SECRET_KEY"))
	req.Header.Set("Idempotency-Key", "order-4821-1")
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var body struct {
		Success bool   `json:"success"`
		Message string `json:"message"`
		Code    string `json:"code"`
		Data    struct {
			ID  string `json:"id"`
			URL string `json:"url"`
		} `json:"data"`
	}
	if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
		log.Fatal(err)
	}
	if !body.Success {
		log.Fatalf("%s: %s", body.Code, body.Message)
	}
	fmt.Println(body.Data.ID, body.Data.URL)
	// In a handler: http.Redirect(w, r, body.Data.URL, http.StatusSeeOther)
}
require "json"
require "net/http"

uri = URI("https://api.takaelo.com/v1/checkouts")
request = Net::HTTP::Post.new(uri,
  "Authorization" => "Bearer #{ENV.fetch("TAKAELO_SECRET_KEY")}",
  "Idempotency-Key" => "order-4821-1",
  "Content-Type" => "application/json")
request.body = {
  amount: 1250,
  reference: "ORD-4821",
  success_url: "https://yourshop.com/orders/4821/thanks",
  cancel_url: "https://yourshop.com/cart",
  customer: { name: "Rahim Uddin", phone: "01712345678" },
  metadata: { order_id: "4821" }
}.to_json

response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
body = JSON.parse(response.body)
raise "#{body["code"]}: #{body["message"]}" unless body["success"]

checkout = body["data"]
puts "#{checkout["id"]} #{checkout["url"]}"
# In Rails: redirect_to checkout["url"], allow_other_host: true
// Java 11+ HttpClient; JSON with Jackson (com.fasterxml.jackson.core:jackson-databind).
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;

public class CreateCheckout {
    public static void main(String[] args) throws Exception {
        ObjectMapper json = new ObjectMapper();
        String payload = json.writeValueAsString(Map.of(
            "amount", 1250,
            "reference", "ORD-4821",
            "success_url", "https://yourshop.com/orders/4821/thanks",
            "cancel_url", "https://yourshop.com/cart",
            "customer", Map.of("name", "Rahim Uddin", "phone", "01712345678"),
            "metadata", Map.of("order_id", "4821")));

        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.takaelo.com/v1/checkouts"))
            .header("Authorization", "Bearer " + System.getenv("TAKAELO_SECRET_KEY"))
            .header("Idempotency-Key", "order-4821-1")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();
        HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());

        JsonNode body = json.readTree(response.body());
        if (!body.path("success").asBoolean()) {
            throw new IllegalStateException(body.path("code").asText() + ": " + body.path("message").asText());
        }
        JsonNode checkout = body.get("data");
        System.out.println(checkout.get("id").asText() + " " + checkout.get("url").asText());
        // In Spring: return "redirect:" + checkout.get("url").asText();
    }
}
// .NET 6+ top-level program: dotnet new console, paste into Program.cs, dotnet run
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("TAKAELO_SECRET_KEY"));

var request = new HttpRequestMessage(HttpMethod.Post, "https://api.takaelo.com/v1/checkouts")
{
    Content = JsonContent.Create(new
    {
        amount = 1250,
        reference = "ORD-4821",
        success_url = "https://yourshop.com/orders/4821/thanks",
        cancel_url = "https://yourshop.com/cart",
        customer = new { name = "Rahim Uddin", phone = "01712345678" },
        metadata = new Dictionary<string, string> { ["order_id"] = "4821" },
    }),
};
request.Headers.Add("Idempotency-Key", "order-4821-1");

using var response = await http.SendAsync(request);
var body = await response.Content.ReadFromJsonAsync<JsonElement>();
if (!body.GetProperty("success").GetBoolean())
    throw new Exception($"{body.GetProperty("code")}: {body.GetProperty("message")}");

var checkout = body.GetProperty("data");
Console.WriteLine($"{checkout.GetProperty("id")} {checkout.GetProperty("url")}");
// In ASP.NET Core: return Results.Redirect(checkout.GetProperty("url").GetString()!);

Build with AI

Let your AI assistant do the integration

Copy a ready-made prompt for your framework into Claude, ChatGPT, Cursor or Copilot, or connect our MCP server so your AI can search the docs and run test payments. Your keys stay out of the chat.

  • Next.js
  • Express
  • Laravel
  • PHP
  • WordPress / WooCommerce
  • Django
  • FastAPI
  • Go
  • Claude
  • ChatGPT
  • Cursor
  • GitHub Copilot
  • Windsurf

MCP server address:https://mcp.takaelo.com/mcp

Four outcomes. The whole journey, if you want it.

Every endpoint gets the four events that decide an order. Tick more in the dashboard to follow each checkout from created to paid — payment links and invoices included — and every customer payment report.

  • payment.completed

    Money arrived and matched — fulfil the order.

  • payment.pending_review

    Money arrived but needs your OK (above your auto-approve limit or a TrxID claim).

  • payment.failed

    The checkout expired or was cancelled — no money moved.

  • payment.refunded

    You marked the payment as refunded.

Failed deliveries retry after 1 min, 5 min, 30 min, 2 h, 6 h and 24 h. The event id never changes, so handle each one once.

payment.completed — the full delivery
{
  "id": "evt_8RwK2mZp5TqV9xLc3nB7yH1d",
  "type": "payment.completed",
  "created": 1791641622,
  "livemode": true,
  "data": {
    "id": "pay_3kT9xQm2LrV8nB4cW7yZ1aPd",
    "object": "payment",
    "livemode": true,
    "status": "completed",
    "failure_reason": null,
    "review_reason": null,
    "amount": 1250,
    "amount_received": 1250,
    "amount_due": 0,
    "refund_due": 0,
    "currency": "BDT",
    "wallet": "bkash",
    "sender": "01712345678",
    "trx_id": "BK7Q2M9XLA",
    "reference": "ORD-4821",
    "source": "api",
    "link_id": null,
    "invoice_id": null,
    "customer": { "name": "Rahim Uddin", "phone": "01712345678", "email": "" },
    "metadata": { "order_id": "4821" },
    "url": "https://yourshop.takaelo.com/pay/pay_3kT9xQm2LrV8nB4cW7yZ1aPd",
    "created": 1791641454,
    "expires_at": 1791642354,
    "completed_at": 1791641621,
    "refunded_at": null
  }
}

Verify the signature

TakaElo-Signature: t=<time>,v1=<HMAC-SHA256 of "t.body">. Check it against the raw body with a constant-time compare and reject anything older than 5 minutes — about a dozen lines in any language.

# Check a signature by hand while debugging: HMAC-SHA256 of "<t>.<raw body>" with your webhook secret.
t=1760000000
body='{"id":"evt_test","type":"payment.completed"}'
printf '%s.%s' "$t" "$body" | openssl dgst -sha256 -hmac "whsec_test_secret" | sed 's/^.* //'
# 7f852f9c0d26b339c024880089f7e91038e764b64f8d7e3c2e46d9a5bcb77f1b
# It must equal one of the v1= values in the TakaElo-Signature header.
<?php
/** True only when the request really came from TakaElo in the last 5 minutes. */
function verifyTakaEloSignature(string $payload, string $header, string $secret, ?int $now = null): bool
{
    $now ??= time();
    $timestamp = 0;
    $signatures = [];
    foreach (explode(',', $header) as $part) {
        [$key, $value] = array_pad(explode('=', trim($part), 2), 2, '');
        if ($key === 't') {
            $timestamp = (int) $value;
        } elseif ($key === 'v1') {
            $signatures[] = $value;
        }
    }
    if ($timestamp === 0 || abs($now - $timestamp) > 300) {
        return false; // missing or stale: a replay of an old delivery
    }

    $expected = hash_hmac('sha256', $timestamp . '.' . $payload, $secret);
    foreach ($signatures as $signature) {
        if (hash_equals($expected, $signature)) { // constant-time compare
            return true;
        }
    }
    return false;
}
import crypto from "node:crypto";

/** True only when the request really came from TakaElo in the last 5 minutes. */
export function verifyTakaEloSignature(payload, header, secret, now = Math.floor(Date.now() / 1000)) {
  let timestamp = 0;
  const signatures = [];
  for (const part of (header ?? "").split(",")) {
    const [key, value] = part.trim().split("=", 2);
    if (key === "t") timestamp = Number(value);
    if (key === "v1") signatures.push(value);
  }
  if (!timestamp || Math.abs(now - timestamp) > 300) return false; // missing or stale: a replay

  const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.`).update(payload).digest();
  return signatures.some((signature) => {
    const received = Buffer.from(signature ?? "", "hex");
    return received.length === expected.length && crypto.timingSafeEqual(received, expected);
  });
}
import hashlib
import hmac
import time


def verify_takaelo_signature(payload: bytes, header: str, secret: str, now: int | None = None) -> bool:
    """True only when the request really came from TakaElo in the last 5 minutes."""
    now = int(time.time()) if now is None else now
    timestamp, signatures = 0, []
    for part in (header or "").split(","):
        key, _, value = part.strip().partition("=")
        if key == "t" and value.isdigit():
            timestamp = int(value)
        elif key == "v1":
            signatures.append(value)
    if not timestamp or abs(now - timestamp) > 300:
        return False  # missing or stale: a replay of an old delivery

    expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + payload, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(expected, s) for s in signatures)
package webhooks

import (
	"crypto/hmac"
	"crypto/sha256"
	"encoding/hex"
	"strconv"
	"strings"
	"time"
)

// VerifyTakaEloSignature is true only when the request really came from TakaElo in the last 5 minutes.
func VerifyTakaEloSignature(payload []byte, header, secret string, now time.Time) bool {
	var timestamp int64
	var signatures []string
	for _, part := range strings.Split(header, ",") {
		key, value, _ := strings.Cut(strings.TrimSpace(part), "=")
		switch key {
		case "t":
			timestamp, _ = strconv.ParseInt(value, 10, 64)
		case "v1":
			signatures = append(signatures, value)
		}
	}
	if age := now.Unix() - timestamp; timestamp == 0 || age > 300 || age < -300 {
		return false // missing or stale: a replay of an old delivery
	}

	mac := hmac.New(sha256.New, []byte(secret))
	mac.Write([]byte(strconv.FormatInt(timestamp, 10) + "."))
	mac.Write(payload)
	expected := mac.Sum(nil)
	for _, s := range signatures {
		if received, err := hex.DecodeString(s); err == nil && hmac.Equal(received, expected) {
			return true
		}
	}
	return false
}
require "openssl"

# True only when the request really came from TakaElo in the last 5 minutes.
def verify_takaelo_signature(payload, header, secret, now: Time.now.to_i)
  timestamp = 0
  signatures = []
  header.to_s.split(",").each do |part|
    key, value = part.strip.split("=", 2)
    timestamp = value.to_i if key == "t"
    signatures << value.to_s if key == "v1"
  end
  return false if timestamp.zero? || (now - timestamp).abs > 300 # missing or stale: a replay

  expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{timestamp}.#{payload}")
  signatures.any? { |signature| secure_compare(expected, signature) }
end

# Constant-time compare (in Rails: ActiveSupport::SecurityUtils.secure_compare).
def secure_compare(a, b)
  return false unless a.bytesize == b.bytesize

  a.bytes.zip(b.bytes).reduce(0) { |diff, (x, y)| diff | (x ^ y) }.zero?
end
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.List;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;

public final class TakaEloWebhook {
    /** True only when the request really came from TakaElo in the last 5 minutes. */
    public static boolean verify(byte[] payload, String header, String secret, long now) {
        long timestamp = 0;
        List<String> signatures = new ArrayList<>();
        for (String part : (header == null ? "" : header).split(",")) {
            String[] kv = part.trim().split("=", 2);
            if (kv.length != 2) continue;
            if (kv[0].equals("t")) {
                try { timestamp = Long.parseLong(kv[1]); } catch (NumberFormatException e) { return false; }
            } else if (kv[0].equals("v1")) {
                signatures.add(kv[1]);
            }
        }
        if (timestamp == 0 || Math.abs(now - timestamp) > 300) return false; // missing or stale: a replay

        byte[] expected;
        try {
            Mac mac = Mac.getInstance("HmacSHA256");
            mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
            mac.update((timestamp + ".").getBytes(StandardCharsets.UTF_8));
            expected = mac.doFinal(payload);
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
            throw new IllegalStateException(e);
        }
        for (String signature : signatures) {
            try {
                if (MessageDigest.isEqual(HexFormat.of().parseHex(signature), expected)) return true; // constant-time
            } catch (IllegalArgumentException ignored) {
                // not hex: not ours
            }
        }
        return false;
    }
}
using System.Security.Cryptography;
using System.Text;

public static class TakaEloWebhook
{
    /// <summary>True only when the request really came from TakaElo in the last 5 minutes.</summary>
    public static bool Verify(byte[] payload, string? header, string secret, long? now = null)
    {
        var current = now ?? DateTimeOffset.UtcNow.ToUnixTimeSeconds();
        long timestamp = 0;
        var signatures = new List<string>();
        foreach (var part in (header ?? "").Split(','))
        {
            var kv = part.Trim().Split('=', 2);
            if (kv.Length != 2) continue;
            if (kv[0] == "t") long.TryParse(kv[1], out timestamp);
            else if (kv[0] == "v1") signatures.Add(kv[1]);
        }
        if (timestamp == 0 || Math.Abs(current - timestamp) > 300) return false; // missing or stale: a replay

        var signed = Encoding.UTF8.GetBytes($"{timestamp}.").Concat(payload).ToArray();
        var expected = HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), signed);
        foreach (var signature in signatures)
        {
            byte[] received;
            try { received = Convert.FromHexString(signature); } catch (FormatException) { continue; }
            if (CryptographicOperations.FixedTimeEquals(received, expected)) return true; // constant-time
        }
        return false;
    }
}

Your shop's own address

Checkout URLs use yourshop.takaelo.com; your own pay.yourshop.com is coming soon — no code change when it arrives.

yourshop.takaelo.com → pay.yourshop.com

A sandbox that behaves like real money

  • Separate test keys and test data — switch with one toggle
  • SMS simulator: send a fake bKash or Nagad payment to any test checkout
  • Test webhooks with the same signature as live
  • Free forever, never counts against your plan

SDKs

Small, typed clients with webhook verification built in.

  • PHPcomposer require takaelo/takaelo-phpComing soon
  • Node.jsnpm install takaeloComing soon
  • Pythonpip install takaeloComing soon
  • Gogo get github.com/takaelo/takaelo-goComing soon
  • Rubygem install takaeloComing soon

Plugins

Coming soon: install, paste your API key, done.

  • WooCommerceComing soon
  • WHMCSComing soon
  • LaravelComing soon
  • SMM panelsComing soon
  • ShopifyComing soon
  • Easy Digital DownloadsComing soon
  • FOSSBillingComing soon
  • BlestaComing soon
  • PaymenterComing soon
  • WiseCPComing soon
  • Tutor LMSComing soon

Until they ship, every example in the docs is plain HTTP — there's nothing to wait for.

Read the docs

Get your test key

Create a free account — the sandbox is ready the moment you sign up.

Start free