Skip to content

Connect your website to Build it Pay

The developer guide and API reference: create a payment, send your customer to pay, and confirm it safely.

This guide is for the developer of a business that takes payments through Build it. The whole integration is two API calls and one webhook.

If the business has no website or developer, use a payment link instead. It needs no code; see the article above.

Quick start

  1. Create a test key on the Payments page of your account.
  2. When your customer checks out, call Create a checkout from your server with the amount and your order number.
  3. Redirect your customer to the url in the answer.
  4. When they come back to your return_url, call Read a checkout. Confirm the order only if status is paid and the amount matches.
  5. Add a webhook so the order is also confirmed when your customer pays but never returns.
  6. Test it, then swap the test key for a live key.

How a payment works

Your server            Build it                 Your customer
     |  create checkout   |                          |
     |------------------->|                          |
     |  checkout + url    |                          |
     |<-------------------|                          |
     |  redirect to url ------------------------------>|
     |                    |   pays on payment page   |
     |                    |<-------------------------|
     |  webhook: checkout.paid                       |
     |<-------------------|                          |
     |                    |  redirect to return_url  |
     |<------------------------------------------------|
     |  read checkout     |                          |
     |------------------->|                          |
     |  status: paid      |                          |
     |<-------------------|                          |

Your customer pays on a Build it page and then on the payment gateway's secure page. Card and wallet details never touch your website.

The one rule that matters: never confirm an order just because your customer arrived at your return address. Anyone can open that address. Confirm only from the API or a signed webhook.

Basics

Base address https://buildit.com.bd/api/pay/v1
Format JSON in and out. Send Accept: application/json.
Sign-in Authorization: Bearer <your secret key> on every request.
Money Whole numbers of paisa. BDT 8,800.00 is 880000.
Currency BDT only. Convert other currencies before you call.
Dates ISO 8601 with a time zone, for example 2026-11-16T07:00:00+00:00.
Rate limit 120 requests a minute from one address.

Keys

Create and revoke keys on the Payments page.

Key Starts with What it does
Test bp_test_ Payments go through a sandbox. No money moves.
Live bp_live_ Takes real money. Available once your account is approved.

The key decides the mode: a checkout made with a test key is a test checkout, and a test key cannot read a live checkout.

A key is shown once when you create it. Keep it in your server's configuration. Never put it in a web page, a mobile app or a public repository. If it may have leaked, revoke it and create another; the old one stops working at once.

Amounts in paisa

Multiply taka by 100 and round to a whole number. Do the rounding once, on your server, and store the result with the order so you can compare it later.

$amount = (int) round($priceInTaka * 100);   // 8800.00 -> 880000

Create a checkout

POST /checkouts

curl -X POST https://buildit.com.bd/api/pay/v1/checkouts \
  -H "Authorization: Bearer bp_test_your_key" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "reference": "ORDER-1001",
    "amount": 880000,
    "currency": "BDT",
    "description": "Consultation, 60 minutes",
    "customer": {"name": "Rahim Uddin", "email": "rahim@example.com", "phone": "01700000000"},
    "return_url": "https://your-site.example/payment/return",
    "cancel_url": "https://your-site.example/payment/cancelled",
    "expires_at": "2026-11-16T07:00:00+00:00",
    "metadata": {"order_id": "1001"}
  }'
Field Required Rule
reference Yes Your own id for the order. Letters, numbers, dots, dashes and underscores. Up to 60 characters.
amount Yes Whole number of paisa, from 1000 (BDT 10.00) to 50000000 (BDT 500,000.00). Your account may have a lower limit.
currency Yes BDT.
description Yes Shown to your customer on the payment page. Up to 120 characters.
customer.name Yes Up to 100 characters.
customer.email Yes We send the receipt here.
customer.phone No Up to 30 characters.
return_url Yes Where your customer goes after paying. Must be https and on a website registered for your business.
cancel_url Yes Where your customer goes if they give up. Same rules.
expires_at No When the checkout stops accepting payment. Up to 24 hours ahead. One hour if left out.
metadata No Up to 20 text values of up to 255 characters each. Returned to you unchanged. Do not put secrets or card details here.

