StampMitraDevelopers
Livee-Stamp Paper APIStep 7 of 8

e-Stamp payment: wallets, top-ups and what is debited when an order is created

Create a payment intent and check payment status for an order.

POST/v1/payments/intentsScope payments.writeAPI fee ₹5 per call
curl -X POST "https://api-b2b.stampmitra.in/v1/payments/intents" \
  -H "Authorization: Bearer $STAMPMITRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "externalOrderId": "ord_ext_123",
    "amountMinor": 50000,
    "currency": "INR",
    "paymentConnectionId": "pc_8d1f3a2b"
  }'
Example responseJSON
{
  "id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "externalOrderId": "ord_ext_123",
  "coreOrderId": null,
  "amountMinor": 50000,
  "currency": "INR",
  "status": "CREATED",
  "providerIntentId": "order_Nf3k2m9QxPz1Ab",
  "createdAt": "2026-10-15T09:41:07.000Z"
}

"Payment" is the most overloaded word in the e-Stamp flow. It can mean the customer paying you, you paying StampMitra for the stamp, StampMitra paying the state through the issuing side, or you paying for the API calls themselves. A developer who treats those as one thing will eventually debit the wrong balance, show the wrong message or explain the wrong invoice. This page separates them. It explains the three balances behind an e-Stamp integration, how each one is funded, when each one is debited, how GST enters, how to size and monitor the balances, and what the generic payment-intent resource in the reference is really for. It is step seven of the eight-step e-Stamp flow.

The short version, which the rest of the page earns: duty and fees are paid from prepaid wallets at the moment an order is created, and a payment is never the same as an issued stamp.

Three balances, three jobs

An organisation integrating e-Stamp deals with three balances. They are kept apart on purpose.

BalanceWhat it pays forGST treatmentHow you fund itDebited when
API credit walletStampMitra's API fee on metered calls: duty calculation, parties, and per-order fee where enabledCharged with GST, with GST invoicesTop-up from the dashboard, with a minimum top-up before GSTA metered call succeeds
Service Fee WalletThe procurement and convenience fees on an e-Stamp orderGST is added at top-up. The order debits the fee net of GSTPOST /v1/service-fee-wallet/topupAn order is created
Stamp Duty WalletThe statutory duty itselfNone. No GST is ever addedPOST /v1/stamp-duty-wallet/topupAn order is created

The duty is the government's money and passes through at cost. The fees are StampMitra's and the issuing side's service charges and carry GST. The API fee is StampMitra's charge for using the API. Three different kinds of money, three balances, and an order creation that touches two of them at once.

The Stamp Duty Wallet

The Stamp Duty Wallet holds money for statutory duty. Three routes cover it, all under the base URL https://api-b2b.stampmitra.in.

RoutePurposeScopeRate limit
GET /v1/stamp-duty-walletCurrent balancestamp-duty-wallet.read60 per 60 s
POST /v1/stamp-duty-wallet/topupStart a top-upstamp-duty-wallet.topup20 per 60 s
GET /v1/stamp-duty-wallet/transactionsPaginated ledgerstamp-duty-wallet.read60 per 60 s
cURL
export STAMPMITRA_API_KEY="sk_test_xxxxxxxxxxxx"
export BASE="https://api-b2b.stampmitra.in"

curl -s "$BASE/v1/stamp-duty-wallet" -H "Authorization: Bearer $STAMPMITRA_API_KEY"
JSON
{ "balance": "1250.00", "currency": "INR" }

The balance is a decimal string. Parse it before comparing, and never concatenate it. A top-up takes a baseAmount in rupees, which must be a positive number:

cURL
curl -s -X POST "$BASE/v1/stamp-duty-wallet/topup" \
  -H "Authorization: Bearer $STAMPMITRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "baseAmount": 5000 }'
JSON
{
  "baseAmount": "5000.00",
  "gstAmount": "0.00",
  "totalCharged": "5000.00",
  "razorpayOrderId": "order_Lm3n4o5p6q7r8s",
  "razorpayKeyId": "rzp_live_1234567890abcd"
}

The response is not a credited balance. It is the pair of identifiers your front end needs to open Razorpay Checkout. gstAmount is 0.00 because no GST is added to this wallet, so totalCharged equals baseAmount. The values above are illustrative.

POST/v1/payments/intents

Create a payment intent

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.
Idempotency-KeyheaderOptional idempotency key (1 to 255 characters), kept for 24 hours. The same key and the same request replays the stored response; the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; the same key while the first request is still running is 409 IDEMPOTENCY_IN_PROGRESS (see Retry-After).
externalOrderIdrequiredstringYour reference for the order being paid.
amountMinorrequiredintegerAmount in minor units (paise); positive integer.
currencyrequiredstringCurrency code, at least 3 characters, e.g. INR.
paymentConnectionIdrequiredstringId of one of your active payment connections.

Response fields

Response fields
FieldType
idstring
externalOrderIdstring
coreOrderIdnull
amountMinornumber
currencystring
statusstring
providerIntentIdstring
createdAtstring

GET/v1/payments/intents/:id

Get a payment intent

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.

Response fields

Response fields
FieldType
idstring
externalOrderIdstring
coreOrderIdnull
amountMinornumber
currencystring
statusstring
providerIntentIdstring
createdAtstring

GET/v1/orders/:id/payment

Get an order's payment

Request parameters

Request parameters
FieldTypeDescription
AuthorizationrequiredheaderBearer <api-key> (e.g. sk_test_... in sandbox, sk_live_... in production). The x-api-key header is also accepted.

The Service Fee Wallet

The Service Fee Wallet has the same three routes and adds invoices.

RoutePurposeScope
GET /v1/service-fee-walletCurrent balanceservice-fee-wallet.read
POST /v1/service-fee-wallet/topupStart a top-up. GST is added on top of baseAmountservice-fee-wallet.topup
GET /v1/service-fee-wallet/transactionsPaginated ledgerservice-fee-wallet.read
GET /v1/service-fee-wallet/invoices, GET .../invoices/:idGST invoices for top-upsservice-fee-wallet.invoices.read

The top-up response shows the GST added:

JSON
{
  "baseAmount": "500.00",
  "gstAmount": "90.00",
  "totalCharged": "590.00",
  "razorpayOrderId": "order_Pq9r8s7t6u5v4w",
  "razorpayKeyId": "rzp_live_1234567890abcd"
}

Read it closely, because it explains how GST reaches the books. The customer-facing charge is totalCharged: the base amount plus 18 percent GST. The wallet is credited with the base. When an order later debits the service fee, it debits the amount net of GST, because the GST on that amount was already collected, once, at top-up. That is why the invoices attach to top-ups and not to individual orders. If your finance team asks where the GST on an order's fees was charged, the answer is on the invoice for the top-up that funded the wallet.

Funding a wallet: the Razorpay Checkout sequence

A top-up is a three-party dance: your server, your user's browser and Razorpay. Keep the sequence in mind, since each party owns one step.

  1. Your server calls the top-up route and receives razorpayOrderId, razorpayKeyId and totalCharged.
  2. Your front end opens Razorpay Checkout with those values, so the person paying completes the payment with Razorpay directly.
  3. Razorpay confirms the payment to StampMitra. The wallet is credited by that confirmation. Your browser's "payment succeeded" callback is a hint, not the credit.
  4. Your server reads the balance or the ledger until the top-up appears, and only then lets the user continue.
JavaScript
// Browser: open Checkout with values your server obtained from the top-up route
function openCheckout({ razorpayKeyId, razorpayOrderId, totalCharged }, onDone) {
  const rzp = new window.Razorpay({
    key: razorpayKeyId,
    order_id: razorpayOrderId,
    amount: Math.round(Number(totalCharged) * 100),   // paise
    currency: "INR",
    name: "Your company",
    handler: () => onDone(),                          // a hint; confirm on your server before relying on it
  });
  rzp.open();
}
Python
import os, time, requests

BASE = "https://api-b2b.stampmitra.in"
H = {"Authorization": f"Bearer {os.environ['STAMPMITRA_API_KEY']}"}

def wallet_balance(path: str) -> float:
    r = requests.get(f"{BASE}{path}", headers=H, timeout=15)
    r.raise_for_status()
    return float(r.json()["balance"])

def wait_for_credit(path: str, before: float, expected_increase: float, timeout_s: int = 300) -> bool:
    """Poll the wallet until the top-up lands, or give up and flag it for a person."""
    deadline = time.time() + timeout_s
    while time.time() < deadline:
        if wallet_balance(path) >= before + expected_increase - 0.005:
            return True
        time.sleep(5)
    return False

Never credit your own "available funds" display from the browser callback. Trust the wallet's balance or ledger. A user can close the tab after paying, and the credit still arrives, so poll on the server and let the user come back to a screen that shows the truth.

Reading the balance and the ledger

Both e-Stamp wallets return the same ledger shape from their transactions routes, paginated with a limit query parameter and a cursor.

cURL
curl -s "$BASE/v1/stamp-duty-wallet/transactions?limit=20" -H "Authorization: Bearer $STAMPMITRA_API_KEY"
JSON
{
  "items": [
    {
      "id": "txn_01",
      "type": "TOPUP",
      "amount": "5000.00",
      "balanceAfter": "6250.00",
      "referenceId": "order_Lm3n4o5p6q7r8s",
      "description": "Wallet top-up",
      "mode": "RAZORPAY",
      "createdAt": "2026-10-29T08:55:10.000Z"
    }
  ],
  "nextCursor": null
}
FieldWhat it tells you
idThe ledger entry id
typeThe kind of movement, for example TOPUP, and debit or refund types for orders
amountThe movement, as a decimal string
balanceAfterThe balance after this movement
referenceIdWhat caused it: a Razorpay order for a top-up, or an order reference for a debit
descriptionA human-readable note
modeHow the money moved, such as RAZORPAY
createdAtWhen it happened

