Skip to main content

FamGateway Python SDK

PyPI version Python versions License: MIT Govt MSME Registered

The official Python client library for FamGateway — 100% Free, Zero-Fee Peer-to-Peer UPI Payment Gateway for Indian Developers and Businesses.


Features

  • Instant Dynamic UPI QR Codes — Get direct QR image URLs (qr_url) to send directly in Telegram Bots or apps.
  • Deep UPI Intent Linksupi://pay?... URLs for 1-tap payments in PhonePe, Google Pay, and Paytm.
  • Telegram Bot Friendly — Send QR codes directly to users inside Telegram chats without external browser redirects.
  • Zero Transaction Fees — 100% peer-to-peer settlement directly into your FamPay / UPI ID.
  • Instant Webhooks & Polling — Automated payment reconciliation via webhooks and status API.

Installation

pip install famgateway

Quickstart (3 Lines of Code)

from famgateway import FamGateway

# 1. Initialize client with your API Key
fg = FamGateway(api_key="your_famgateway_api_key")

# 2. Create a dynamic UPI payment order
order = fg.create_order(
    amount=100.0,
    customer_name="Aryan Gupta",
    customer_phone="9876543210"
)

print("Order ID:", order.order_id)
print("Payable Amount: Rs.", order.payable_amount)
print("QR Code Image URL:", order.qr_url)
print("Deep UPI Intent:", order.upi_intent)
print("Hosted Checkout URL:", order.checkout_url)

# 3. Check order payment status
status = fg.get_status(order.order_id)
if status.is_paid:
    print(f"Payment Captured! UTR: {status.utr}")

Telegram Bot Integration Example

Use famgateway to collect payments directly inside Telegram without any website redirect:

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=['buy'])
def handle_buy(message):
    # 1. Create UPI payment order for Rs 50
    order = fg.create_order(
        amount=50.0,
        customer_name=f"{message.from_user.first_name} ({message.from_user.id})"
    )

    # 2. Create inline pay button
    markup = InlineKeyboardMarkup()
    markup.row(
        InlineKeyboardButton("Pay via UPI App", url=order.upi_intent),
        InlineKeyboardButton("Web Checkout", url=order.checkout_url)
    )
    markup.row(
        InlineKeyboardButton("Check Status", callback_data=f"check_{order.order_id}")
    )

    # 3. Send QR image directly in chat
    bot.send_photo(
        chat_id=message.chat.id,
        photo=order.qr_url,
        caption=f"Scan to Pay Rs {order.payable_amount}\n\nOrder ID: `{order.order_id}`",
        reply_markup=markup
    )

@bot.callback_query_handler(func=lambda call: call.data.startswith("check_"))
def handle_status(call):
    order_id = call.data.split("_")[1]
    status = fg.get_status(order_id)

    if status.is_paid:
        bot.answer_callback_query(call.id, "Payment Verified!", show_alert=True)
        bot.send_message(call.message.chat.id, f"Payment received! Payer: {status.sender_name}, UTR: `{status.utr}`")
    else:
        bot.answer_callback_query(call.id, "Payment pending. Please complete the UPI payment.", show_alert=True)

bot.infinity_polling()

API Reference

FamGateway(api_key, base_url="https://famgateway.in", timeout=15)

Initializes the FamGateway client.

fg.create_order(amount, customer_name=None, customer_email=None, customer_phone=None, redirect_url=None, webhook_url=None)

Creates a new payment order and generates dynamic UPI QR details.

Returns OrderResponse object:

  • order.order_id (str): Unique order reference (e.g. fg_J2KVI0O8)
  • order.amount (float): Base order amount
  • order.payable_amount (float): Reconciled payable amount
  • order.qr_url (str): Direct URL of the QR code image
  • order.upi_intent (str): Deep link (upi://pay?...) for opening UPI apps
  • order.checkout_url (str): Hosted web checkout URL
  • order.upi_id (str): Receiver UPI ID
  • order.created_at_ist (str): Order generation timestamp (IST)
  • order.expires_at_ist (str): Order expiry timestamp (IST)

fg.get_status(order_id)

Fast public polling check for an order.

fg.verify_order(order_id)

Full server-side payment verification with authenticated merchant credentials and instant IMAP sync.

Returns OrderStatus object:

  • status.status (str): 'success', 'pending', or 'expired'
  • status.is_paid (bool): True if payment captured successfully
  • status.is_pending (bool): True if awaiting customer payment
  • status.is_expired (bool): True if order timed out after 5 minutes
  • status.utr (str|None): Bank 12-digit UTR / RRN reference
  • status.transaction_id (str|None): FamPay transaction reference ID
  • status.sender_name (str|None): Name of payer extracted from UPI
  • status.payment_time (str|None): Payment confirmation timestamp

fg.verify_webhook(payload, signature)

Verifies the cryptographic HMAC-SHA256 signature (X-FamGateway-Signature) of incoming webhooks.

fg.simulate_payment(order_id)

Simulates a successful payment for sandbox / local development without real funds.


About & Legal

FamGateway is a developer-focused payment orchestration platform operated by ARYANISPE.

License

MIT License. Free for commercial and private use.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

famgateway-1.0.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

famgateway-1.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file famgateway-1.0.2.tar.gz.

File metadata

  • Download URL: famgateway-1.0.2.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for famgateway-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bffe11786a30586800292c27f34daf7a1fa4b60add9d8807edce066702b41218
MD5 ee90be1435e71d270cc299b0ab893106
BLAKE2b-256 30c5e540fd507e7303db543ad0dd0ee15377d5170144e1dc5624f6b423be83a5

See more details on using hashes here.

File details

Details for the file famgateway-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: famgateway-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for famgateway-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 95c6184a928f4fc0b9ec7085db8cb7ef7bfc958f4d20099b44f9315c0eb51bc9
MD5 796d767b63108eabf83c95da5913d944
BLAKE2b-256 11dc954bc67c6c71c0dd690cc4be2315e6f4184c772d67ea8cf48776787e2d7a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page