The answer is 201 Created with the checkout. Redirect your customer to its url.

Safe to repeat

If your request times out, send it again with the same reference. You get the same checkout back with 200 OK, so a retry never creates a second payment. Use one reference per order.

Sending a reference you have used before with a different amount is refused with 422. For a new order or a changed price, use a new reference.

Holding stock or a time slot

If you hold something for your customer while they pay, set expires_at to when your hold ends. The checkout then cannot be paid after you have released it. You also get a checkout.expired webhook when the time is up.

When your customer comes back

We add checkout and reference to your address:

https://your-site.example/payment/return?checkout=co_3f9c...&reference=ORDER-1001
They arrive at What to do
return_url Read the checkout. If it is paid, confirm the order and thank them. If not, show "we are confirming your payment" and let the webhook finish the job.
cancel_url Read the checkout anyway, in case they did pay. If it is still open, release the order. They may still return to the payment page and pay before it expires, and you will get a webhook if they do.

Treat checkout and reference in the address as hints for looking up the order. They prove nothing.

Read a checkout

GET /checkouts/{id}

curl https://buildit.com.bd/api/pay/v1/checkouts/co_3f9c... \
  -H "Authorization: Bearer bp_test_your_key" -H "Accept: application/json"

Confirm your order only when all of these are true:

  • status is paid,
  • reference is the order you expect,
  • amount equals the amount you stored for that order,
  • currency is BDT.

The checkout

Both calls, and every webhook, return the same object:

{
  "data": {
    "id": "co_3f9c2a71b8e04d6f9a0c5e1d7b2f4a68",
    "mode": "test",
    "reference": "ORDER-1001",
    "status": "paid",
    "amount": 880000,
    "currency": "BDT",
    "description": "Consultation, 60 minutes",
    "fee": 30800,
    "refunded_amount": 0,
    "payment_method": "BKash Mobile Banking",
    "paid_at": "2026-11-16T06:12:00+00:00",
    "expires_at": "2026-11-16T07:00:00+00:00",
    "url": "https://buildit.com.bd/pay/co_3f9c2a71b8e04d6f9a0c5e1d7b2f4a68",
    "metadata": {"order_id": "1001"}
  }
}
Field Meaning
id Our id for the checkout. Store it with your order.
mode test or live.
reference The reference you sent.
status See the table below.
amount, currency What your customer was asked to pay.
fee Our fee in paisa. Empty until the checkout is paid.
refunded_amount Total refunded so far, in paisa.
payment_method How it was paid, as reported by the gateway. Empty until paid.
paid_at When the payment was confirmed. Empty until paid.
expires_at When the checkout stops accepting payment.
url The payment page to send your customer to.
metadata What you sent, unchanged.
Status Meaning What to do
open Not paid yet. Wait, or send your customer back to url.
paid Paid and confirmed. Confirm the order.
review Money arrived but we are checking it, for example because the gateway flagged it. Do not confirm yet. It becomes paid if we accept it.
expired Ran out of time without being paid. Release the order. Rarely, a customer who was already paying finishes afterwards and it becomes paid.

A paid checkout stays paid after a refund. Compare refunded_amount with amount to tell a part refund from a full one.

Webhooks

Your customer may pay and close the browser before returning to you. A webhook tells your server directly. Set the address on your Payments page. It must be https and on a website registered for your business.

We send a JSON POST:

{
  "event": "checkout.paid",
  "created_at": "2026-11-16T06:12:01+00:00",
  "data": {
    "id": "co_3f9c2a71b8e04d6f9a0c5e1d7b2f4a68",
    "reference": "ORDER-1001",
    "status": "paid",
    "amount": 880000,
    "currency": "BDT"
  }
}

data is the full checkout; it is shortened here.

