Overview
Texon Pay lets your website accept payments through EPS (bKash, Nagad, Rocket, Upay, cards, internet banking …) with a hosted checkout. The flow is:
- Your server creates a payment with
POST /paymentsand receives apayment_url. - You redirect the customer to
payment_url. They confirm their details and pay on EPS. - We verify the payment with EPS, send a signed webhook to your server and redirect the customer to your
success_url/fail_url. - You fulfil the order when you receive
payment.succeeded(or after confirming viaGET /payments/:id).
https://pay.texonltd.com/api/v1Authentication
Authenticate every request with your secret API key in the Authorization header. Keys starting with tx_test_ use the EPS sandbox; keys starting with tx_live_ move real money. Your Texon Pay contact shares the keys with you.
Authorization: Bearer tx_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
⚠️ Keep API keys on your server (environment variables). Never put them in JavaScript, mobile apps or Git repositories. Ask us to revoke a key immediately if it leaks.
Check your key:
curl https://pay.texonltd.com/api/v1/ping -H "Authorization: Bearer $TEXONPAY_KEY"
# {"ok":true,"organization":{"id":"…","name":"…"},"mode":"sandbox"}Create a payment
| Field | Type | Required | Description |
|---|---|---|---|
| order_id | string | required | Your unique order reference (max 100 chars). Re-sending the same order_id + amount while the payment is still open returns the same payment (idempotent). |
| amount | number | required | Amount in BDT, e.g. 1250 or 1250.50 (min 1). |
| product_name | string | required | Shown to the customer on checkout. |
| product_category | string | optional | Optional category. |
| description | string | optional | Internal description (max 500). |
| customer.name / email / phone | string | optional | Pre-fills checkout. The customer can edit them before paying. |
| customer.address / city / postcode / country | string | optional | Billing address (country = 2-letter code, default BD). |
| success_url | url | optional | Where the customer is sent after a successful payment. |
| fail_url | url | optional | Where the customer is sent after a failed payment. |
| cancel_url | url | optional | Where the customer is sent if they cancel (defaults to fail_url). |
| expires_in_minutes | integer | optional | Link lifetime, 5 – 10080 minutes (default set per organization). |
| metadata | object | optional | Flat key/value object returned in API responses and webhooks. |
curl -X POST https://pay.texonltd.com/api/v1/payments \
-H "Authorization: Bearer $TEXONPAY_KEY" \
-H "Content-Type: application/json" \
-d '{
"order_id": "INV-10045",
"amount": 1250.00,
"product_name": "Annual subscription",
"customer": {
"name": "Abdur Rahim",
"email": "rahim@example.com",
"phone": "01712345678"
},
"success_url": "https://yoursite.com/payment/success",
"fail_url": "https://yoursite.com/payment/failed",
"cancel_url": "https://yoursite.com/payment/cancelled",
"metadata": { "user_id": "42" }
}'Response 201 Created:
{
"id": "cm4x2k9qz0001abcd",
"object": "payment",
"mode": "sandbox",
"order_id": "INV-10045",
"amount": 1250,
"currency": "BDT",
"status": "pending",
"payment_url": "https://pay.texonltd.com/pay/cm4x2k9qz0001abcd",
"receipt_url": "https://pay.texonltd.com/receipt/cm4x2k9qz0001abcd?t=…",
"expires_at": "2026-11-30T10:15:00.000Z",
...
}Redirect & return
Redirect the customer (HTTP 303 or window.location) to payment_url. After payment, we verify the result with EPS on our server and then redirect the customer to your URL with these query parameters:
https://yoursite.com/payment/success?payment_id=cm4x2k9qz0001abcd&order_id=INV-10045&status=success
Query parameters can be modified by the user. Never mark an order paid from the redirect alone — rely on the webhook, or call GET /payments/:id from your server and check status === "success" and the amount.
If you don't pass return URLs, the customer sees a Texon Pay receipt page.
Every payment also has a receipt_url: a shareable, signed pay-slip page (with PDF download and a verification QR code) you can show or email to your customer. Customers can also look up any payment themselves at https://pay.texonltd.com/verify using the transaction ID and their mobile number or email.
Webhooks
We send a POST request with a JSON body to your organization's webhook URL whenever something happens. Respond with any 2xx status within 15 seconds. Failed deliveries are retried after 1, 5, 15 min, 1, 3, 6, 12 and 24 hours. Your handler must be idempotent — the same event can arrive more than once.
| Field | Type | Required | Description |
|---|---|---|---|
| payment.succeeded | event | optional | Payment verified as paid with EPS. Fulfil the order. |
| payment.failed | event | optional | Payment failed at EPS / bank. |
| payment.cancelled | event | optional | Customer cancelled, or you cancelled a pending payment. |
| payment.expired | event | optional | Payment link expired without payment. |
| refund.requested / approved / rejected / processed | event | optional | Refund lifecycle updates. data = refund object. |
| test.ping | event | optional | Sent when an admin clicks “Send test event”. |
Headers:
Content-Type: application/json X-Texon-Event: payment.succeeded X-Texon-Delivery: cm4x… (unique delivery id) X-Texon-Signature: t=1732950000,v1=5f0c3e… (HMAC-SHA256 of "<t>.<raw body>" with your webhook secret)
Body:
{
"id": "cm4x…",
"event": "payment.succeeded",
"created_at": "2026-11-30T09:20:11.000Z",
"data": { "id": "cm4x2k9qz0001abcd", "order_id": "INV-10045", "amount": 1250, "status": "success",
"payment_method": "bKash", "eps_transaction_id": "C2549190401", "paid_at": "…", "metadata": {…} }
}Verify the signature with your webhook secret (shared by your Texon Pay contact):
// Express example — use the RAW body to verify the signature
import crypto from "node:crypto";
import express from "express";
const app = express();
app.post("/api/texonpay/webhook", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("X-Texon-Signature") || ""; // "t=1732950000,v1=ab12…"
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto
.createHmac("sha256", process.env.TEXONPAY_WEBHOOK_SECRET)
.update(`${t}.${req.body}`)
.digest("hex");
const valid = v1 && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300; // 5 min tolerance
if (!valid || !fresh) return res.status(400).send("invalid signature");
const event = JSON.parse(req.body);
if (event.event === "payment.succeeded") {
const p = event.data; // payment object
// idempotent: mark order p.order_id as paid if not already, check p.amount
}
res.sendStatus(200); // any 2xx = delivered
});Retrieve & verify
Returns the payment object including its refunds. Use this to confirm a payment from your server.
Forces an immediate re-check with EPS for a processing payment (e.g. the customer closed the browser). We also re-check these automatically in the background.
Lists payments (newest first) with cursor pagination.
Cancel a payment
Cancels a payment whose status is still pending (customer hasn't started paying). Sends payment.cancelled.
Refunds / returns
| Field | Type | Required | Description |
|---|---|---|---|
| payment_id | string | required | ID of a successful payment. |
| amount | number | optional | Partial amount. Defaults to the full refundable balance. |
| reason | string | required | Why the customer is being refunded (3 – 500 chars). |
curl -X POST https://pay.texonltd.com/api/v1/refunds \
-H "Authorization: Bearer $TEXONPAY_KEY" -H "Content-Type: application/json" \
-d '{ "payment_id": "cm4x2k9qz0001abcd", "amount": 500, "reason": "Item returned" }'
# 201 → { "id": "cm4y…", "object": "refund", "status": "requested", "amount": 500, ... }Refunds are reviewed by Texon Pay finance and processed back to the customer's original method via EPS. Status moves requested → approved → processed (or rejected), each with a webhook. Check status with GET /refunds/{id} or GET /refunds?payment_id=.
Payment object & statuses
| Field | Type | Required | Description |
|---|---|---|---|
| pending | status | optional | Created, customer hasn't started paying. |
| processing | status | optional | Customer was sent to EPS; waiting for confirmation. |
| success | status | optional | Paid and verified with EPS. Final. |
| failed | status | optional | Payment failed. Final — create a new payment to retry. |
| cancelled | status | optional | Cancelled by customer or merchant. Final. |
| expired | status | optional | Link expired. Final. |
| partially_refunded / refunded | status | optional | Part or all of a successful payment has been refunded. |
Errors
Errors use standard HTTP status codes and a JSON body:
HTTP/1.1 422 Unprocessable Entity
{ "error": { "code": "validation_error", "message": "Request validation failed",
"fields": [ { "field": "amount", "message": "Number must be greater than or equal to 1" } ] } }| Field | Type | Required | Description |
|---|---|---|---|
| 401 unauthorized | optional | Missing, invalid or revoked API key. | |
| 403 org_suspended / live_disabled | optional | Organization suspended or live mode not enabled. | |
| 404 not_found | optional | Payment / refund doesn't exist for this key's organization and mode. | |
| 409 duplicate_order_id | optional | order_id already used for a closed payment or with a different amount. | |
| 422 validation_error | optional | Invalid fields. See error.fields. | |
| 429 rate_limited | optional | Too many requests (240/min per key). | |
| 5xx | optional | Temporary problem — retry with backoff. |
Testing & go-live
- Use a
tx_test_key. Sandbox checkouts run on the EPS sandbox — use the test wallets / cards EPS shows on its sandbox page. - Test success, failure and cancel flows, and confirm your webhook handler verifies signatures and is idempotent.
- Ask your Texon Pay contact to enable live mode, then switch to a
tx_live_key. Nothing else changes in your code. - Show the EPS "Pay with" payment-methods banner in your website footer / checkout page.