Guide #51 Official Release Announcement & Python SDK Documentation

FamGateway Releases Official Python SDK on PyPI: Zero-Fee UPI Payment Gateway Integration for Python Developers (2026)

By Aryan Gupta September 2, 2026 5 min read

We are excited to announce the official release of the FamGateway Python SDK on the Python Package Index (PyPI): famgateway. Starting today, Indian developers, indie hackers, Telegram bot creators, and SaaS founders can integrate seamless, zero-fee Peer-to-Peer UPI payments into any Python application with just three lines of clean, type-annotated Python code.

Open-Source Python Release Overview:

1. Why Indian Python Developers Needed a Native UPI SDK

Python powers a massive portion of India's developer ecosystem: from FastAPI and Flask backends to automated Telegram bots, Discord servers, AI agent interfaces, and micro-SaaS applications. However, accepting UPI payments in Python backends has historically required navigating two broken extremes:

  1. Legacy Aggregators (Razorpay, Cashfree, PayU): Require business entity registration (Pvt Ltd / LLP), active GSTIN credentials, lengthy merchant onboarding approval delays, 2%–3% commission deduction on every sale, and 48-hour custodial settlement cycles.
  2. Unmaintained Third-Party Scrapers: Brittle, unauthorized scraping scripts that break whenever web interfaces update, risking API credential exposure and account blocks.

FamGateway solves this problem permanently. By combining an enterprise API orchestration layer with automated IMAP bank verification and non-custodial P2P UPI routing, FamGateway provides a robust, developer-first bridge that brings instant UPI automation to standard Python environments with zero platform fees.


2. Key Architecture and Features of the `famgateway` Library

The famgateway SDK was designed from the ground up to follow modern Python best practices, type safety, and minimalistic dependency footprints.

Instant Dynamic QR Codes

Direct order.qr_url image links ready to be embedded in web HTML, sent to mobile clients, or delivered via bot.send_photo() in Telegram/Discord.

Deep Intent URLs