Event When What to do
checkout.paid A payment was confirmed. Confirm the order.
checkout.refunded All or part of a payment was refunded. Update the order. refunded_amount is the total so far.
checkout.expired The checkout ran out of time. Release what you were holding.
refund.sent We sent a refund you asked for. data.refund is the refund request. Mark the order refunded.
refund.declined We did not send a refund you asked for. data.refund.decision_note says why. Tell whoever asked for it.
plan_payment.due A repeating payment was asked for and its payer emailed. data is the checkout for it and data.plan_payment the period. Show it as due in your system.
plan_payment.paid A repeating payment was paid. It follows checkout.paid. Mark the period paid.

Ignore events you do not recognise and still answer 200; we may add more.

Header Value
BuildIt-Event The event name.
BuildIt-Delivery A number for this notice. It stays the same when we retry.
BuildIt-Signature t=<unix time>,v1=<signature>. See below.

Check the signature

Anyone can post to your webhook address, so check every notice.

v1 is the HMAC-SHA256, in lowercase hex, of the text <t>.<raw request body>, using your signing secret from the Payments page. Reject the notice when:

  • the header is missing or badly formed,
  • the signature does not match, or
  • t is more than five minutes from your server's clock, which stops an old notice being replayed.

Use the raw body exactly as it arrived. If you decode the JSON and encode it again, the text changes and the signature will not match.

For extra safety, do not act on the notice's contents. Take data.id from it, read the checkout from us, and act on that.

Answer and retries

  • Answer with any 2xx status within 10 seconds. Do slow work, such as sending email, after you answer.
  • We do not follow redirects. A 301 or 302 counts as a failure.
  • If you do not answer 2xx, we try again after 30 seconds, 2 minutes, 10 minutes, 30 minutes, 2 hours, 6 hours and 12 hours: eight tries over about 21 hours. Then the notice is marked failed.
  • Each try has a fresh t and signature.
  • Latest notices on your Payments page shows each notice and what your server answered.

A failed webhook never affects the payment. You can always read the checkout from the API.

Handle repeats

The same notice can arrive more than once, and the webhook and your customer's return can arrive in the same second. Make confirming an order safe to repeat: check whether the order is already confirmed inside a database transaction, and do nothing if it is.

Errors

Errors are JSON with a message you can log.

{ "message": "The return_url is not on a website registered for this account." }

A field that fails validation also has errors:

{
  "message": "The smallest payment is BDT 10.00 (1000 paisa).",
  "errors": { "amount": ["The smallest payment is BDT 10.00 (1000 paisa)."] }
}
Status Meaning What to do
401 The key is missing, wrong or revoked. Check the Authorization header.
403 Your account is waiting for approval or is suspended. Contact us.
404 No checkout, plan or subscriber with that id for your business in this key's mode. Check you are not mixing test and live.
422 A field is wrong, the amount is above your limit, an address is not on a registered website, or the reference was used for another amount. Read message.
429 Too many requests. Wait a minute and try again.
5xx Something failed on our side. Try again with the same reference.

When creating a checkout fails, do not leave your customer on a blank page. Tell them payment is unavailable for a moment and release anything you were holding.

Code examples

PHP

Create a checkout and redirect:

<?php
$key = getenv('BUILDIT_PAY_KEY');

$ch = curl_init('https://buildit.com.bd/api/pay/v1/checkouts');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 25,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer '.$key,
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'reference' => $order['number'],
        'amount' => (int) round($order['total'] * 100),
        'currency' => 'BDT',
        'description' => 'Order '.$order['number'],
        'customer' => ['name' => $order['name'], 'email' => $order['email']],
        'return_url' => 'https://your-site.example/payment/return',
        'cancel_url' => 'https://your-site.example/payment/cancelled',
    ]),
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status !== 200 && $status !== 201) {
    exit('Payment is unavailable right now. Please try again.');
}

// Save $body['data']['id'] with the order, then:
header('Location: '.$body['data']['url']);

Confirm on return (and reuse the same function from your webhook):

