TexonPay

Developers

Texon Pay API

Everything you need to accept EPS payments on your website: create payments, receive webhooks and handle refunds.

Overview

Texon Pay lets your website accept payments through EPS (bKash, Nagad, Rocket, Upay, cards, internet banking …) with a hosted checkout. The flow is:

  1. Your server creates a payment with POST /payments and receives a payment_url.
  2. You redirect the customer to payment_url. They confirm their details and pay on EPS.
  3. We verify the payment with EPS, send a signed webhook to your server and redirect the customer to your success_url / fail_url.
  4. You fulfil the order when you receive payment.succeeded (or after confirming via GET /payments/:id).
Base URL: https://pay.texonltd.com/api/v1

Authentication

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

POSThttps://pay.texonltd.com/api/v1/payments
FieldTypeRequiredDescription
order_idstringrequiredYour unique order reference (max 100 chars). Re-sending the same order_id + amount while the payment is still open returns the same payment (idempotent).
amountnumberrequiredAmount in BDT, e.g. 1250 or 1250.50 (min 1).
product_namestringrequiredShown to the customer on checkout.
product_categorystringoptionalOptional category.
descriptionstringoptionalInternal description (max 500).
customer.name / email / phonestringoptionalPre-fills checkout. The customer can edit them before paying.
customer.address / city / postcode / countrystringoptionalBilling address (country = 2-letter code, default BD).
success_urlurloptionalWhere the customer is sent after a successful payment.
fail_urlurloptionalWhere the customer is sent after a failed payment.
cancel_urlurloptionalWhere the customer is sent if they cancel (defaults to fail_url).
expires_in_minutesintegeroptionalLink lifetime, 5 – 10080 minutes (default set per organization).
metadataobjectoptionalFlat 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.

FieldTypeRequiredDescription
payment.succeededeventoptionalPayment verified as paid with EPS. Fulfil the order.
payment.failedeventoptionalPayment failed at EPS / bank.
payment.cancelledeventoptionalCustomer cancelled, or you cancelled a pending payment.
payment.expiredeventoptionalPayment link expired without payment.
refund.requested / approved / rejected / processedeventoptionalRefund lifecycle updates. data = refund object.
test.pingeventoptionalSent 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

GEThttps://pay.texonltd.com/api/v1/payments/{id}
GEThttps://pay.texonltd.com/api/v1/payments/order:{order_id}

Returns the payment object including its refunds. Use this to confirm a payment from your server.

POSThttps://pay.texonltd.com/api/v1/payments/{id}/verify

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.

GEThttps://pay.texonltd.com/api/v1/payments?status=success&order_id=&limit=20&starting_after=

Lists payments (newest first) with cursor pagination.

Cancel a payment

POSThttps://pay.texonltd.com/api/v1/payments/{id}/cancel

Cancels a payment whose status is still pending (customer hasn't started paying). Sends payment.cancelled.

Refunds / returns

POSThttps://pay.texonltd.com/api/v1/refunds
FieldTypeRequiredDescription
payment_idstringrequiredID of a successful payment.
amountnumberoptionalPartial amount. Defaults to the full refundable balance.
reasonstringrequiredWhy 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

FieldTypeRequiredDescription
pendingstatusoptionalCreated, customer hasn't started paying.
processingstatusoptionalCustomer was sent to EPS; waiting for confirmation.
successstatusoptionalPaid and verified with EPS. Final.
failedstatusoptionalPayment failed. Final — create a new payment to retry.
cancelledstatusoptionalCancelled by customer or merchant. Final.
expiredstatusoptionalLink expired. Final.
partially_refunded / refundedstatusoptionalPart 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" } ] } }
FieldTypeRequiredDescription
401 unauthorizedoptionalMissing, invalid or revoked API key.
403 org_suspended / live_disabledoptionalOrganization suspended or live mode not enabled.
404 not_foundoptionalPayment / refund doesn't exist for this key's organization and mode.
409 duplicate_order_idoptionalorder_id already used for a closed payment or with a different amount.
422 validation_erroroptionalInvalid fields. See error.fields.
429 rate_limitedoptionalToo many requests (240/min per key).
5xxoptionalTemporary 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.