Skip to main content

Billing service library for API usage tracking and Stripe integration.

Project description

Augint Billing Library

Billing service library for API usage tracking, tiered pricing calculations, and Stripe integration.

Overview

This library provides the core business logic for:

  • Tracking API usage per customer
  • Calculating charges with tiered pricing models
  • Managing Stripe customers and payments
  • Processing webhooks from Stripe
  • Publishing billing events to AWS EventBridge
  • Generating usage and billing reports

EventBridge Integration

The library automatically publishes billing events to AWS EventBridge for real-time monitoring and integration:

  • Usage Tracking: billing.usage.tracked events when API usage is recorded
  • Customer Creation: billing.customer.created events for new customers
  • Invoice Generation: billing.invoice.created events when invoices are generated
  • Payment Processing: billing.payment.processed events for payment status updates

Event publishing can be disabled via BILLING_ENABLE_EVENT_PUBLISHING=false environment variable.

CI Pipeline PyPI Python

Poetry Code style: black Linting: Ruff pre-commit Renovate

pytest GitHub Actions Semantic Release AWS SAM License: AGPL v3

📊 Live Dashboards

📖 Documentation 🧪 Unit Tests 🔬 Integration Tests 📊 Coverage Benchmarks 🔒 Security ⚖️ Compliance

🔑 Key Development Characteristics

Characteristic Details
Merge Strategy Configurable (see .env)
Deployment Model Tag-based to PyPI
Environments Local → PyPI
Preview Environments N/A (library)
Pipeline Features Semantic release, Auto-publish to PyPI
Special Considerations 90% coverage requirement, Mutation testing

Project Structure

augint-billing-lib-library/
├── src/
│   └── augint_billing_lib/      # Core library code (to be implemented)
├── tests/                   # Test suite (to be implemented)
├── examples/                # Original template code for reference
├── pyproject.toml          # Project dependencies and configuration
├── Makefile                # Development commands
└── README.md               # This file

Development Setup

# Install dependencies
make install

# Run tests
make test

# Check code quality
make lint
make type-check

# Generate documentation
make docs

Implementation Status

The library is fully implemented with all core components. Current implementation includes:

Library Exports (from planning spec)

  • BillingService - Main service class
  • UsageCollector - Track API usage
  • PricingCalculator - Apply tiered pricing
  • StripeManager - Stripe operations
  • WebhookProcessor - Process Stripe webhooks
  • ReportGenerator - Generate reports
  • EventPublisher - Publish billing events to EventBridge
  • Data models (Customer, UsageRecord, BillingPeriod, etc.)

Key Features Removed (Minimal Version)

  • ✅ Feature flags removed
  • ✅ Telemetry/Sentry removed
  • ✅ Mutation testing removed
  • ✅ Complex CLI structures removed

Dependencies

Core dependencies:

  • click - CLI framework
  • boto3 - AWS SDK (to be added)
  • stripe - Stripe SDK (to be added)
  • pydantic - Data validation (to be added)

Testing

The project uses pytest with pragmatic coverage targets:

  • Library code: 70% coverage target
  • Focus on core business logic
  • Integration tests for AWS/Stripe interactions

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

augint_billing_lib-1.3.0.tar.gz (105.7 kB view details)

Uploaded Source

Built Distribution

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

augint_billing_lib-1.3.0-py3-none-any.whl (118.0 kB view details)

Uploaded Python 3

File details

Details for the file augint_billing_lib-1.3.0.tar.gz.

File metadata

  • Download URL: augint_billing_lib-1.3.0.tar.gz
  • Upload date:
  • Size: 105.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for augint_billing_lib-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c65a07391ece7fbac7d97bde067d8e8313de32a04953225db4266d2f4db5c4b7
MD5 f350e7f34a5361e81c4366694891026b
BLAKE2b-256 735cac1e3eec24dacd2c05fa2a47fdef1e39d8f5133a6adef03d223ce92ab3b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for augint_billing_lib-1.3.0.tar.gz:

Publisher: pipeline.yaml on svange/augint-billing-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file augint_billing_lib-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for augint_billing_lib-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d19e8dd19706a311688ae47ea44149a97ea0302eb3112031aedc9fe548b24a9
MD5 13cbbefbb79a2f1dc438edfa8df194b4
BLAKE2b-256 bec68ab7ce159a0db6d316b7fe5372c9adc6c0e67adeaaec4e2ae278051029ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for augint_billing_lib-1.3.0-py3-none-any.whl:

Publisher: pipeline.yaml on svange/augint-billing-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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