Skip to main content

Razorpay-backed Swarmauri billing provider for payment links, orders, capture, refunds, subscriptions, invoices, transfers, and webhooks.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_billing_razorpay Discord

Swarmauri Billing Razorpay

swarmauri_billing_razorpay provides a Razorpay-backed billing provider for the Swarmauri SDK. It connects Swarmauri billing interfaces to the Razorpay Python SDK for items, payment links, orders, payment capture, refunds, subscriptions, invoices, Route transfers, disputes, and webhook signature verification.

Why Swarmauri Billing Razorpay?

Use swarmauri_billing_razorpay when a Swarmauri application needs Razorpay payment flows while keeping application code behind provider-neutral Swarmauri billing interfaces. The provider lets payment links, orders, subscriptions, invoices, refunds, Route transfers, and dispute checks share the same calling style as other Swarmauri billing providers.

FAQ

Q: Does this package call live Razorpay APIs?

A: Yes. The provider creates a razorpay.Client with key_id and key_secret, then calls SDK resources such as item, payment_link, order, payment, subscription, invoice, refund, and dispute.

Q: Which Razorpay products map to Swarmauri billing flows?

A: Products and prices use Razorpay Items, hosted checkout uses Payment Links, payment intents use Orders, capture/refund use Payments and Refunds APIs, subscription flows use Subscriptions, invoicing uses Invoices, marketplace transfer flows use Route payment transfers, and risk checks use webhook signatures and disputes.

Q: What credentials are required?

A: Pass Razorpay API credentials as key_id and key_secret. Use test mode keys for development and load production keys from secure deployment secrets.

Features

  • Razorpay-backed provider class registered as RazorpayBillingProvider.
  • Item-based product and price creation.
  • Payment Link checkout sessions with customer email support.
  • Order creation for online payment initialization.
  • Payment capture that fetches the authorized payment amount before calling Razorpay capture.
  • Refund creation and refund lookup through Razorpay refund APIs.
  • Subscription create/cancel support.
  • Invoice create, issue, and cancel operations.
  • Route transfer support for split-payment workflows.
  • Webhook signature verification with X-Razorpay-Signature and HMAC-SHA256.
  • Dispute listing through Razorpay disputes.
  • Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.

Installation

Install with uv:

uv add swarmauri_billing_razorpay

Install with pip:

pip install swarmauri_billing_razorpay

Usage

Create a product, price, and Razorpay payment link:

from swarmauri_billing_razorpay import RazorpayBillingProvider
from swarmauri_base.billing import CheckoutRequest, PriceSpec, ProductSpec

provider = RazorpayBillingProvider(
    api_key="razorpay",
    key_id="rzp_test_xxxxx",
    key_secret="test_secret",
)

product = provider.create_product(
    ProductSpec(name="Analytics Plan", description="Advanced dashboards"),
    idempotency_key="razorpay-prod-001",
)

price = provider.create_price(
    product,
    PriceSpec(currency="INR", unit_amount_minor=49900, nickname="Quarterly"),
    idempotency_key="razorpay-price-001",
)

checkout = provider.create_checkout(
    price,
    CheckoutRequest(
        quantity=1,
        success_url="https://merchant.example/razorpay/callback",
        customer_email="buyer@example.com",
        idempotency_key="razorpay-checkout-001",
    ),
)

print(product.id, price.id, checkout.url)

Create an order-backed payment intent:

from swarmauri_billing_razorpay import RazorpayBillingProvider
from swarmauri_base.billing import PaymentIntentRequest

provider = RazorpayBillingProvider(
    api_key="razorpay",
    key_id="rzp_test_xxxxx",
    key_secret="test_secret",
)

payment = provider.create_payment_intent(
    PaymentIntentRequest(
        amount_minor=49900,
        currency="INR",
        idempotency_key="receipt-1001",
    )
)

print(payment.id, payment.status)

Create a partial refund:

from swarmauri_billing_razorpay import RazorpayBillingProvider
from swarmauri_base.billing import PaymentRef, RefundRequest

provider = RazorpayBillingProvider(
    api_key="razorpay",
    key_id="rzp_test_xxxxx",
    key_secret="test_secret",
)

refund = provider.create_refund(
    PaymentRef(id="pay_123", provider="razorpay"),
    RefundRequest(amount_minor=1000, reason="Customer request"),
    idempotency_key="refund-1001",
)

print(refund["id"], refund["status"])

Important Scope Notes

This package uses live Razorpay SDK calls. Runtime behavior depends on Razorpay account settings, enabled products, API credentials, dashboard capture settings, and the status of each payment, order, invoice, subscription, or Route transfer.

Entry Point

The package exposes a Swarmauri billing provider entry point:

[project.entry-points.'swarmauri.billing_providers']
RazorpayBillingProvider = "swarmauri_billing_razorpay.provider:RazorpayBillingProvider"

Related Packages

Billing provider packages:

Foundational packages:

  • swarmauri_core defines billing capabilities and interfaces.
  • swarmauri_base provides billing specs, refs, mixins, and BillingProviderBase.
  • swarmauri provides namespace imports and plugin discovery.

Documentation

License

Apache-2.0

Contributing

When expanding Razorpay coverage, keep each Swarmauri billing method aligned with the corresponding Razorpay SDK resource, document required credentials and account configuration, and add tests for each changed runtime path.

Project details


Download files

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

Source Distribution

swarmauri_billing_razorpay-0.11.0.dev1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file swarmauri_billing_razorpay-0.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_billing_razorpay-0.11.0.dev1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_billing_razorpay-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 388be0ace90866f2fe43477c237f8d199404109c8bc29fc5d40d53d9fae5d203
MD5 2f8050dba59db1c8830e818578641a5b
BLAKE2b-256 e13d95fccf88bc2fa566148b7101664ac03f7850dd0a6973f847fee085ad78c3

See more details on using hashes here.

File details

Details for the file swarmauri_billing_razorpay-0.11.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_billing_razorpay-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_billing_razorpay-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 20e429bcc0f21e406ff2a2b3cc2ef82dbbba57c561026cb29805d0cbb85b8ca2
MD5 b3019355757652d93b2f00bd532ebc50
BLAKE2b-256 dc829ced2cff3e8cd61cdd1a2edb8dc32b3e7332ad8491335afeb8abf0446fb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page