Skip to main content

beangulp-stripe

beangulp importer for Stripe balance transactions, plus a thin API client. Entity-agnostic: account names, the fee account, and payee rules are all constructor arguments.

Input

A JSON file of /v1/balance_transactions data — the raw Stripe list response, a bare array, or a wrapper:

{
  "account": {"id": "acct_..."},
  "balance": {"as_of": "2026-07-10", "available": [...], "pending": [...]},
  "data": [{"object": "balance_transaction", "id": "txn_...", ...}]
}

Behaviour

  • stripe_id: metadata (the txn_... id) is the idempotency key — re-imports skip ids already in the ledger.
  • Minor units are converted per currency (zero- and three-decimal currencies included).
  • Cash leg books the net; a per-transaction fee is split out to the fees account so the counter leg is the gross. Without a fees account the fee is not posted and the counter leg is the net.
  • Nothing is skipped silently: money in a currency missing from account_map (a transaction, or a non-zero balance) and a transaction without id, created, net or fee raise ValueError.
  • stripe_fee transactions (monthly-billed fees debited from the balance) go straight to the fees account, review-flagged: the monthly tax invoice drives the VAT split at review.
  • payee_rules (regex, account, flag) draft other counter legs; unmatched drafts stay !-flagged with the cash leg only.
  • A balance snapshot becomes per-currency balance assertions dated the day after as_of.

Invoice correlation

correlate_invoices(transactions, invoices) pairs each charge balance transaction with the invoice documenting it, so a caller can file the customer invoice PDF against the entry it belongs to.

Stripe does not reliably link the two objects — on subscription invoices charge, payment_intent and subscription can all be null — so the pairing works in two passes:

  1. an id named by both objects wins outright (charge/payment_intent, or the newer payments list);
  2. failing that, same currency, same gross amount and created within CREATED_TOLERANCE_SECONDS of each other — and the agreement has to be mutual, one invoice for the transaction and one transaction for the invoice.

A transaction with no candidate is normal and silent: payouts, refunds and monthly stripe_fee debits have no customer invoice. A tie is returned in ambiguities and is expected to stop the caller — filing a PDF against the wrong entry is worse than filing none. An invoice that names an id but matched nothing settles a charge outside the window, so it never falls back to the heuristic.

Client

from beangulp_stripe import StripeClient

client = StripeClient("rk_live_...")   # restricted key, read-only scopes
txns = client.balance_transactions(created_gte, created_lte)
snapshot = client.balance()
invoices = client.invoices(created_gte, created_lte)
pdf = client.document(invoices[0]["invoice_pdf"])   # bytes

Use a restricted API key with Balance transaction sources: Read and Charges: Read (for expand[]=data.source payee names), plus Invoices: Read for invoices(). No write scopes.

invoice_pdf URLs are signed and short-lived, so fetch them at download time. document() follows the redirects itself, bounded, and sends no Authorization — the key stays on API requests and never travels to the host a redirect names.

Every fetch is bounded: a listing stops with StripeError past 10,000 objects (max_items; narrow the created window) or when a page fails to advance the cursor, and document() refuses a file over 8 MiB (max_bytes).

Metadata

Release files for beangulp-stripe 0.3.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 beangulp-stripe 0.3.0
File Size Uploaded
beangulp_stripe-0.3.0.tar.gz 25.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for beangulp-stripe 0.3.0
File Interpreter ABI Platform
beangulp_stripe-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.5 kB

Release files / beangulp_stripe-0.3.0.tar.gz

Download URL beangulp_stripe-0.3.0.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
acbd07adff5a09f805e34ce485644eb3761a4788259171847b45b2ee02133a8e
BLAKE2b-256 checksum
How to use checksums
3d41d1a21e3645897d488b3fb9e2352ca2e8f5abb38424f87d3d3d17fcfa36ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / beangulp_stripe-0.3.0-py3-none-any.whl

Download URL beangulp_stripe-0.3.0-py3-none-any.whl
Size 20.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4ab25b3df1a094825418a7faf840c2b7fa1ce9ebf035fae4f5a0c7e23739b8d3
BLAKE2b-256 checksum
How to use checksums
387dc2ba4751887d37cdb7a362da031f520279d6c1c56e84c0acba39b20358c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

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