Skip to main content

Chaos engineering for payment flows

Project description

Carbon Layer

Chaos engineering for payment flows.

Test what breaks in your payment integration before it breaks in production. Run scenarios (dispute spikes, refund storms, payment failures) against your Razorpay test account and get a report on what your system handled—and what it didn't.

Status

Early stage. MVP implemented: scenario engine, mock + Razorpay adapters, CLI.

Run locally (no Razorpay account):

python -m venv .venv && .venv/bin/pip install -e .
.venv/bin/carbon scenarios-list
.venv/bin/carbon run dispute-spike --provider mock
.venv/bin/carbon report --run-id <run_id>

Webhook simulation:

Point Carbon Layer at your webhook endpoint and it will fire Razorpay-format events (payment.captured, dispute.created, refund.processed, etc.) at it after the scenario runs. The report shows how your endpoint responded — 2xx, 4xx, 5xx, or timeout — for each event type.

carbon run dispute-spike --provider mock --webhook-url http://localhost:8000/webhooks/razorpay

No Razorpay account needed. Carbon generates the payloads and signs them with X-Razorpay-Signature (HMAC-SHA256). Pass --webhook-url to any scenario.

Database: PostgreSQL only. Set DATABASE_URL (default: postgresql://localhost:5432/carbon). Create the database first: createdb carbon. Tables are created on first run. If you see "password authentication failed", either set DATABASE_URL in .env with your credentials, or use Docker: docker run -d --name carbon-pg -e POSTGRES_PASSWORD=carbon -e POSTGRES_DB=carbon -p 5433:5432 postgres:15 then DATABASE_URL=postgresql://postgres:carbon@localhost:5433/carbon (see .env.example; a .env with this URL is created for local runs).

Base SLA (mock adapter, PostgreSQL, real-world scale): Target: < 5 s (5,000 ms) end-to-end per scenario. Measured after optimization (single connection, bulk entity inserts, parallel adapter calls).

Scenario Scale Result Measured (ms) Target
dispute-spike 1,000 orders, 1,000 captured, 150 disputes All passed ~440 ms < 5,000 ms ✓
payment-decline-spike 2,000 orders, ~1,400 captured (70% success) All passed ~480 ms < 5,000 ms ✓
refund-storm 2,000 orders, 2,000 captured, 500 refunds All passed ~520 ms < 5,000 ms ✓

See TECHNICAL_REQUIREMENTS.md for full spec. Carbon Layer is not limited to payments; payments is the first vertical; more apps/verticals will be imitated later (see Product strategy, scope, and paid layers in the spec).

Tests:

pip install -e ".[dev]"
pytest tests/ -v                    # unit tests only (no DB)
DATABASE_URL=postgresql://... pytest tests/ -v   # include integration tests (all 7 scenarios)

Unit tests cover the validator (metrics, expected evaluation, conditions) and compiler (scenario load and plan). Integration tests run each scenario end-to-end with the mock adapter and assert entity counts and that high-severity findings pass; they require PostgreSQL.

Roadmap

  • Phase 1: Scenario testing engine (Razorpay adapter)
  • Phase 2: Environment-as-a-Service (populate sandbox with realistic data)
  • Phase 3: Compliance & audit simulation

License

Apache 2.0 — see LICENSE.

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

carbon_layer-0.1.0.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carbon_layer-0.1.0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file carbon_layer-0.1.0.tar.gz.

File metadata

  • Download URL: carbon_layer-0.1.0.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for carbon_layer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15d3f2305ddfd14d930a5ab312c333cf28037f11aadcca4b493d7a09a74e3795
MD5 c99e8de5643fba0a289fa98c9a5b83e9
BLAKE2b-256 e2a7c61078ec3f64a2c65b65ebe7dc2a104ac1df7e947063b1f1015544f4ac15

See more details on using hashes here.

File details

Details for the file carbon_layer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: carbon_layer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for carbon_layer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76870db0c3e2ee9e78c1e236dd04fbfc4474c2cc60496cefba012911395b3805
MD5 23d687ddce4e0ca0b316a239c6ca4977
BLAKE2b-256 f4b5a3aec539ff277405edace33f187b99410df46f8e42eccb883f4fdb6afc38

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