How to add payments to a Django or FastAPI app
To add payments to a Django or FastAPI app, install Ruba’s Python SDK, create a checkout session with the product ID in a view or route, redirect the buyer to the returned URL, and confirm the sale with a verified webhook. Ruba is the Merchant of Record, so you need no Stripe account and no company. Ruba pays you to your own bank.
One small server, one payment link
Ruba has a Python SDK, and a plain checkout link works with no SDK at all. Farah in Lahore runs a FastAPI service that checks resumes. A new user clicks “Upgrade”, and she needs to take a card from a buyer in another country. Stripe does not support Pakistan, so she uses Ruba’s Python SDK, which has typed synchronous and asynchronous clients on HTTPX.
- ClickYour route runsCreate a checkout session.
- RedirectSend to RubaTo the returned URL.
- PayBuyer paysOn Ruba’s checkout.
- WebhookYou unlockAfter verifying it.
Install and connect
The SDK needs Python 3.11 or newer. Create an access token in the sandbox dashboard first, and keep it in an environment variable.
pip install ruba-sdkFastAPI: the async client
import os
from fastapi import FastAPI
from fastapi.responses import RedirectResponse
from ruba import RubaAsync
app = FastAPI()
@app.get("/buy")
async def buy():
async with RubaAsync(
access_token=os.environ["RUBA_ACCESS_TOKEN"],
base_url="https://sandbox-api.getruba.com", # remove for production
) as client:
checkout = await client.checkouts.create(
products=[os.environ["RUBA_PRODUCT_ID"]],
)
return RedirectResponse(checkout.url)Django: the sync client
import os
from django.shortcuts import redirect
from ruba import Ruba
def buy(request):
with Ruba(
access_token=os.environ["RUBA_ACCESS_TOKEN"],
base_url="https://sandbox-api.getruba.com", # remove for production
) as client:
checkout = client.checkouts.create(
products=[os.environ["RUBA_PRODUCT_ID"]],
)
return redirect(checkout.url)Create the session when the buyer clicks. The URL is short-lived. The SDK raises RubaError and its subclasses, so wrap the call and show a friendly message.
Confirm with a webhook
Ruba follows Standard Webhooks. Verify the exact raw request body with your endpoint secret using a Standard Webhooks library or the specification, then queue the work and return 2xx fast. A custom implementation must base64-encode the secret.
Full rules: how to handle Ruba webhooks. Ready to sell? See the early-access deal.
Ruba has a Python SDK. A company is not required, and no monthly fee applies. Get approved in early access and your Python app keeps 4% + $0.50 per sale, locked while the account stays open and in good standing. The $100 promise: a fee Ruba never told you about comes back to you, and Ruba pays you $100. Terms apply. See the early-access deal.
Questions people ask
Does Ruba have a Python SDK?
Yes. Ruba has synchronous and asynchronous clients built on HTTPX, for Python 3.11 or newer. Install it with pip install ruba-sdk.
How do I use it in FastAPI?
Use the async client, RubaAsync, inside your async route, create a checkout with the product ID, and redirect the buyer to the returned url. In Django, the synchronous client fits normal views.
How do I point at the sandbox?
Pass base_url="https://sandbox-api.getruba.com" and use an access token created in the sandbox.
How do I verify webhooks in Python?
Ruba follows Standard Webhooks, so use a Standard Webhooks library or implement the specification. Always verify the exact raw request body, and note that a custom implementation must base64-encode the secret.
What errors does the SDK raise?
The package exports RubaError, RubaNetworkError, RubaServerError and RubaClientError for handling failures.
Sources
We check these when we update this guide. Rules can change, so check them yourself before you decide.
- Ruba: Python SDKChecked 26 Nov 2026
- Ruba: checkout sessionsChecked 26 Nov 2026
- Ruba: webhook deliveryChecked 26 Nov 2026
- Ruba: sandboxChecked 26 Nov 2026
- Ruba: pricing and feesChecked 26 Nov 2026