<?php
function confirmIfPaid(string $checkoutId, array $order): bool
{
    $ch = curl_init('https://buildit.com.bd/api/pay/v1/checkouts/'.rawurlencode($checkoutId));
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT => 25,
        CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('BUILDIT_PAY_KEY'), 'Accept: application/json'],
    ]);
    $checkout = json_decode(curl_exec($ch), true)['data'] ?? [];
    curl_close($ch);

    $paid = ($checkout['status'] ?? null) === 'paid'
        && ($checkout['reference'] ?? null) === $order['number']
        && ($checkout['amount'] ?? null) === (int) round($order['total'] * 100)
        && ($checkout['currency'] ?? null) === 'BDT';

    if ($paid) {
        markOrderPaid($order['number'], $checkoutId);   // must be safe to call twice
    }

    return $paid;
}

Receive a webhook:

<?php
$header = $_SERVER['HTTP_BUILDIT_SIGNATURE'] ?? '';
$body = file_get_contents('php://input');
$secret = getenv('BUILDIT_PAY_WEBHOOK_SECRET');

if (! preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/', $header, $m)
    || abs(time() - (int) $m[1]) > 300
    || ! hash_equals(hash_hmac('sha256', $m[1].'.'.$body, $secret), $m[2])) {
    http_response_code(400);
    exit;
}

$notice = json_decode($body, true);

if ($notice['event'] === 'checkout.paid') {
    $order = findOrderByNumber($notice['data']['reference']);
    if ($order) {
        confirmIfPaid($notice['data']['id'], $order);
    }
}

http_response_code(200);

Laravel

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

// Create a checkout
$response = Http::withToken(config('services.buildit_pay.key'))
    ->acceptJson()->timeout(25)
    ->post('https://buildit.com.bd/api/pay/v1/checkouts', [
        'reference' => $order->number,
        'amount' => (int) round($order->total * 100),
        'currency' => 'BDT',
        'description' => "Order {$order->number}",
        'customer' => ['name' => $order->name, 'email' => $order->email],
        'return_url' => route('payment.return'),
        'cancel_url' => route('payment.cancelled'),
    ]);

abort_unless($response->successful(), 503);

return redirect()->away($response->json('data.url'));
// Webhook route. Exclude it from CSRF protection, since we cannot send your token.
Route::post('/webhooks/buildit', function (Request $request) {
    $valid = preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/', (string) $request->header('BuildIt-Signature'), $m)
        && abs(time() - (int) $m[1]) <= 300
        && hash_equals(hash_hmac('sha256', $m[1].'.'.$request->getContent(), config('services.buildit_pay.webhook_secret')), $m[2]);

    abort_unless($valid, 400);

    if ($request->input('event') === 'checkout.paid') {
        ConfirmOrder::dispatch($request->input('data.id'), $request->input('data.reference'));
    }

    return response('OK');
});

Node.js (Express)

The webhook route must receive the raw body, so register it before any JSON body parser.

const crypto = require('crypto');
const express = require('express');
const app = express();

app.post('/webhooks/buildit', express.raw({ type: 'application/json' }), (req, res) => {
  const match = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(req.get('BuildIt-Signature') || '');
  if (!match) return res.sendStatus(400);

  const [, time, signature] = match;
  const expected = crypto
    .createHmac('sha256', process.env.BUILDIT_PAY_WEBHOOK_SECRET)
    .update(`${time}.${req.body.toString('utf8')}`)
    .digest('hex');

  const fresh = Math.abs(Date.now() / 1000 - Number(time)) <= 300;
  const same = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
  if (!fresh || !same) return res.sendStatus(400);

  const notice = JSON.parse(req.body.toString('utf8'));
  if (notice.event === 'checkout.paid') {
    confirmOrder(notice.data.id, notice.data.reference); // read the checkout from the API inside
  }

  res.sendStatus(200);
});

Python (Flask)

import hashlib, hmac, os, re, time
from flask import Flask, request

app = Flask(__name__)

