Skip to main content

Stripe-backed Swarmauri billing provider for checkout, payments, subscriptions, invoices, refunds, disputes, Connect, and webhooks.

Project description

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.

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_stripe-0.11.0.dev2.tar.gz (10.7 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_stripe-0.11.0.dev2.tar.gz.

File metadata

  • Download URL: swarmauri_billing_stripe-0.11.0.dev2.tar.gz
  • Upload date:
  • Size: 10.7 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_stripe-0.11.0.dev2.tar.gz
Algorithm Hash digest
SHA256 7ef59eecdca8b1c836253f5721344f68fc3724be04f1974d248d6e89102cf2de
MD5 767bad3a266dcd60f1009a01eed44c72
BLAKE2b-256 a0f7275414fe2fcb2a5e6259cf1640ea7ad44df55ba728d489120da90c5e64a4

See more details on using hashes here.

File details

Details for the file swarmauri_billing_stripe-0.11.0.dev2-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_billing_stripe-0.11.0.dev2-py3-none-any.whl
  • Upload date:
  • Size: 11.6 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_stripe-0.11.0.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 1d6aba08c1e2d2c3094d94a78a6024eb44c6f2b9830a7027a576fb9110429a77
MD5 8f0710808dcbcf340712a482db7db803
BLAKE2b-256 1b3c909e41966ce6987e86a2906692694234709a99f0db4d473e550156860a7c

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