SMEPay Logo
Official Server SDKsZero third-party dependencies • MIT Licensed • Node.js, Go, Python, PHP & Java — 0% Commission UPI!
SMEPay API & SDKs|create → initiate → get status

Accept UPI Payments with Three Simple Calls in Any Backend Language

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.

0 Third-Party Dependencies
Auto Auth & Token Refresh
MIT Licensed • Flat ₹3/Txn
Jump to Quickstart
Thread-Safe Singleton Client•Secrets Never Logged•60s Built-in Request Timeout

Official SMEPay SDKs

Pick your language to install

MIT License
Node.js (Node.js 18+) • 0.1.1
npm install smepay-node
1. payment.create→2. payment.initiate→3. payment.getStatus
Official Server-Side Packages

Choose Your Language & Install in Seconds

Every SDK follows semantic versioning, carries zero third-party dependencies, is MIT licensed, and ships with a runnable full-flow example inside its examples/ folder.

Node.js

Node.js 18+

0.1.1
npm install smepay-node

Go

Go 1.21+

v0.2.0
go get github.com/Typof-Technologies-Pvt-Ltd/smepay-go

Python

Python 3.8+

0.1.0
pip install smepay

PHP

PHP 8.1+

0.1.0
composer require smepay/smepay-php

Java

Java 11+ / Kotlin

0.1.0
implementation("in.smepay:smepay-java:0.1.0")
Before You Start

Credentials, Environments & Going Live

01

Get Your API Credentials

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.

02

Pick the Matching Environment

Match the SDK environment to the badge on API Credentials (a mismatch returns invalid_endpoint):

  • test (default): staging.smepay.in — No real money, no fees. Wallet balance must not be negative.
  • live: extranet.smepay.in — Real payments, fees from SMEPay wallet. Server IP must be whitelisted and wallet balance must be ₹10 or more plus fees.
03

Going Live Checklist

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.

Use SDKs strictly on your backend server. Never put Client Secret in a browser, mobile app, or public repository.
Payment Lifecycle

How It Works: 5-Step Flow

create → initiate → customer pays → webhook → get status
1

Create Order

Pass amount, your unique order_id, callback_url, and customer email/mobile → returns order_slug.

2

Initiate Payment

Pass order_slug → returns UPI link, base64 PNG QR code, and per-app UPI intents.

3

Customer Pays

Display QR or UPI app links; customer completes payment in any UPI app.

4

Webhook Fires

SMEPay sends an HTTP POST JSON webhook to your callback_url on final status.

5

Get Status

Always call get status to confirm SUCCESS before marking the order paid.

Hosted Page Alternative: Skip step 2 and redirect the customer directly to 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.
Interactive Quickstart

Create, Initiate & Verify in Minutes

Each complete snippet creates an order, initiates the UPI payment, checks status, and parses typed SMEPay errors.

Install(Node.js 18+)
npm install smepay-node
Node.js Full Flow Example (create → initiate → get status)
const { 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);
  }
}
API Reference

Core Methods, Parameters & Responses

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()).

Create Orderpayment.create (Node/PHP/Py) • Payment.Create (Go) • payment().create (Java)
Initiate Paymentpayment.initiate (Node/PHP/Py) • Payment.Initiate (Go) • payment().initiate (Java)
Get Statuspayment.getStatus (Node/PHP) • payment.get_status (Py) • Payment.GetStatus (Go) • payment().getStatus (Java)

Parameters (All Required)

  • 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).

Response Fields

  • 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.

Webhooks & Retry Policy

HTTP POST JSON

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"
}
  • Always confirm with get status (passing ref_id as external_reference_id) before marking paid or shipping goods.
  • Reply with HTTP 2xx quickly, make handlers idempotent, and always use an https:// callback URL.
  • On downtime or 5xx, SMEPay retries after 1 min, 5 min, 25 min, 2 h, and 12 h. 4xx replies are final and not retried.

Payment Statuses

Test-mode accounts receive TEST_SUCCESS, TEST_FAILED, and TEST_PENDING.

CREATEDOrder created; payment not started.
INITIATEDQR / UPI link issued to the customer.
PENDINGCustomer is paying; may still become SUCCESS or FAILED, keep checking.
SUCCESSPaid. Treat SUCCESS as confirmed payment.
FAILEDPayment failed (or provider/integration error/dispute); initiate again to retry.
EXPIREDPayment window closed; initiate again to generate a fresh QR/link.
REFUND_PENDINGRefund is currently in progress.
REFUNDEDPayment has been refunded.

Auto Auth & Refresh

Logs in on first call, reuses token, refreshes before expiry, and retries once if rejected.

60s Timeouts

Every HTTP request waits at most 60 seconds so your workers never hang.

No Auto-Retries

Never sends a duplicate create. Check get status after any network_error or timeout.

Thread-Safe

Instantiate one client at startup and safely share across threads, goroutines & requests.

Zero Secret Leaks

Client secrets and tokens are never logged and are stripped from errors & debug prints.

Typed Error Handling & Error Codes

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 CodeHTTPMeaning & Resolution
invalid_configClientMissing credentials or bad environment in SDK setup. Fix the client configuration.
invalid_client_id, invalid_credentials401Wrong Client ID or Secret (remember: secret changes when you go live). Re-copy from API Credentials.
business_not_found401Business not found or inactive. Contact SMEPay support.
invalid_endpoint403Environment doesn't match your business's mode. Set test or live to match your API Credentials badge.
api_not_enabled403External API not enabled for your business. Contact SMEPay support.
ip_not_whitelisted403Live server IP not whitelisted. Ask SMEPay support to whitelist your public IP(s).
insufficient_wallet_balance, wallet_validation_failed403Wallet balance too low or wallet inactive. Top up wallet (live needs ₹10 or more plus fees).
invalid_request, validation_error400Missing or invalid parameter. Inspect the error message.
amount_below_minimum, amount_exceeds_maximum400Amount outside your account's configured min/max range. Adjust the amount.
duplicate_order_id409order_id has already been used. Supply a unique order_id.
transaction_not_found404No matching order found for your business. Verify the ID.
payment_already_processed400Initiate 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.
Developer FAQs

Common Integration Questions

SMEPay provides official, MIT-licensed, zero-dependency server-side SDKs for Node.js (18+), Go (1.21+), Python (3.8+), PHP (8.1+), and Java (11+, including Kotlin support).
Zero Dependencies • MIT Licensed • Flat ₹3/Txn

Start Integrating Zero-Commission UPI Payments Today

Grab your Test & Live API credentials from the SMEPay dashboard and ship UPI payments in Node.js, Go, Python, PHP, or Java in minutes.

Open REST API V2 Docs