Skip to main content

stapel-orders

CI coverage pypi downloads python license llms.txt

Cart, checkout and orders over opaque purchasables. A host registers what can be bought (purchasable_type -> a keyed-batch resolver Function answering title, price, currency, availability); the cart snapshots each line when it is added, so reading a cart never calls the product owner. Checkout re-prices every line, refuses with the refreshed cart when anything drifted, and places an order idempotently on a client key, emptying the cart and announcing orders.order.placed with its lines. Orders follow a staff-driven lifecycle with buyer cancel and a full staff refund; payment is a provider seam (none, mock) whose outcome arrives as the orders.payment.completed fact (or the payment module's payment.completed). Checkout seams let commerce companions plug in without forking: ADJUSTERS price the cart (discounts, shipping, tax; a quote endpoint shows them before submit, order adjustments are snapshotted) and CHECKOUT_HOOKS reserve before the order is written, commit once it is placed and release on failure or cancel.

Part of the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.

Install

pip install stapel-orders

At a glance

Fact Value
Version 0.2.0
Python >=3.11 (3.11, 3.12, 3.13, 3.14)
HTTP operations 12
Config axes 2
Usage surface 24
Extension points 9
Error codes 63
Documented flows 4
Fleet dependencies stapel-auth (optional) · stapel-core · stapel-currencies (optional) · stapel-delivery (optional) · stapel-inventory (optional) · stapel-listings (optional) · stapel-promotions (optional)

Documentation

OpenAPI · capabilities.json · llms.txt (for agents)

What this is

Cart, checkout and orders for a Stapel shop — over opaque purchasables. The module ships knowing nothing about what is sold: a host registers each purchasable type with a comm Function that resolves a keyed batch of keys to title, price, currency and availability. Orders never imports a product model, so a listing, a spare part from a custom app, or anything else is bought through one cart.

Quick start

INSTALLED_APPS = [
    # ...
    "stapel_orders",
]

STAPEL_ORDERS = {
    "PURCHASABLE_TYPES": {
        "listing": {"resolve": "listings.purchasables"},  # stapel-shop preset default
    },
}

# urls.py
path("orders/api/", include("stapel_orders.urls"))   # -> /orders/api/v1/...

# settings.py — the abandoned-cart purge and the checkout-hook sweep (Celery optional)
from stapel_orders.beat import get_orders_beat_schedule
CELERY_BEAT_SCHEDULE = {**get_orders_beat_schedule()}

A custom product type is one resolver and one registration:

from stapel_core.comm import function

@function("parts.purchasables")
def purchasables(payload):
    parts = Part.objects.filter(pk__in=payload["keys"])
    return {str(p.pk): {"title": p.name, "price": str(p.price), "currency": "USD",
                        "available": p.stock > 0, "max_quantity": p.stock,
                        "seller_id": None, "image": None, "url": f"/parts/{p.pk}"}
            for p in parts}

# AppConfig.ready()
from stapel_orders.registry import register_purchasable_type
register_purchasable_type("part", {"resolve": "parts.purchasables"})

Concepts

  • Purchasable — an opaque pair (purchasable_type, purchasable_key). The resolver answers on add and at checkout only; a cart line is a snapshot, so GET cart/ makes zero comm calls.
  • Cart — one per user. A stapel-auth guest is a user too, and user.merged folds the guest's cart into the account on sign-in (same item summed, capped at MAX_LINE_QUANTITY). One currency per cart; a line in another currency is refused, never converted.
  • Checkout — one idempotent call (idempotency_key). Every line is re-priced; a changed price, a vanished item or short stock refreshes the cart and refuses with it in params.cart, so the shopper is never charged a number they did not see. Guests are asked to sign in unless CHECKOUT_REQUIRES_ACCOUNT is off.
  • Checkout seams — commerce companions plug in by settings, never by import. ADJUSTERS (discounts, shipping, tax) price the cart; POST cart/quote/ shows their lines and errors with the client's opaque context (promo codes, delivery choice), and checkout re-quotes, refuses on any error and snapshots the adjustments: total = max(0, subtotal + adjustments). CHECKOUT_HOOKS (stock, redemptions) reserve before the order is written, commit once it is placed, release on failure or cancel; a crashed checkout is released by the hook sweep. Both registries ship empty, and a silent companion refuses the checkout instead of being skipped.
  • Order — new → confirmed → shipped → completed, cancel from new by the buyer (OWNER_CANCELLABLE_STATUSES), staff for the rest, needs_review when a payment does not match. History is anchor-paginated.
  • Money — Decimal inside, strings on the wire. Line and cart limits are a proof that a total cannot overflow its column (tests/test_money_bounds.py, system check E005).
  • Payment — a provider seam: none (staff confirm by hand) or mock (prototype posture only). The outcome always arrives as payment.completed, the one path that marks an order paid.
  • GDPR — erasure deletes carts and pseudonymizes the person on orders; amounts stay.

License

MIT — see LICENSE.


This page is assembled by stapel-readme from docs/readme.md plus the contract artifacts in docs/. Edit the prose in docs/readme.md; the badges, facts and links above and below it are generated — do not hand-edit README.md.

Metadata

Release files for stapel-orders 0.2.0

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

Source distribution (sdist)

Source distribution for stapel-orders 0.2.0
File Size Uploaded Provenance Actions
stapel_orders-0.2.0.tar.gz 118.2 kB With provenance Details for stapel_orders-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stapel-orders 0.2.0
File Interpreter ABI Platform Actions
stapel_orders-0.2.0-py3-none-any.whl Python 3 none any Details for stapel_orders-0.2.0-py3-none-any.whl

Total release size: 226.7 kB

Release files / stapel_orders-0.2.0.tar.gz

Download URL stapel_orders-0.2.0.tar.gz
Size 118.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7241ebd1b279476ad414297af226223d449940231af44bc242eefb369b5dd592
BLAKE2b-256 checksum
How to use checksums
9084f9e51a3af6773988f5aac3894a9d454d480b4c320f9388aa75f0baafffa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / stapel_orders-0.2.0-py3-none-any.whl

Download URL stapel_orders-0.2.0-py3-none-any.whl
Size 108.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd8bd3307201f4bb203c50b09f3b6566e433068b91cddc40d840550cfdacf561
BLAKE2b-256 checksum
How to use checksums
fe79840e0069ccd51f247f27763bf37c44b690adf8af39f3b527f07b8e112c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for stapel-orders 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for stapel_orders-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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