Skip to main content

Ferrox-Py-Commerce

1. Overview (What does this do?)

The ferrox-py-commerce package is a standardized extension for the Ferrox ecosystem dedicated to handling billing, subscriptions, and standardized payment webhooks. It abstracts away the complexity of dealing directly with external payment providers (like Stripe or PayPal) and guarantees robust, mathematically idempotent transaction handling.

2. Philosophy (Why does it exist?)

Handling real money in software is notoriously difficult. E-commerce integrations frequently suffer from race conditions (double charging a user), out-of-order webhook events (an invoice is marked paid before the charge is completed), and severe vendor lock-in. This module exists to decouple your core business logic from the specific syntax and behavior of third-party payment gateways, enforcing strict state machines that make duplicate charges nearly impossible.

3. Target Audience (Who is it for?)

This module is intended for backend engineers building SaaS billing systems, subscription platforms, or general e-commerce architectures where financial data integrity and vendor-agnostic infrastructure are critical.

4. Architecture (How does it work?)

The Commerce module leverages three main architectural concepts:

  • Gateways: Abstract adapters over official provider SDKs (e.g., StripeGateway), allowing the core application to initiate payments using uniform interfaces.
  • Transaction State Machine: A strict, Redis-backed state machine that enforces mathematical idempotency for incoming webhook events (e.g., ensuring a transaction can only move from PENDING to COMPLETED once).
  • Controllers & Webhooks: Layer 6 endpoints that securely parse incoming events (verifying HMAC signatures) and translate proprietary JSON payloads into standardized Pydantic Domain Events.

5. Installation / Setup

Ensure you are using Python 3.11+ and install the package via pip:

pip install ferrox-py-commerce

You will also need to configure a Redis instance, as it is required by the TransactionStateService to manage distributed, atomic locks.

6. Quickstart (Usage)

from ferrox_py.core.container import Container
from ferrox_py_commerce import CommerceModule

# 1. Initialize your IoC container
container = Container()

# 2. Register the Commerce Module
container.register_module(CommerceModule)

# The Webhook controllers, Gateways, and State Machines are now 
# wired and ready to process payments safely!

7. Ecosystem Integration

The Commerce module integrates seamlessly with the Security Component of the core ferrox-py framework for distributed Redis locking, and it relies strictly on the AuthModule (ferrox-py-auth) to ensure that payment intents and subscriptions are accurately linked to a validated, authenticated User context.

Metadata

Release files for ferrox-py-commerce 1.0.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 ferrox-py-commerce 1.0.0
File Size Uploaded
ferrox_py_commerce-1.0.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ferrox-py-commerce 1.0.0
File Interpreter ABI Platform
ferrox_py_commerce-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / ferrox_py_commerce-1.0.0.tar.gz

Download URL ferrox_py_commerce-1.0.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f8e6e7d4b5caccfb5f7ef445f42903b19aaa1768102339e973f23eee939008
BLAKE2b-256 checksum
How to use checksums
01ca3b366d4eebcda17ed2f810e2c58d261c6834f5dd0965a662db180e821852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / ferrox_py_commerce-1.0.0-py3-none-any.whl

Download URL ferrox_py_commerce-1.0.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d771d2fea1b6ae9413c3fadb8bcf9b37136fc7235ea7fa688ffc2b1e91e34d21
BLAKE2b-256 checksum
How to use checksums
23f9b80a0c27b1100e7cfb7cd4802a78c88ee0dee7ac4aeb7f0602cd15263d1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

This release

1.0.0 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