The ledger is your reconciliation source. Walk it with nextCursor until it is null, store entries by id, and match debits to orders through referenceId. A nightly job that sums movements and compares them with the balance catches any drift early.

When money moves at order creation

Order creation is where the two e-Stamp wallets are debited, and the sequence matters.

  1. The order is validated and priced afresh, per line.
  2. The duty total is debited from the Stamp Duty Wallet.
  3. The service fee total, net of GST, is debited from the Service Fee Wallet.
  4. Only then is the order record written.

If step three fails, step two is reversed with a refund entry. If the order cannot be written after both debits, both are credited back. Debits are keyed to the order reference, so a retry with the same idempotency key does not charge twice: at most one live debit exists per wallet and reference, and a retry after a failure that kept the debits reuses them. A retry after a failure that was refunded charges again, since the refund reversed the earlier debit.

A shortfall in either balance refuses the order before anything is written. The answer is a 402 PAYMENT_REQUIRED whose message names the wallet that is short, the Stamp Duty Wallet or the Service Fee Wallet. Top up that wallet. After topping up, retry with the same Idempotency-Key and the same body. Since nothing was created, the retry runs cleanly. The order page covers the create route and its keys.

Sizing the balances

How much to keep in each wallet is a working-capital question with a practical answer. Duty is the large number and fees the small one, so the Stamp Duty Wallet needs the most attention.

InputHow to get it
Orders per dayYour own volume, peak day rather than average
Typical duty per orderFrom your own quotes, by state and article
Typical fees per orderFrom the quote's service charge subtotal, by state
Lead time for a top-upHow long your finance process takes to approve and pay
Safety marginA multiple, such as one to two days of peak volume

A simple rule is: keep at least lead time in days x peak daily need x 1.5 in each wallet, and top up when the balance falls to that floor. The two wallets deplete at different rates, so track them separately. Illustrative arithmetic helps: if peak is 40 orders a day with an average duty of 1,000 and fees of 150, the Stamp Duty Wallet burns around 40,000 and the Service Fee Wallet around 6,000 on a peak day, and with a two-day lead time and a 1.5 margin you would hold about 120,000 and 18,000. These numbers are examples, not recommendations.

Do not size from averages alone. Months have peaks, such as the start of academic and tenancy cycles, and an order refused for a short balance on the busiest day is the most expensive refusal you will have.

Watching burn rate by state and article

Duty is not evenly spread. A product that stamps a few high-value articles in one state can drain the Stamp Duty Wallet quickly, while a product that stamps many low-value articles across states barely moves it. Break your burn rate down by state and article from your own order records, since the ledger's references let you attribute each debit to an order. Two uses follow. A top-up policy tied to the next week's expected mix is more accurate than one tied to last month's average. And an outlier is easy to spot: one order that debits many times the usual duty is either a large legitimate document or a mistaken amount, and worth a second look before it is created. A simple pre-submit rule, such as asking for a second approver above a threshold you set, turns that observation into a control.

Alerts and a low-balance policy

Treat low balance as an operational event with an owner. A reasonable policy has three parts.

  1. Measure often. A job reads both balances every few minutes during business hours and writes the numbers to your metrics.
  2. Alert in tiers. A warning when a balance falls to your floor, a page when it is below one day of volume, and a hard stop on new orders if it is below what your largest likely order needs.
  3. Make top-up easy. A runbook, an approver on call and a saved payment method in your finance process shorten the gap between alert and money.

For the API credit wallet, the dashboard shows a low-balance state, and the platform treats production calls differently once the balance is exhausted. Watch it as well, since an exhausted API credit wallet makes quoting and parties calls fail with a 402 even when both e-Stamp wallets are full.

The API credit wallet and the API fee

Separately from the stamp money, StampMitra charges an API fee for metered calls. For the e-Stamp surface the metered calls are duty calculation, parties, and order creation where the per-order fee is enabled. The fee is ₹5 per charged call on pay-as-you-go before GST, lower on Growth and Scale, and your plan's rate is on the pricing page. It is debited from the API credit wallet, which you top up from the dashboard with a minimum top-up before GST, and which carries GST invoices on the billing page.

Several rules from the pricing page apply: wallets are prepaid only, there is no postpaid or credit, malformed requests rejected with a 400 are not charged, and calls that fail on StampMitra's side or its provider's side are credited back automatically. Sandbox calls never debit the wallet.

Sandbox

Free

Build and test with a sandbox key.

Production API fee

₹5 / call

Pay-as-you-go per successful call, lower on Growth and Scale. Excludes 18% GST. State procurement fee and stamp duty are quoted per order. Full pricing

Access scope

payments.write

Your API key needs this scope to call the endpoint.

Keep this wallet out of your stamp reconciliation. A quote costs the API fee and moves no stamp money, and an order moves stamp money and may or may not carry a per-order API fee. The two ledgers answer different questions.

The generic payment intent

The reference page for payment also documents a generic payment resource, which sounds like it must be central and is not what e-Stamp orders draw from. POST /v1/payments/intents creates a payment intent backed by Razorpay, and GET /v1/payments/intents/:id reads it.