@app.post("/webhooks/buildit")
def buildit_webhook():
    body = request.get_data()  # raw bytes, exactly as sent
    match = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", request.headers.get("BuildIt-Signature", ""))
    if not match:
        return "", 400

    sent_at, signature = match.groups()
    expected = hmac.new(
        os.environ["BUILDIT_PAY_WEBHOOK_SECRET"].encode(),
        sent_at.encode() + b"." + body,
        hashlib.sha256,
    ).hexdigest()

    if abs(time.time() - int(sent_at)) > 300 or not hmac.compare_digest(expected, signature):
        return "", 400

    notice = request.get_json()
    if notice["event"] == "checkout.paid":
        confirm_order(notice["data"]["id"], notice["data"]["reference"])

    return "", 200

Testing

Use a test key. Everything works the same, but no money moves, no receipt is emailed, and test payments never count in your balance.

Make a test payment

  1. Create a checkout with your test key and open its url. The page shows a Test payment banner.
  2. Press Pay. You reach the gateway's sandbox page.
  3. Choose Mobile Banking, then any wallet.
  4. On the test page, press Success to pay, or Failed to see a declined payment. You do not need a real card, wallet or one-time password.

On the Payments page, switch Showing to Test payments to see the result.

What to try

Try this You should see
Pay, and return to your site Order confirmed.
Pay, and close the browser before returning Order confirmed by the webhook alone.
Press Failed on the sandbox page Back on the payment page with a chance to try again. Order not confirmed.
Press Cancel on the payment page Arrive at your cancel_url. Order released.
Open your return_url by hand with a made-up checkout Order not confirmed.
Post to your webhook without a signature 400, and nothing changes.
Send the same create request twice The same checkout id both times.
Let a checkout pass its expires_at A checkout.expired webhook within about five minutes.

Developing on your own computer

Our servers cannot reach localhost, so webhooks will not arrive there. Either rely on the return flow while developing, or use a tunnelling tool to give your computer a public https address and register that address with us. Return and cancel addresses must also be on a registered website, so ask us to add your development address.

Refunds

Ask for a refund from your Payments page, or from your website with the API below. We send it to your customer's card or wallet once we have checked it, and it comes out of your balance. Our fee on the original payment is not returned.

Ask for a refund

POST /checkouts/{id}/refunds

curl -X POST https://buildit.com.bd/api/pay/v1/checkouts/co_3f9c.../refunds \
  -H "Authorization: Bearer bp_test_your_key" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"amount": 250000, "reason": "Order cancelled", "reference": "RF-1001"}'
Field Required Rule
amount Yes Whole number of paisa. No more than what is left of the payment after earlier refunds and refunds still waiting.
reason Yes Why the money is going back. Up to 500 characters. We read it before sending.
reference No Your own id for the refund. Sending it again returns the same request, so a retry never asks twice.

The answer is 201 Created with the refund request, or 200 OK when the reference was already used for the same refund:

{
  "data": {
    "id": "rf_5b1e...",
    "checkout": "co_3f9c...",
    "reference": "RF-1001",
    "amount": 250000,
    "currency": "BDT",
    "reason": "Order cancelled",
    "status": "waiting",
    "decision_note": null,
    "created_at": "2026-11-22T06:12:00+00:00",
    "decided_at": null
  }
}

status is waiting, sent or declined. It is refused with 422 when the payment is not paid, the amount is more than is left, or we owe you less than the refund.

List a payment's refunds

GET /checkouts/{id}/refunds returns every refund request for that payment, newest first.

Hearing the outcome

You get refund.sent or refund.declined by webhook when we decide. A sent refund is also followed by checkout.refunded, with the payment's new refunded_amount.

Repeating payments

For tuition, rent and memberships, the business makes a payment plan on its Payments page: an amount, how often (every month on a day from 1 to 28, or every week on a day), and when it ends. Your system adds the people who pay it, called subscribers, and follows along by webhook.

We cannot charge a saved card or wallet, so nothing is taken automatically. Three days before each due date we make a checkout for the period and email the subscriber a pay link, then remind them on the due date and 3 and 7 days after while it is unpaid. Each period is one checkout like any other, with a reference starting PLN, return_url and cancel_url on our own pages, and metadata holding the plan, subscriber, period and your subscriber_reference.

Plans are made on the Payments page. These calls use the same key and mode rules as checkouts.

