ডেভেলপার
এক বিকেলেই ইন্টিগ্রেশন
চেকআউট তৈরি করতে একটি এপিআই কল, সামলাতে চারটি ওয়েবহুক, আর আটটি ভাষায় টেস্ট করা উদাহরণ। সব চালিয়ে দেখার জন্য আছে ফ্রি স্যান্ডবক্স।
যেভাবে কাজ করে
- ১
একটি টেস্ট কি নিন
প্রথম মিনিট থেকেই প্রতিটি অ্যাকাউন্টে একটি ফ্রি স্যান্ডবক্স কি (sk_test_…) থাকে।
- ২
চেকআউট তৈরি করুন
অ্যামাউন্ট আর আপনার অর্ডার আইডি পাঠান। উত্তরে পাবেন আপনার শপের অ্যাড্রেসে একটি চেকআউট লিংক।
- ৩
কাস্টমারকে সেখানে পাঠান
কাস্টমার বিকাশ, নগদ, রকেট বা উপায় বেছে নিয়ে সবসময়ের মতোই টাকা পাঠাবেন।
- ৪
একটি ওয়েবহুক সামলান
টাকা এলে আমরা আপনার সার্ভারে সাইন করা payment.completed পাঠাব। তারপর কাস্টমার আপনার সাইটে ফিরে আসবেন।
- ৫
লাইভে যান
sk_test_ বদলে sk_live_ দিন। আর কিছু বদলাতে হয় না।
চেকআউট তৈরি করুন
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()!);এআই দিয়ে বানান
ইন্টিগ্রেশনের কাজটা আপনার এআই অ্যাসিস্ট্যান্টকে দিন
আপনার ফ্রেমওয়ার্কের জন্য তৈরি প্রম্পট কপি করে Claude, ChatGPT, Cursor বা Copilot-এ দিন। অথবা আমাদের এমসিপি সার্ভার যুক্ত করুন, তাহলে আপনার এআই নিজেই ডকস খুঁজে পড়বে আর টেস্ট পেমেন্ট করে দেখবে। আপনার কি চ্যাটে দিতে হবে না।
- Next.js
- Express
- Laravel
- PHP
- WordPress / WooCommerce
- Django
- FastAPI
- Go
- Claude
- ChatGPT
- Cursor
- GitHub Copilot
- Windsurf
এমসিপি সার্ভারের অ্যাড্রেস:https://mcp.takaelo.com/mcp
চারটি ফলাফল। চাইলে শুরু থেকে শেষ, সবকিছু।
প্রতিটি এন্ডপয়েন্টে আমরা সেই চারটি ইভেন্ট পাঠাব, যা দেখে অর্ডারের ফল ঠিক হয়। ড্যাশবোর্ডে আরও ইভেন্টে টিক দিলে প্রতিটি চেকআউট তৈরি হওয়া থেকে পেমেন্ট পর্যন্ত সব খবর পাবেন, পেমেন্ট লিংক আর ইনভয়েসেরও। কাস্টমারের প্রতিটি পেমেন্ট রিপোর্টের খবরও পাবেন।
payment.completedটাকা এসেছে আর মিলেছে। এবার অর্ডারটি কমপ্লিট করুন।
payment.pending_reviewটাকা এসেছে কিন্তু আপনার অ্যাপ্রুভাল লাগবে (অটো-অ্যাপ্রুভ লিমিটের বেশি বা TrxID ক্লেইম)।
payment.failedচেকআউটের সময় শেষ হয়েছে বা বাতিল হয়েছে। কোনো টাকা আসেনি।
payment.refundedআপনি পেমেন্টটি রিফান্ড করা হিসেবে মার্ক করেছেন।
কোনো ডেলিভারি না পৌঁছালে আমরা আবার পাঠাব ১ মিনিট, ৫ মিনিট, ৩০ মিনিট, ২ ঘণ্টা, ৬ ঘণ্টা ও ২৪ ঘণ্টা পর। ইভেন্ট আইডি বদলাবে না, তাই প্রতিটি ইভেন্ট একবারই সামলান।
{
"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
}
}সিগনেচার ভেরিফাই করুন
TakaElo-Signature: t=<সময়>,v1=<"t.body"-এর HMAC-SHA256>। যে বডি এসেছে, হুবহু সেটার সাথে কনস্ট্যান্ট-টাইম কম্পেয়ারে মিলিয়ে দেখুন, আর ৫ মিনিটের বেশি পুরোনো কিছু নিবেন না। যেকোনো ভাষায় মোটামুটি এক ডজন লাইন।
# 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?
endimport 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;
}
}শপের নিজস্ব অ্যাড্রেস
চেকআউট লিংক হবে yourshop.takaelo.com-এ। নিজের pay.yourshop.com শিগগিরই আসছে, তখনো কোড বদলাতে হবে না।
yourshop.takaelo.com → pay.yourshop.com
এমন স্যান্ডবক্স, যা চলে ঠিক আসল টাকার মতো
- আলাদা টেস্ট কি আর টেস্ট ডেটা, এক টগলেই বদলাতে পারবেন
- এসএমএস সিমুলেটর: যেকোনো টেস্ট চেকআউটে বিকাশ বা নগদের টেস্ট পেমেন্ট পাঠান
- টেস্ট ওয়েবহুকেও লাইভের মতো একই সাইন
- চিরকাল ফ্রি, আপনার প্ল্যানের লিমিট থেকে কখনো কাটবে না
এসডিকে
ছোট, টাইপড ক্লায়েন্ট। ওয়েবহুক ভেরিফাই করার ব্যবস্থা ভেতরেই আছে।
- PHP
composer require takaelo/takaelo-phpশিগগিরই আসছে - Node.js
npm install takaeloশিগগিরই আসছে - Python
pip install takaeloশিগগিরই আসছে - Go
go get github.com/takaelo/takaelo-goশিগগিরই আসছে - Ruby
gem install takaeloশিগগিরই আসছে
প্লাগইন
শিগগিরই আসছে: ইনস্টল করুন, এপিআই কি বসান, ব্যস।
- WooCommerceশিগগিরই আসছে
- WHMCSশিগগিরই আসছে
- Laravelশিগগিরই আসছে
- SMM panelsশিগগিরই আসছে
- Shopifyশিগগিরই আসছে
- Easy Digital Downloadsশিগগিরই আসছে
- FOSSBillingশিগগিরই আসছে
- Blestaশিগগিরই আসছে
- Paymenterশিগগিরই আসছে
- WiseCPশিগগিরই আসছে
- Tutor LMSশিগগিরই আসছে
এগুলো আসার আগ পর্যন্ত ডকসের প্রতিটি উদাহরণ সাধারণ HTTP দিয়ে লেখা। তাই অপেক্ষা করার কিছু নেই।
ডকস পড়ুনআপনার টেস্ট কি নিন
একটি ফ্রি অ্যাকাউন্ট খুলুন। সাইন আপ করামাত্র স্যান্ডবক্স তৈরি থাকবে।