FieldMeaning
externalOrderIdYour reference for the order being paid (request)
amountMinorThe amount in paise, a positive integer (request)
currencyA currency code, for example INR (request)
paymentConnectionIdThe id of one of your active payment connections (request)
id, status, providerIntentId, coreOrderId, createdAtReturned: the intent id, its status such as CREATED, the provider's id, and timestamps

The scopes are payments.write and payments.read, and the create route accepts an optional Idempotency-Key. The related GET /v1/orders/:id/payment reads the payment attached to a generic order under orders.read. Payment events from the provider reach StampMitra on a server-to-server route that is signature-verified and is never called by your frontend or your backend.

The honest reading is this. The payment-intent resource is the platform's generic building block for gateway payments, tied to the generic order resource. The e-Stamp order routes fund themselves from the two wallets instead. If you integrate the generic resource for another purpose, keep it separate in your code from the wallet flows, and do not model an e-Stamp order as a payment intent plus an order. Ask developer support if you believe your account needs the intent path for stamping.

Payment is not issuance

A successful payment or a successful wallet debit is not an issued stamp. Between the debit and a certificate sit a human review, a placement with the issuing side, generation and verification, which can take time and can fail. StampMitra's service terms say that payment confirmation does not necessarily mean the instrument has been issued, and that you must not represent a payment as an issued instrument until the applicable status is confirmed.

Your internal stateEvidenceWhat to show the customer
paidWallet debited at order creation, order record exists"Payment received. Your stamp request is with our team"
in_reviewOrder in a pre-placement status"We are reviewing your request"
placedStamps exist and are progressing"Your stamp is being generated"
stampedCertificate available and saved"Your stamp is ready" with a download
refunded or cancelledOrder cancelled, credits seen in the ledger"Your request was cancelled" and what happens to the money

Never skip from paid to stamped. The status routes and the certificate route are the only evidence for the last step, as the document access page explains.

Who pays: you, or your customer

Most products sit between a customer and StampMitra, and you choose how the customer's money reaches the wallets. Three patterns are common, and none of them involves StampMitra collecting from your customer directly.

  • Pre-funded, absorbed. You keep the wallets topped up and recover the cost inside your own pricing. Simple for the customer, with working capital on your side.
  • Pre-funded, passed through. You collect the quote's total from the customer through your own checkout, then rely on your pre-funded wallets for the actual debit. You need a margin of float, and your reconciliation must tie each customer payment to an order and its debits.
  • Top-up on demand. You collect from the customer and top up the wallets just in time. This avoids float and adds a delay and a failure mode: the customer has paid, and the top-up has not yet landed.

Whichever you choose, say plainly on your own checkout screen what the customer is paying for, with duty, fees and GST shown as separate lines, because a customer who understands the split rarely disputes it later. Keep your own record of what each customer paid and which order it covered, and decide in advance what happens to the customer's money if an order is cancelled. The platform credits wallets back on a failed creation; what you return to your customer, and how fast, is your policy.

Tying ledgers to orders and invoices

A reliable reconciliation joins four things: your orders, the two e-Stamp ledgers, the Razorpay receipts for top-ups, and the GST invoices. A short daily job is enough to keep them honest.

JoinKeyWhat a mismatch means
Your order to a duty debitThe order reference in the ledger's referenceIdA debit with no order, or an order with no debit
Your order to a fee debitThe same reference in the Service Fee ledgerSame, for the fee side
A top-up to a Razorpay receiptrazorpayOrderIdA top-up that was paid but never credited, or credited twice
A Service Fee top-up to an invoiceThe invoice id or the order id on itA missing invoice, which finance will ask about at month end
Python
import os, requests

BASE = "https://api-b2b.stampmitra.in"
H = {"Authorization": f"Bearer {os.environ['STAMPMITRA_API_KEY']}"}

def ledger(path: str):
    """Yield every ledger entry, following the cursor to the end."""
    cursor = None
    while True:
        params = {"limit": 100, **({"cursor": cursor} if cursor else {})}
        r = requests.get(f"{BASE}{path}/transactions", headers=H, params=params, timeout=20)
        r.raise_for_status()
        page = r.json()
        yield from page["items"]
        cursor = page.get("nextCursor")
        if not cursor:
            return

def unmatched_debits(path: str, known_references: set[str]) -> list[dict]:
    """Debits whose reference is not one of our orders: worth a human look."""
    return [e for e in ledger(path) if e["type"] != "TOPUP" and e["referenceId"] not in known_references]

Run the same job for both wallets, and add one more check: the running total of amount by type should explain the current balance. When it does not, stop and escalate with the entry ids, because the cheapest time to fix a ledger question is the day it appears.

Making top-ups safe against double payment

