
Official server-side SDKs for the SMEPay External API in Node.js, Go, Python, PHP, and Java. Zero third-party dependencies, automatic authentication & token refresh, typed error parsing, and flat ₹3 UPI pricing.
Official SMEPay SDKs
Pick your language to install
npm install smepay-nodeEvery SDK follows semantic versioning, carries zero third-party dependencies, is MIT licensed, and ships with a runnable full-flow example inside its examples/ folder.
In the SMEPay dashboard open Profile menu → Integrations → API Credentials and copy your Client ID and Client Secret. Store them in environment variables (SMEPAY_CLIENT_ID, SMEPAY_CLIENT_SECRET), never hardcoded in source files.
Match the SDK environment to the badge on API Credentials (a mismatch returns invalid_endpoint):
staging.smepay.in — No real money, no fees. Wallet balance must not be negative.extranet.smepay.in — Real payments, fees from SMEPay wallet. Server IP must be whitelisted and wallet balance must be ₹10 or more plus fees.When SMEPay switches your business to live, your Client Secret changes (your Client ID stays the same) — copy the new secret from API Credentials, ask SMEPay support to whitelist your server's public IP address(es), and keep your wallet at ₹10 or more.
Create Order
Pass amount, your unique order_id, callback_url, and customer email/mobile → returns order_slug.
Initiate Payment
Pass order_slug → returns UPI link, base64 PNG QR code, and per-app UPI intents.
Customer Pays
Display QR or UPI app links; customer completes payment in any UPI app.
Webhook Fires
SMEPay sends an HTTP POST JSON webhook to your callback_url on final status.
Get Status
Always call get status to confirm SUCCESS before marking the order paid.
payment_url returned by create (e.g., https://link.smepay.in/@yourbusiness/<order_slug>). SMEPay's hosted page initiates the UPI payment and renders the QR & app buttons for you. Use only one approach per order, since each starts its own UPI request.Each complete snippet creates an order, initiates the UPI payment, checks status, and parses typed SMEPay errors.
npm install smepay-nodeconst { SMEPay, SMEPayError } = require("smepay-node"); // or: import { SMEPay } from "smepay-node";
const smepay = new SMEPay({
clientId: process.env.SMEPAY_CLIENT_ID,
clientSecret: process.env.SMEPAY_CLIENT_SECRET,
environment: "test", // or "live"
});
async function pay() {
try {
const order = await smepay.payment.create({
amount: "100.00", // string, in rupees
order_id: "ORD-1001", // your unique reference
callback_url: "https://yoursite.com/smepay/callback",
customer_details: { name: "Asha", mobile: "9876543210" },
});
const payment = await smepay.payment.initiate({ slug: order.order_slug });
// show payment.qr_code / payment.payment_link / payment.intents to the customer
const status = await smepay.payment.getStatus({ external_reference_id: "ORD-1001" });
console.log(status.payment_status); // "SUCCESS"
} catch (err) {
if (err instanceof SMEPayError) console.log(err.code, err.message);
}
}Field names below match the API JSON. Node.js, Python, and PHP use them as-is; Go and Java use language idioms (order_slug → OrderSlug / getOrderSlug()).
amount (string): Amount in rupees, e.g. "100.50". Must be > 0 and within your account's min/max order limits.order_id (string): Your own reference, unique per order.callback_url (string): HTTPS URL that receives the payment webhook.customer_details (object): name, email, mobile (email or mobile is required).order_slug: Pass to initiate payment.order_id: SMEPay's internal order ID.ref_id: Your order_id, echoed back.payment_url: Hosted checkout page URL (alternative to initiate).payment_status: CREATED.amount, customer_details, callback_url, message: Echoed / informational.Sent to your callback_url on final statuses (SUCCESS, FAILED, REFUNDED; or TEST_SUCCESS / TEST_FAILED in test mode). Not sent for CREATED, INITIATED, PENDING, or EXPIRED — use get status for those.
{
"ref_id": "ORD-1001",
"status": "SUCCESS",
"transaction_id": "abc1234",
"amount": "100.00",
"created_at": "2026-11-17T14:38:27+05:30",
"processed_at": "2026-11-17T14:38:44+05:30",
"utr": "123456789012"
}ref_id as external_reference_id) before marking paid or shipping goods.2xx quickly, make handlers idempotent, and always use an https:// callback URL.5xx, SMEPay retries after 1 min, 5 min, 25 min, 2 h, and 12 h. 4xx replies are final and not retried.Test-mode accounts receive TEST_SUCCESS, TEST_FAILED, and TEST_PENDING.
Logs in on first call, reuses token, refreshes before expiry, and retries once if rejected.
Every HTTP request waits at most 60 seconds so your workers never hang.
Never sends a duplicate create. Check get status after any network_error or timeout.
Instantiate one client at startup and safely share across threads, goroutines & requests.
Client secrets and tokens are never logged and are stripped from errors & debug prints.
Every failure raises one typed exception/error containing machine-readable code, message, HTTP status, and raw API reply.
Node.js
SMEPayError
→ err.code
Go
*smepay.Error (use errors.As)
→ e.Code
Python
smepay.SMEPayError
→ e.code
PHP
SMEPay\SMEPayException
→ $e->getErrorCode()
Java
in.smepay.SMEPayException (unchecked)
→ e.getCode()
| Error Code | HTTP | Meaning & Resolution |
|---|---|---|
| invalid_config | Client | Missing credentials or bad environment in SDK setup. Fix the client configuration. |
| invalid_client_id, invalid_credentials | 401 | Wrong Client ID or Secret (remember: secret changes when you go live). Re-copy from API Credentials. |
| business_not_found | 401 | Business not found or inactive. Contact SMEPay support. |
| invalid_endpoint | 403 | Environment doesn't match your business's mode. Set test or live to match your API Credentials badge. |
| api_not_enabled | 403 | External API not enabled for your business. Contact SMEPay support. |
| ip_not_whitelisted | 403 | Live server IP not whitelisted. Ask SMEPay support to whitelist your public IP(s). |
| insufficient_wallet_balance, wallet_validation_failed | 403 | Wallet balance too low or wallet inactive. Top up wallet (live needs ₹10 or more plus fees). |
| invalid_request, validation_error | 400 | Missing or invalid parameter. Inspect the error message. |
| amount_below_minimum, amount_exceeds_maximum | 400 | Amount outside your account's configured min/max range. Adjust the amount. |
| duplicate_order_id | 409 | order_id has already been used. Supply a unique order_id. |
| transaction_not_found | 404 | No matching order found for your business. Verify the ID. |
| payment_already_processed | 400 | Initiate called on an order already paid or in progress. Call get status instead. |
| network_error, timeout | — | Could not reach SMEPay or no reply within 60s. Call get status before retrying. |
| invalid_response | — | Unreadable reply from SMEPay. Retry later or contact support if it persists. |
Grab your Test & Live API credentials from the SMEPay dashboard and ship UPI payments in Node.js, Go, Python, PHP, or Java in minutes.