Composable commerce core for products, order items, and payments.
Project description
commercexl
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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file commercexl-0.1.1.tar.gz.
File metadata
- Download URL: commercexl-0.1.1.tar.gz
- Upload date:
- Size: 42.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcfbf1cf38b43700a73603281056ad6416f94f2bd09006e364b0afc0d4ad2d90
|
|
| MD5 |
7c8bfa2ea4817d4c54a4b3a81adb9765
|
|
| BLAKE2b-256 |
4b458e4d5780e7c2286adf0a0488de467235648fbcbb5fe3097c253be75cce27
|
Provenance
The following attestation bundles were made for commercexl-0.1.1.tar.gz:
Publisher:
ci.yml on Artasov/commercexl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commercexl-0.1.1.tar.gz -
Subject digest:
fcfbf1cf38b43700a73603281056ad6416f94f2bd09006e364b0afc0d4ad2d90 - Sigstore transparency entry: 1186220566
- Sigstore integration time:
-
Permalink:
Artasov/commercexl@47ea24ac72a9be440b297baf52edcfa1523a7cd7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Artasov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@47ea24ac72a9be440b297baf52edcfa1523a7cd7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file commercexl-0.1.1-py3-none-any.whl.
File metadata
- Download URL: commercexl-0.1.1-py3-none-any.whl
- Upload date:
- Size: 65.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7878b047e1330373560e8677fe7c57d6bc96c3818b24b45305bac60b4fffab75
|
|
| MD5 |
5584ac7fabc54b7800d4d776d9e67f40
|
|
| BLAKE2b-256 |
4bf5bcb51083cf13a41fb5072378dc27968c7b356d6009fa001386c78d9019bb
|
Provenance
The following attestation bundles were made for commercexl-0.1.1-py3-none-any.whl:
Publisher:
ci.yml on Artasov/commercexl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
commercexl-0.1.1-py3-none-any.whl -
Subject digest:
7878b047e1330373560e8677fe7c57d6bc96c3818b24b45305bac60b4fffab75 - Sigstore transparency entry: 1186220569
- Sigstore integration time:
-
Permalink:
Artasov/commercexl@47ea24ac72a9be440b297baf52edcfa1523a7cd7 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Artasov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@47ea24ac72a9be440b297baf52edcfa1523a7cd7 -
Trigger Event:
push
-
Statement type: