Skip to main content

Chaos engineering for payment flows

Project description

Carbon Layer

Chaos engineering for payment flows.

Every company processing payments tests the happy path — payment succeeds, order fulfilled — and ships. What breaks in production is everything else: dispute spikes your system doesn't respond to, refund storms that break reconciliation, gateway errors that leave orders stuck, webhook sequences your handlers were never tested against.

Carbon Layer lets you simulate these failure modes against your own integration before your customers encounter them. Run a scenario, point it at your webhook endpoint, and see exactly what your system handles and what it doesn't.


Installation

pip install carbon-layer

PostgreSQL is required for storage. Create a database before the first run:

createdb carbon

Or use Docker:

docker run -d --name carbon-pg \
  -e POSTGRES_PASSWORD=carbon \
  -e POSTGRES_DB=carbon \
  -p 5433:5432 postgres:15

Set the connection string via environment variable or .env file:

DATABASE_URL=postgresql://postgres:carbon@localhost:5433/carbon

Quickstart

No Razorpay account needed to get started. The mock adapter simulates the full payment lifecycle locally.

List available scenarios:

carbon scenarios-list

Run a scenario:

carbon run dispute-spike --provider mock
carbon report --run-id <run_id>

Webhook Simulation

The real value of Carbon Layer is testing your webhook handlers. Point it at your endpoint and it fires Razorpay-format events — payment.captured, dispute.created, refund.processed, and more — after the scenario runs. Payloads are signed with X-Razorpay-Signature (HMAC-SHA256), the same as Razorpay's live webhooks.

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

The report shows how your endpoint responded for each event type — 2xx, 4xx, 5xx, or timeout. No Razorpay account required.


Scenarios

Scenario What it tests
dispute-spike 15% dispute rate — does your system respond and submit evidence?
payment-decline-spike 30% payment failure rate — does your retry and order state logic hold?
refund-storm Mass refunds on captured payments — does reconciliation break?
flash-sale High order and payment volume — does throughput hold?
gateway-error-burst Intermittent gateway errors — are orders left in inconsistent state?
min-amount Minimum paise transactions — are edge-case amounts handled correctly?
max-amount Large-value transactions — are limits and approvals handled correctly?

Using with Razorpay

To run scenarios against your Razorpay test account:

carbon run dispute-spike \
  --provider razorpay \
  --api-key rzp_test_xxx \
  --api-secret yyy \
  --webhook-url https://your-staging-app.com/webhooks/razorpay

Or set credentials via environment variables: RAZORPAY_API_KEY and RAZORPAY_API_SECRET.

Note: Razorpay's test API does not support server-side payment creation or dispute creation. Scenarios that require these (e.g. dispute-spike) use the mock adapter automatically for those actions. Use --provider mock if you don't have Razorpay test credentials.


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.3.tar.gz (30.9 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.3-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: carbon_layer-0.1.3.tar.gz
  • Upload date:
  • Size: 30.9 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.3.tar.gz
Algorithm Hash digest
SHA256 0097de002282e82ee744552fad14623b0459bf708d2df1ec833ff2772ecead0f
MD5 fc34ef441cd0d4932e578db806995ab7
BLAKE2b-256 c952879d75e41f4a3192bd8e3a57982c1144eefbf826f50842fb202717d2eb9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: carbon_layer-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 34.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c254ff04607b47add9247056677cf709619f8592d9c0591d8895ab6b406eae83
MD5 4b8343818448d9ed5056eda65fdddb8f
BLAKE2b-256 568005c340dc36a19c745e9f64873e26145301fddc1bb5d3eeb365e6da5064a2

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