A top-up is a payment initiated by a person. People double-click, refresh and retry, so protect them.

  1. Disable the button once pressed and show a "payment in progress" state until you have an answer.
  2. Create your own top-up record before calling the route, with a unique id, the amount, the wallet and who started it, and attach the razorpayOrderId when you receive it. Then a refresh finds the pending record instead of starting another top-up.
  3. Reuse an open top-up instead of creating a second one for the same purpose within a short window. Each call to the route creates a new Razorpay order, and each can be paid.
  4. Confirm from the wallet, not the browser. Mark your record complete only when the ledger shows the credit, and keep it "pending" if it has not appeared after the timeout, with an alert.
  5. Reconcile pending records daily. A top-up pending for more than a day is either unpaid or unreflected, and either deserves a person.

None of this requires anything from StampMitra beyond reading the ledger, so you can build it in an afternoon and test it with recorded fixtures. It is plain discipline around a payment flow, and it prevents the unpleasant case where a customer has paid twice and your records show once.

Who may move money

A top-up route can start a payment, and a wallet read reveals balances. Give them the care that money deserves.

  • Separate the keys. The service that creates orders should not hold the top-up scopes, and the service that tops up should not hold the order scopes. A leak of one key then cannot both spend and fund.
  • Restrict by network where your plan allows. An IP allowlist on the keys that touch wallets is cheap protection.
  • Keep payment secrets out of your own code and logs. The Razorpay key id is a public identifier meant for the browser. Anything secret stays with Razorpay and StampMitra.
  • Require approval for large top-ups. Make the amount at which a second approver is needed a documented policy.
  • Record who did what. Store the person, the time, the amount, the wallet and the razorpayOrderId for every top-up, and the person who approved it.
  • Alert on the unexpected. A top-up outside business hours, a burst of top-ups, or a wallet read from an unfamiliar address deserves a message to someone.

These habits are the same ones you would apply to any payment integration, and they matter more here because an order creation spends from the wallets without any further prompt.

Failure modes and what to do

SituationSignalWhat to do
A wallet is short at creationRefused before anything is written, as 402 PAYMENT_REQUIRED naming the walletTop up that wallet, retry with the same key
The API credit wallet is empty402 PAYMENT_REQUIRED on a metered callTop up from the dashboard, then retry
The user closed the tab after payingNo browser callbackPoll the wallet from your server; the credit arrives anyway
A top-up never appearsBalance unchanged after a reasonable waitCheck the ledger and your Razorpay receipt, then contact support with the razorpayOrderId
A debit appears but no order existsLedger shows a debit with an order referenceList orders by your reference; if none, contact support with the reference
An order was created and then cancelledOrder status CANCELLEDWatch the ledger for the credit, and do not promise a refund time to your customer
Two debits for one orderTwo ledger entries with the same referenceContact support with both ids; do not retry

Errors and how to react

All errors use { "error": { "code", "message", "requestId" } }.

StatusCodeWhenWhat to do
400BAD_REQUESTbaseAmount is not a positive numberFix the amount
401UNAUTHORIZEDMissing or invalid keyFix the key
403FORBIDDENValid key without the wallet scopeAdd stamp-duty-wallet.read, .topup or the service fee equivalents
404NOT_FOUNDNo such invoice for your organisationCheck the invoice id
429TOO_MANY_REQUESTSRate limit exceeded: 60 per 60 s for reads, 20 per 60 s for top-upsBack off
502INTERNAL_ERRORThe wallet service is unreachableRetry with backoff; do not assume a top-up was or was not started

A top-up call that times out is a prompt to read the ledger before you call again, since a second call creates a second Razorpay order. Both orders can be paid, and both would credit the wallet, so make the retry decision from the ledger and not from the timeout.

GST, invoices and the accounting view

Three kinds of document matter to your finance team. Invoices for the API credit wallet are on the billing page of the dashboard. Invoices for Service Fee Wallet top-ups come from GET /v1/service-fee-wallet/invoices. The Stamp Duty Wallet carries no GST and no invoice route, because duty is a pass-through of the government's money.

A plain summary of what is taxed: StampMitra's own charges carry 18 percent GST, which is collected at top-up for the Service Fee Wallet and invoiced for the API credit wallet. The statutory duty carries none. How you treat these in your own accounts, and whether any input tax credit is available, depends on your own position, so take that to your accountant. Match each top-up to its invoice by the razorpayOrderId or the invoice id, and archive invoices with the ledger entry that references them.

Sandbox and production

A sandbox key has its own pair of wallets, and they are fake. The Stamp Duty Wallet and the Service Fee Wallet in sandbox are counters kept for your organisation in a separate sandbox ledger. They are not the real wallets, they never touch a payment provider, and nothing in them is money, so the sandbox lets you test the whole money loop for free. This chapter describes how they behave. The order side is on the order page. Wallet calls count too: balance, top-up, ledger and invoice requests all count toward the sandbox limits (10 requests a minute and 200 a day per organisation, and 50 a day per IP address, resetting at midnight IST), the same allowance as quotes and orders, so poll a balance sparingly.

Balances, top-ups and the cap

The first call to either wallet creates both with a starting balance, so you can create an order straight away.