Call What it does
GET /plans Your plans in this key's mode.
GET /plans/{id} One plan.
GET /plans/{id}/subscribers Its subscribers, 100 a page (?page=2). meta.total is the count.
POST /plans/{id}/subscribers Add a subscriber.
GET /subscribers/{id} One subscriber with every payment asked for so far.
POST /subscribers/{id}/pause Stop asking and reminding until resumed.
POST /subscribers/{id}/resume Start again. Periods that fell due while paused are marked skipped.
POST /subscribers/{id}/skip Do not ask for one period. Send {"period": 3}: one already asked for and unpaid, or the next one. Its pay link stops working.
POST /subscribers/{id}/resend Email the pay link for an unpaid period again. Send {"period": 3}.
POST /subscribers/{id}/end Ask for nothing more. A period already asked for can still be paid.

Add a subscriber

curl -X POST https://buildit.com.bd/api/pay/v1/plans/pp_8c1f.../subscribers \
  -H "Authorization: Bearer bp_test_your_key" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"name": "Karim Ahmed", "email": "karim@example.com", "phone": "01811111111", "reference": "ROLL-23", "start_date": "2026-12-01"}'
Field Required Rule
name Yes Up to 100 characters.
email Yes Where the pay links go. One subscriber per email on a plan, unless the earlier one has ended.
phone No Up to 30 characters.
reference No Your own id for this person, such as a student number. Up to 60 characters. Sent back in every plan webhook.
start_date No YYYY-MM-DD, today or later. Defaults to today. The first payment is the plan's first billing day on or after it.

The answer is 201 Created:

{
  "data": {
    "id": "ps_4d2a...",
    "plan": "pp_8c1f...",
    "reference": "ROLL-23",
    "name": "Karim Ahmed",
    "email": "karim@example.com",
    "phone": "01811111111",
    "start_date": "2026-12-01",
    "status": "active",
    "emails_stopped": false,
    "url": "https://buildit.com.bd/pay/plans/9f3c...",
    "payments": []
  }
}

status is active, paused or ended; a subscriber ends by itself once the plan's last payment is settled. url is the subscriber's own page, where they see what they paid, pay anything due and can stop the emails. Keep it private: anyone with it can see that page. emails_stopped is true when they stopped the emails; payments are still due.

Each entry in payments, and data.plan_payment in the webhooks, looks like this:

{
  "subscriber": "ps_4d2a...",
  "plan": "pp_8c1f...",
  "reference": "ROLL-23",
  "period": 1,
  "due_date": "2026-12-05",
  "amount": 250000,
  "status": "due",
  "checkout": "co_7a1b...",
  "paid_at": null
}

status is due, overdue, paid or skipped. A period is never asked for twice. If a payer was already paying when you skipped the period, the payment still counts and the period becomes paid.

Going live

  • Your account is approved and you have created a live key.
  • The live key and signing secret are in your server's configuration, not in your code.
  • Your live website's domain is registered with us, and your return_url, cancel_url and webhook address use https on it.
  • You confirm orders only from the API or a signed webhook, and compare the amount.
  • Confirming an order twice does no harm.
  • You have run every row of the test table with a test key.
  • Your refund terms are on your website, as the merchant agreement requires.

Common questions

What does my customer see on their statement? Build it or the payment gateway's name, not your business. Tell your customers, to avoid disputes.

Can I charge in dollars? Not yet. Convert to BDT at your own rate before you create the checkout, and show your customer the BDT amount.

Can I take a repeating payment? No. Each payment needs your customer to pay again. Create a new checkout, or send a payment link, each time.

Can I change the amount of a checkout? No. Create a new checkout with a new reference and let the old one expire.

Can I show the payment page inside my own page? No. Redirect the whole browser window to url. The page cannot be placed in a frame.

When do I get the money? Each payment is held for the number of days shown on your Payments page, then paid out by bank transfer. See your balance.

How do I know which order a payment is for? By reference, which is the value you sent, and by id if you stored it.

Updated 24 Nov 2026 Did not solve it? Contact support