Skip to main content

commercexl

License: MPL 2.0

commercexl is a reusable commerce core for:

  • product catalog records
  • checkout orders
  • order items
  • payment systems
  • FastAPI router assembly

It does not create your DB engine, session factory, auth, or project-specific payment callbacks.

Installation

pip install commercexl

For tests and local development:

pip install "commercexl[test]"
pip install "commercexl[dev]"

What the library gives you

  • SQLAlchemy models via CommerceBase
  • explicit module wiring via CommerceModule
  • abstract services for products, order items, and payments
  • built-in balance and handmade payments
  • FastAPI router factory via create_router(...)

Quick start

from decimal import Decimal

from commercexl import (
    BaseConfig,
    CommerceModule,
    DefaultOrderItemService,
    HandMadePaymentService,
    PaymentConfigBuilder,
    ProductOrderConfig,
    ProductOrderConfigBuilder,
)


class ProjectCommerceConfig(BaseConfig):
    PAYMENT_SYSTEMS = {"USD": ("handmade",)}
    MIN_TOP_UP_AMOUNTS = {"USD": Decimal("1")}
    CREDITS_CONVERTERS = {"USD": Decimal("10000")}


commerce = CommerceModule(
    config_class=ProjectCommerceConfig,
    product_orders=ProductOrderConfigBuilder(
        ProductOrderConfig(MyProductService, DefaultOrderItemService),
    ),
    payments=PaymentConfigBuilder(HandMadePaymentService),
)

FastAPI integration

from commercexl import CommerceHTTPConfig, CommerceUserActorDTO, create_router

app.include_router(
    create_router(
        CommerceHTTPConfig(
            get_db_session_dependency=get_db_session,
            get_current_user_dependency=get_current_user,
            get_commerce_module=lambda: commerce,
            build_actor=lambda user: CommerceUserActorDTO(id=user.id),
            get_user_id=lambda user: int(user.id),
            is_staff=lambda user: bool(user.is_staff),
        ),
    ),
    prefix="/api/v1",
)

Alembic

commercexl does not ship migrations. The host project owns migrations.

Add library metadata to your Alembic target_metadata:

from commercexl import CommerceBase
from my_project.db import Base

target_metadata = [
    Base.metadata,
    CommerceBase.metadata,
]

Docs

Testing

pytest

License

Licensed under the Mozilla Public License 2.0. Commercial use is permitted; changes to MPL-covered files remain subject to the MPL. See NOTICE and TRADEMARKS.md.

Release files for commercexl 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 commercexl 0.2.0
File Size Uploaded
commercexl-0.2.0.tar.gz 47.0 kB Details

Built distribution (wheel)

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

Total release size: 116.7 kB

Release files / commercexl-0.2.0.tar.gz

Download URL commercexl-0.2.0.tar.gz
Size 47.0 kB
Tags Source
SHA-256 checksum
How to use checksums
58ea2b35093b6e60bab46247004165c2dd1ca6583c852a0cfadd8d4fa5a54cf5
BLAKE2b-256 checksum
How to use checksums
cb5f2f2db6a4e9d62e806a6849b71cdbd61f1dae1c5891cc7a2625852fffc219
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

Transparency log

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

Download URL commercexl-0.2.0-py3-none-any.whl
Size 69.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b09cbe9f787b705e887f0b68ca9099475869160f065425034772367b33035a4
BLAKE2b-256 checksum
How to use checksums
26f10f5d3cd7123c6d045367fb9d3e589c55ebc35a3c9cc1ac7ea91d2e5c051d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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