ItemSandbox behaviour
Starting balance, Stamp Duty WalletINR 50,000 of fake credit
Starting balance, Service Fee WalletINR 5,000 of fake credit
POST .../topup with baseAmountAdds that amount instantly, with no checkout and no payment
Most one wallet can holdINR 10,00,000. A top-up past that answers 400 and changes nothing
GET .../transactionsNewest first, with type SEED, TOPUP, DEBIT or REFUND and mode SANDBOX
GET /v1/service-fee-wallet/invoicesEmpty, because a fake top-up produces no tax invoice

The sandbox top-up response keeps the production money fields (baseAmount, gstAmount, totalCharged) so your parsing carries over, and adds sandbox: true, credited, balance and a notice. The Service Fee Wallet shows the 18 percent GST on top as production does, but only baseAmount is credited and nothing is charged. There is no razorpayOrderId and no razorpayKeyId, because there is no checkout to open. Branch on sandbox: true in your top-up screen, and keep the production Checkout code behind the live key.

What an order does to the wallets

Creating an order debits the fake wallets in one step. The Stamp Duty Wallet pays the duty total. The Service Fee Wallet pays the service charges before GST, the same split as production, because GST on the service fee is collected when the wallet is topped up. If either balance is short, the create answers 402 with the usual envelope, the code PAYMENT_REQUIRED and a message that names the short wallet, such as The Stamp Duty Wallet balance is too low for this order, and a wallet field with STAMP_DUTY or SERVICE_FEE. Production answers the same way. Nothing is created and nothing stays debited. Top up and send the same request again.

An order that ends PAYMENT_FAILED, ISSUANCE_FAILED, CANCELLED or EXPIRED credits both amounts back, once, as a REFUND row, so your reconciliation job sees a debit and its refund for every failed order. An order that reaches ISSUED keeps its debit. Two orders sent at the same moment cannot both spend the same balance.

Why this still is not a complete rehearsal

The sandbox shows you the shape and the arithmetic of the money loop. It cannot show you the real payment checkout, real GST invoices, how long a real top-up takes to appear, or a real price book. The fee schedule in sandbox is illustrative, so do not copy its figures into your own pricing. Test the Checkout sequence with the payment provider's own test tools, test your balance polling and reconciliation against recorded ledger fixtures, and rehearse the full path once in production with a low-value order and a small top-up before launch. Production needs an approved production access request. The sandbox versus production guide covers the switch.

Worked example: a Monday morning

A broker platform expects forty orders on a Monday after a weekend of listings. On Friday evening its balance job showed the Stamp Duty Wallet at a level that covers about one day of volume and the Service Fee Wallet comfortably above its floor.

At eight in the morning, the job pages the finance on-call: the Stamp Duty Wallet is below one day of the expected peak. The on-call approves a top-up. The platform's server calls the top-up route with a baseAmount, gets razorpayOrderId and razorpayKeyId, and the finance user pays through Checkout. The server polls the wallet and sees the credit within a minute. The alert clears.

At ten, an order creation returns a 402 whose message names the Service Fee Wallet. The worker does not retry blindly. The wallet has dipped below the fees for the order, because Friday's top-up had assumed a lower average. The worker pauses new submissions, raises a top-up request for the Service Fee Wallet, and, when the credit shows in the ledger, resumes with the same idempotency key. No order was created by the failed attempt, and the retry succeeds. The ledger shows one duty debit and one fee debit for the order, each with the order reference.

In the afternoon, a customer cancels an order that is still in review. The platform cancels it before placement. The ledger shows refund entries for the duty and the fee. The platform tells the customer the request was cancelled and that the amount will be returned according to its own refund policy.

Testing

TestWhat it proves
A top-up response is parsed into razorpayOrderId, razorpayKeyId and totalChargedYou can open Checkout
The balance is not credited from the browser callbackYou trust the server-side wallet
Polling the wallet detects a credit within the timeout and flags a missYou handle late and missing credits
A 402 on creation pauses submissions and raises a top-up for the wallet the message names, not a blind retryShortfalls are handled as shortfalls
Retrying after a refill uses the same idempotency keyYou do not create duplicates
The nightly ledger sum equals the balanceReconciliation works
Duty and fee debits for each order match its referenceYou can explain every order
A timed-out top-up call is resolved from the ledgerYou never create a second Razorpay order by reflex

Common mistakes

  • Treating payment as issuance. A debit is not a stamp.
  • Crediting from the browser callback. The wallet is credited by the confirmation, so read the balance.
  • Mixing the three balances. API fee, fees and duty are separate ledgers.
  • Retrying a top-up on timeout. Read the ledger first, since a second call makes a second Razorpay order.
  • Sizing from averages. Peak days decide refusals.
  • Retrying a 402 on creation without topping up. Top up the wallet the message names, then retry with the same key.
  • Expecting GST on duty. Duty is untaxed and has no invoice.
  • Using payment intents for stamping. The e-Stamp routes fund themselves from the wallets.
  • Promising refund timing to customers. Credits follow the platform's process, and your promise is your own.

Where this fits in the flow

