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.
  • 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.

Release files for beangulp-stripe 0.2.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.2.0
File Size Uploaded
beangulp_stripe-0.2.0.tar.gz 22.3 kB Details

Built distribution (wheel)

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

Total release size: 40.7 kB

Release files / beangulp_stripe-0.2.0.tar.gz

Download URL beangulp_stripe-0.2.0.tar.gz
Size 22.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0ceb45e17939b72c39242c690c8d309dfa31f65cfaedb5f964d18092f87550e0
BLAKE2b-256 checksum
How to use checksums
0bde2ed93de4f403ca9e26466abaff1d451dc60998ee5e5291cd61a299780e5a
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 Sep 21, 2026.

Transparency log

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

Download URL beangulp_stripe-0.2.0-py3-none-any.whl
Size 18.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d2d9a6abe09497893e44dca14d10fea69ce86afd6575c00752e424d5badd64cb
BLAKE2b-256 checksum
How to use checksums
9de2f6457e96c704bc6a7d69456c79c50c50137c7b23817c0ef2ece7af38c6c7
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 Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

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