Automated order.upi_intent links (upi://pay?...) that launch PhonePe, Google Pay, and Paytm with pre-filled amount and reference IDs in 1 tap.

Strict Typed Models

Structured dataclass responses (OrderResponse, OrderStatus) with IDE auto-completion and automatic type validation.

Clean Exception Hierarchy

Granular exception handling with AuthenticationError, APIError, OrderNotFoundError, and NetworkError.


3. Installation and Quickstart Tutorial

Step 1: Install from PyPI

Open your terminal or command prompt and run:

pip install famgateway

Step 2: Generate an Order in 3 Lines of Python

Initialize the FamGateway client with your API key (obtained from your FamGateway Dashboard) and create an order:

from famgateway import FamGateway

# Initialize client
fg = FamGateway(api_key="fam_your_api_key_here")

# Create a dynamic UPI order for Rs. 250.00
# Step 2: Create a dynamic UPI payment order (Only amount is required!)
order = fg.create_order(amount=250.0)

# Optional: pass customer metadata if needed for your records:
# order = fg.create_order(amount=250.0, customer_name="Aryan Gupta", customer_phone="9876543210")

print(f"Order Created: {order.order_id}")
print(f"Payable Amount: Rs. {order.payable_amount}")
print(f"Direct QR Image: {order.qr_url}")
print(f"Hosted Checkout URL: {order.checkout_url}")

Step 3: Check Payment Status

Verify whether the customer has completed the payment:

status = fg.get_status(order.order_id)

if status.is_paid:
    print("Payment Captured Successfully!")
    print(f"Bank UTR: {status.utr}")
    print(f"FamPay Txn ID: {status.transaction_id}")
elif status.is_pending:
    print("Awaiting customer payment...")
elif status.is_expired:
    print("Order has expired.")

4. Polling Best Practices & Rate Limits (3–5s Interval)

In high-throughput fintech pipelines, polling correctly is essential to maintain low latency and avoid spamming upstream bank verification servers:

  • Recommended Polling Interval: Poll fg.get_status(order_id) every 3 to 5 seconds (using time.sleep(3) in Python).
  • Why Not 100ms or 1s? When a customer scans a UPI QR code and completes payment on PhonePe, Google Pay, or Paytm, FamPay's bank notification emails take 2 to 4 seconds to sync via IMAP. Polling more frequently than 3 seconds wastes network bandwidth and triggers our automated 5-second merchant rate-limiting lock.
  • Order Expiration: Orders expire in 5 minutes. When status.is_expired evaluates to True, terminate the polling loop.
  • Zero-Polling Alternative (Webhooks): For high-traffic web applications, bypass polling entirely by using our instant HMAC-SHA256 webhooks. Unlike platforms like ZapUPI that lack cryptographic webhook verification, FamGateway signs every event securely; see our FamGateway vs ZapUPI Comparison.
import time

order = fg.create_order(amount=100.0)

# Recommended 3-second polling loop (up to 5 minutes / 100 attempts)
for _ in range(100):
    time.sleep(3)  # ✅ Respect the 3-5 second polling interval
    status = fg.get_status(order.order_id)
    
    if status.is_paid:
        print(f"Payment Captured! UTR: {status.utr}, Payer: {status.sender_name}")
        break
    elif status.is_expired:
        print("Order expired without payment.")
        break

5. Framework Integration Examples

A. FastAPI / Flask Webhook Verification

FamGateway dispatches real-time webhooks with an X-FamGateway-Signature header generated via HMAC-SHA256. Here is how you can verify webhook authenticity in FastAPI:

import hmac
import hashlib
from fastapi import FastAPI, Request, HTTPException, Header

app = FastAPI()
WEBHOOK_SECRET = "your_famgateway_api_secret"

@app.post("/api/famgateway-webhook")
async def handle_famgateway_webhook(request: Request, x_famgateway_signature: str = Header(None)):
    raw_body = await request.body()
    
    # Calculate HMAC-SHA256 signature
    computed_signature = hmac.new(
        WEBHOOK_SECRET.encode("utf-8"),
        raw_body,
        hashlib.sha256
    ).hexdigest()
    
    if not hmac.compare_digest(computed_signature, x_famgateway_signature or ""):
        raise HTTPException(status_code=401, detail="Invalid webhook signature")
    
    data = await request.json()
    if data.get("status") == "success":
        order_id = data.get("order_id")
        amount = data.get("amount")
        utr = data.get("utr")
        print(f"Webhook Verified: Order {order_id} paid Rs {amount} with UTR {utr}")
        # Activate digital access or credit database balance here
    
    return {"status": "ok"}

B. Telegram Bot In-Chat Payments (`pyTelegramBotAPI`)

Accept payments directly inside Telegram chats without external website drops:

import telebot
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from famgateway import FamGateway

bot = telebot.TeleBot("YOUR_TELEGRAM_BOT_TOKEN")
fg = FamGateway(api_key="YOUR_FAMGATEWAY_API_KEY")

@bot.message_handler(commands=['deposit'])
def handle_deposit(message):
    order = fg.create_order(
        amount=100.0,
        customer_name=f"{message.from_user.first_name} ({message.from_user.id})"
    )

    markup = InlineKeyboardMarkup()
    markup.row(
        InlineKeyboardButton("Pay Online / UPI Apps", url=order.checkout_url),
        InlineKeyboardButton("Verify Payment", callback_data=f"chk:{order.order_id}:100.0")
    )

    caption = (
        f"Payment Details:\n\n"
        f"Amount to Pay: Rs {order.payable_amount}\n"
        f"Order ID: `{order.order_id}`\n\n"
        f"Scan the QR code with PhonePe, Google Pay, or Paytm.\n"
        f"After paying, tap 'Verify Payment' to credit your account."
    )

    bot.send_photo(
        chat_id=message.chat.id,
        photo=order.qr_url,
        caption=caption,
        parse_mode="Markdown",
        reply_markup=markup
    )

@bot.callback_query_handler(func=lambda call: call.data.startswith("chk:"))
def handle_verify(call):
    _, order_id, amount_str = call.data.split(":")
    status = fg.get_status(order_id)

    if status.is_paid:
        bot.answer_callback_query(call.id, "Payment Verified! Wallet Credited.", show_alert=True)
        bot.send_message(call.message.chat.id, f"Payment Confirmed! Bank UTR: `{status.utr}`")
    else:
        bot.answer_callback_query(call.id, "Payment pending. Please complete UPI transfer.", show_alert=True)

bot.infinity_polling()

5. Architectural Comparison: FamGateway vs Traditional Aggregators

Feature FamGateway Python SDK Razorpay / Cashfree
Transaction Commission 0.0% (Zero Fees Forever) 2.0% - 2.5% + 18% GST
Settlement Window 0 Seconds (Direct to Bank) T+2 Business Days (Escrow Hold)
Business KYC / GST Requirement None (Personal UPI Supported) Mandatory GST & Incorporation Docs
In-Chat Telegram Bot QR Supported (`qr_url` Image) Not Supported (Forced Web Redirect)
Package Overhead Under 25 KB (Zero Bloat) Over 1.5 MB with heavy dependencies
Open Source License MIT Open Source Proprietary / Vendor Locked

6. Legal Compliance and Enterprise Trust

FamGateway is developed and maintained by ARYANISPE, an entity officially registered with the Government of India Ministry of Micro, Small & Medium Enterprises under UDYAM Registration: UDYAM-BR-28-0050000. All transactions processed via FamGateway are direct peer-to-peer bank transfers settled over the National Payments Corporation of India (NPCI) Unified Payments Interface network.

For more information, API documentation, or community developer support, explore the following official resources:

Topic Cluster & Series

Related Developer Guides & Resources

View All 70+ Guides →
SMM Panels

How to Integrate FamPay UPI Payment Gateway in SMM Panels (Rental, Perfect Panel & SmartPanel)

Step-by-step developer guide to integrating FamPay UPI payment gateway in SMM panels (Rental, Perfect Panel...

Read Guide →
WooCommerce

How to Accept UPI Payments on WooCommerce Without GST or Current Account (2026 Guide)

Complete tutorial on accepting automated UPI payments on WooCommerce without GST or a commercial current ac...

Read Guide →
Telegram Bot

How to Accept Automated UPI Payments in Telegram Bots (Python & Node.js Guide)

Step-by-step tutorial on accepting automated UPI payments in Telegram shop bots using Python (FastAPI) and ...

Read Guide →

Back to Homepage →

About the Platform

FamGateway is an official unit of ARYANISPE, founded by Aryan Gupta (Aryanispe) and officially registered under the Ministry of Micro, Small and Medium Enterprises (MSME), Government of India (Reg: UDYAM-BR-28-0050000).

Legal Disclaimer: FamGateway is an independent developer automation tool operated by ARYANISPE. FamGateway is not affiliated with, authorized, maintained, sponsored, or endorsed by Tri O Tech Solutions Private Limited, FamApp, or FamPay. All brand names, logos, and trademarks belong to their respective owners.

All Systems Operational