Payment is step seven of eight. Before it come the catalogue, the schema, the state, instrument and article lookup, the duty and value calculation, the parties and the order. After it comes the order status and document access. The overview guide shows all eight with a rental example, and the e-Stamp API reference lists the routes in tabular form.

StampMitra is a private LegalTech platform operated by Bani Global Industries LLP. It is not a government body or a law firm, and nothing here is legal, tax or accounting advice. Confirm your own obligations with qualified professionals.

Sources

Frequently asked questions

How is an e-stamp order paid for through the API?

At order creation, before any record is written, the platform debits the statutory duty from your Stamp Duty Wallet and the service fee, net of GST, from your Service Fee Wallet. Both are prepaid balances you fund with top-ups.

Is GST charged on stamp duty?

No. The Stamp Duty Wallet never adds GST, because duty passes through at cost. GST at 18 percent applies to StampMitra's own charges: it is added when you top up the Service Fee Wallet and invoiced for the API credit wallet.

How do I top up the Stamp Duty Wallet?

POST /v1/stamp-duty-wallet/topup with a positive baseAmount returns razorpayOrderId and razorpayKeyId. Open Razorpay Checkout with them, then read the wallet balance on your server until the credit appears, rather than trusting the browser callback.

Why does the Service Fee Wallet top-up show a GST amount?

GST is added on top of baseAmount at top-up, so totalCharged is base plus GST. The wallet is credited with the base, and orders later debit fees net of GST. Invoices therefore attach to top-ups and are listed at GET /v1/service-fee-wallet/invoices.

What happens if a wallet is short when I create an order?

The order is refused before anything is written and nothing is debited. The answer is a 402 PAYMENT_REQUIRED whose message names the wallet that is short, so top up that wallet and retry with the same Idempotency-Key.

Does paying mean the stamp is issued?

No. A debit is followed by human review, placement with the issuing side, generation and verification. Do not show a stamp as issued until the order and stamp statuses and a certificate say so.

What is the difference between the three balances?

The API credit wallet pays StampMitra's per-call API fee. The Service Fee Wallet pays procurement and convenience fees on orders. The Stamp Duty Wallet pays the statutory duty. They are separate ledgers and are never combined.

What are payment intents for?

POST /v1/payments/intents is the platform's generic Razorpay-backed payment resource tied to the generic order resource. E-Stamp orders fund themselves from the wallets instead, so keep intents separate from your stamping flow unless support advises otherwise.

How do I know a top-up has been credited?

Read GET /v1/stamp-duty-wallet or the service fee equivalent, or walk the transactions ledger, until a TOPUP entry with your razorpayOrderId appears. The credit comes from Razorpay's confirmation to StampMitra, not from your browser.

Can I retry a top-up call that timed out?

Read the ledger first. Each call creates a new Razorpay order and each can be paid, so a reflex retry can produce two payments. Create your own pending top-up record, reuse an open one, and reconcile pending records daily.

How much should I keep in each wallet?

Size from peak days, not averages: lead time in days times peak daily need times a margin such as 1.5, tracked separately for duty and fees. Alert in tiers and make top-up approval quick, since a refusal on your busiest day is the costly one.

Where do I get GST invoices?

API credit wallet invoices are on the dashboard billing page. Service Fee Wallet top-up invoices come from GET /v1/service-fee-wallet/invoices. The Stamp Duty Wallet has none because duty carries no GST. Ask your accountant how to treat them in your books.

Build with AI

Integrate Payment with one prompt.

Pick your AI tool and copy a prompt written for this API. It already has the endpoints, fields and errors.

Claude prompt · Payment · 6,675 charactersOpen Claude ↗
I'm using Claude to build this.

Integrate the StampMitra API (Indian identity verification and e-Stamp Paper) into my app.

