-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(invoice): stripe app invoice sync #1978
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hekike
added
release-note/feature
Release note: Exciting New Features
area/billing
labels
Dec 17, 2024
turip
reviewed
Dec 17, 2024
turip
reviewed
Dec 18, 2024
hekike
force-pushed
the
feat/stripe-invoice
branch
from
December 18, 2024 18:03
1ef8d89
to
dffeffa
Compare
hekike
force-pushed
the
feat/stripe-invoice
branch
from
December 20, 2024 16:44
c3df7c0
to
93a8ab6
Compare
hekike
changed the title
feat(invoice): stripe app
feat(invoice): stripe app invoice sync
Dec 21, 2024
tothandras
requested changes
Dec 21, 2024
tothandras
approved these changes
Dec 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synchronize OpenMeter invoices with Stripe Invoicing through apps.
How it works
The invoice state machine calls the interfaces of compatible apps like Stripe App to Upsert and Finalize the invoice.
Driven by the state machine, the Stripe App creates, updates, and finalizes a Stripe Invoice object via the Stripe SDK.
If the invoice doesn't exist yet (determined by checking its external invoicing app ID), it is created; otherwise, it is updated in Stripe. Every OpenMeter invoice line and discount is translated to flat InvoiceLineItem(s) in Stripe. Discounts are represented as negative amounts. The update diffs the line items between Stripe and OpenMeter and decides which lines need to be updated, added, or removed in Stripe.
We prioritize synchronizing lines with quantity and per-unit price for greater visibility when they fit Stripe amount cents. When any Stripe line doesn't fit cents without floating points, we synchronize all lines with the total amount (the product of quantity and unit price).
Currently, automatic tax collection is enabled.
Todos: