Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

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

Swarmauri Billing Stripe

swarmauri_billing_stripe provides a Stripe-backed billing provider for the Swarmauri SDK. It connects Swarmauri billing interfaces to the official Stripe Python SDK for products, prices, Checkout Sessions, Payment Intents, captures, cancellations, refunds, subscriptions, invoices, Stripe Connect destination charges, disputes, and webhook signature verification.

Why Swarmauri Billing Stripe?

Use swarmauri_billing_stripe when a Swarmauri application needs production Stripe billing workflows while keeping application code behind provider-neutral billing interfaces. The provider maps Stripe Billing, Checkout, Payment Intents, Refunds, Invoicing, Subscriptions, Connect, and Disputes into Swarmauri refs and specs.

FAQ

Q: Does this package call live Stripe APIs?

A: Yes. The provider configures the official stripe Python SDK with api_key and calls Stripe resources such as Product, Price, checkout.Session, PaymentIntent, Refund, Subscription, Invoice, and Dispute.

Q: Which Stripe workflows are supported?

A: It supports product and price creation, hosted checkout, payment intent creation, manual capture, payment intent cancellation, refund create/retrieve, subscription create/cancel, invoice create/finalize/void/mark-uncollectible, Connect destination charges with application fees, webhook signature validation, and dispute listing.

Q: What credential is required?

A: Pass a Stripe secret key as api_key, such as a test key beginning with sk_test_. Production keys should be provided through secure deployment secrets.

Features

  • Stripe-backed provider class registered as StripeBillingProvider.
  • Product and price creation with metadata support.
  • Hosted Checkout Session creation for one-time payments.
  • Payment Intent creation with automatic or manual capture.
  • Payment capture and cancellation through Stripe Payment Intents.
  • Refund creation and lookup through Stripe Refunds.
  • Subscription creation and cancellation with Stripe prices.
  • Invoice item creation plus invoice lifecycle operations.
  • Stripe Connect destination-charge support with application fees.
  • Webhook signature verification through stripe.Webhook.construct_event.
  • Dispute listing for operational review workflows.
  • Python 3.10, 3.11, 3.12, 3.13, and 3.14 support.

Installation

Install with uv:

uv add swarmauri_billing_stripe

Install with pip:

pip install swarmauri_billing_stripe

Usage

Create a product, price, and Stripe Checkout Session:

from swarmauri_billing_stripe import StripeBillingProvider
from swarmauri_base.billing import CheckoutRequest, PriceSpec, ProductSpec

provider = StripeBillingProvider(api_key="sk_test_123")

product = provider.create_product(
    ProductSpec(name="Starter", description="Starter subscription"),
    idempotency_key="stripe-prod-001",
)
price = provider.create_price(
    product,
    PriceSpec(currency="USD", unit_amount_minor=1000, nickname="Starter monthly"),
    idempotency_key="stripe-price-001",
)
checkout = provider.create_checkout(
    price,
    CheckoutRequest(
        quantity=1,
        success_url="https://example.com/success",
        cancel_url="https://example.com/cancel",
        customer_email="buyer@example.com",
        idempotency_key="stripe-checkout-001",
    ),
)

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

Create and capture a manual Payment Intent:

from swarmauri_billing_stripe import StripeBillingProvider
from swarmauri_base.billing import PaymentIntentRequest

provider = StripeBillingProvider(api_key="sk_test_123")

payment = provider.create_payment_intent(
    PaymentIntentRequest(
        amount_minor=2500,
        currency="USD",
        payment_method_id="pm_card_visa",
        confirm=True,
        capture=False,
        idempotency_key="stripe-payment-001",
    )
)
captured = provider.capture_payment(payment.id, idempotency_key="stripe-capture-001")

print(payment.status, captured.status)

Verify a Stripe webhook signature:

from swarmauri_billing_stripe import StripeBillingProvider

provider = StripeBillingProvider(api_key="sk_test_123")

valid = provider.verify_webhook_signature(
    raw_body=b'{"id":"evt_test","object":"event"}',
    headers={"Stripe-Signature": "t=...,v1=..."},
    secret="whsec_...",
)

print(valid)

Important Scope Notes

This package uses live Stripe SDK calls. Runtime behavior depends on Stripe account settings, API version, enabled payment methods, test or live mode, Checkout configuration, Connect account setup, and webhook endpoint secrets.

Entry Point

The package exposes a Swarmauri billing provider entry point:

[project.entry-points.'swarmauri.billing_providers']
StripeBillingProvider = "swarmauri_billing_stripe.provider:StripeBillingProvider"

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 Stripe coverage, keep each Swarmauri billing method aligned with the official Stripe Python SDK, document required Stripe account configuration, and add tests for each changed runtime path.

Release files for swarmauri_billing_stripe 0.11.0.dev2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_billing_stripe 0.11.0.dev2
File Size Uploaded
swarmauri_billing_stripe-0.11.0.dev2.tar.gz 10.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_billing_stripe 0.11.0.dev2
File Interpreter ABI Platform
swarmauri_billing_stripe-0.11.0.dev2-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / swarmauri_billing_stripe-0.11.0.dev2.tar.gz

Download URL swarmauri_billing_stripe-0.11.0.dev2.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7ef59eecdca8b1c836253f5721344f68fc3724be04f1974d248d6e89102cf2de
BLAKE2b-256 checksum
How to use checksums
a0f7275414fe2fcb2a5e6259cf1640ea7ad44df55ba728d489120da90c5e64a4
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / swarmauri_billing_stripe-0.11.0.dev2-py3-none-any.whl

Download URL swarmauri_billing_stripe-0.11.0.dev2-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1d6aba08c1e2d2c3094d94a78a6024eb44c6f2b9830a7027a576fb9110429a77
BLAKE2b-256 checksum
How to use checksums
1b3c909e41966ce6987e86a2906692694234709a99f0db4d473e550156860a7c
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.11.0.dev2 This release

2 release 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