API facts (source of truth: https://developer.stampmitra.in/llms.txt)
- Base URL: https://api-b2b.stampmitra.in
- Auth: send "Authorization: Bearer <key>" (or "x-api-key: <key>") on every request
- Requests and responses are JSON. Send Content-Type: application/json on POST.
- Use a SANDBOX key (sk_test_...) while building. Read it from the environment variable STAMPMITRA_API_KEY.
- Never hard-code the key, never expose it to the browser, never log it.
- Call StampMitra only from server-side code. The UI calls my own backend route.

How to build it
- First inspect my project: language, framework, package manager, HTTP client, test runner and folder conventions. Follow them. If the project is empty, ask which stack I want before writing code.
- The official StampMitra SDKs (Node.js, Python, PHP, Java, Go, .NET, Ruby) are pre-release 0.1.0 and not yet published to npm, PyPI, Packagist, Maven Central, the Go module proxy, NuGet or RubyGems, so do not run an install command for them. Call the REST API over HTTPS with the HTTP client my project already uses. Do not install or invent a StampMitra package.
- Put every StampMitra call in ONE small client module. It adds the auth header, applies a 15 second timeout and turns error responses into a typed error with status, code, message and requestId.
- Add STAMPMITRA_API_KEY to .env.example with a placeholder (sk_test_xxx). Fail fast at startup with a clear message if it is missing. Never commit real keys.

Error handling (every error body is { error: { code, message, requestId } })
- 400 BAD_REQUEST: invalid input. Show a field-level message. Do not retry.
- 401 UNAUTHORIZED: key missing or invalid. This is my configuration problem, not the end user's. Show a generic "service unavailable" message, log the requestId, do not retry.
- 402 PAYMENT_REQUIRED: not enough wallet balance (production). Surface it to me as an operational alert, not to the end user.
- 403 FORBIDDEN: the key lacks the required scope or the service is not enabled. Say which scope the endpoint needs.
- 404 NOT_FOUND: wrong id or path. Do not retry.
- 429 TOO_MANY_REQUESTS (or, on a sandbox key, SANDBOX_RATE_LIMIT, SANDBOX_DAILY_LIMIT, SANDBOX_IP_LIMIT): rate limit, or the sandbox limits of 10 requests a minute and 200 a day per organisation. Retry at most 3 times with exponential backoff and jitter (honour Retry-After if present), then show a friendly "try again shortly" message.
- 5xx / 502 / network timeout: retry reads (GET) up to 2 times. For POST calls retry at most once, then show a friendly message.
- Log requestId and referenceId with every failure. Never log the API key, a full PAN, bank account number or whole response bodies.

TASK: Integrate the StampMitra "Payment" API
Create a payment intent and check payment status for an order.

ENDPOINT: POST /v1/payments/intents
- Create a payment intent
- Required scope: payments.write
- Parameters:
  - Idempotency-Key (header, optional): Optional idempotency key (1 to 255 characters), kept for 24 hours. The same key and the same request replays the stored response; the same key with a different request is 422 IDEMPOTENCY_KEY_REUSED; the same key while the first request is still running is 409 IDEMPOTENCY_IN_PROGRESS (see Retry-After).
  - externalOrderId (string, required): Your reference for the order being paid.
  - amountMinor (integer, required): Amount in minor units (paise); positive integer.
  - currency (string, required): Currency code, at least 3 characters, e.g. INR.
  - paymentConnectionId (string, required): Id of one of your active payment connections.
- Example request body: {"externalOrderId":"ord_ext_123","amountMinor":50000,"currency":"INR","paymentConnectionId":"pc_8d1f3a2b"}
- Response fields: id, externalOrderId, coreOrderId, amountMinor, currency, status, providerIntentId, createdAt
- Example response: {"id":"7c9e6679-7425-40de-944b-e07fc1f90ae7","externalOrderId":"ord_ext_123","coreOrderId":null,"amountMinor":50000,"currency":"INR","status":"CREATED","providerIntentId":"order_Nf3k2m9QxPz1Ab","createdAt":"2026-10-15T09:41:07.000Z"}

ENDPOINT: GET /v1/payments/intents/:id
- Get a payment intent
- Required scope: payments.read
- Response fields: id, externalOrderId, coreOrderId, amountMinor, currency, status, providerIntentId, createdAt
- Example response: {"id":"7c9e6679-7425-40de-944b-e07fc1f90ae7","externalOrderId":"ord_ext_123","coreOrderId":null,"amountMinor":50000,"currency":"INR","status":"CREATED","providerIntentId":"order_Nf3k2m9QxPz1Ab","createdAt":"2026-10-15T09:41:07.000Z"}

ENDPOINT: GET /v1/orders/:id/payment
- Get an order's payment
- Required scope: orders.read

Rules for this e-Stamp step
- This is one step of the e-Stamp order flow: services -> state/instrument/article -> schema -> duty -> order -> parties -> payment -> status -> documents.
- Build the form from the schema endpoint and do not invent e-Stamp fields.
- Send an Idempotency-Key header on order creation, store the order id, and make the flow resumable.
- Poll order status with backoff until a final status. Download documents through my backend, never from the browser with the key.
- If an endpoint returns 404 or is not enabled for my key, stop and ask me rather than guessing.

Test in Sandbox
- A successful call, a validation failure (expect 400), a missing or wrong key (expect 401) and the 429 / 5xx retry path.

How I want you to work:
1. Before writing code, list the files you will create or change and the plan in 5-8 bullets. Then implement without pausing for approval.
2. If the StampMitra MCP server (@stampmitra/mcp-server) is connected, use it to run real sandbox calls and check the response shape before coding against it.
3. Write tests for the API client module and the validation (mock the HTTP layer).
4. At the end, summarise what you changed, how to run it and what I must do manually (add the key, restart the server).

Acceptance checklist:
- Works end to end in Sandbox with the real response fields (no mocked data in the final path)
- No secrets in client code, logs, URLs or git
- Clear loading, empty and error states, including 400, 401, 402, 403, 429 and 5xx
- referenceId (and requestId on failures) is stored or logged for audit
- Inputs are validated on client and server, and sensitive values are masked in the UI
- Tests cover the API client, validation and at least one error path
- A short note on how to run it and how to switch from Sandbox to production later
- If anything is missing (like my key), ask me. Do not guess endpoints, fields or values.

Start with a sandbox key.

Free to try. Make your first test call today.