Skip to content

Conversation

@Yopi
Copy link
Contributor

@Yopi Yopi commented Dec 16, 2025

These can be used to build balance metrics in the correct currency

@vercel
Copy link

vercel bot commented Dec 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
polar Ignored Ignored Preview Jan 5, 2026 0:39am
polar-sandbox Ignored Ignored Preview Jan 5, 2026 0:39am

@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch from 8496730 to 8d76e4e Compare December 16, 2025 15:55
Copy link
Member

@frankie567 frankie567 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things there and there, but that's the right approach :)

On another level, I'm wondering if we should add tax_amount in the events metadata as well: merchants indeed only care about the raw amount, but I'm wondering if we might need the tax amount in the future. That said, it can be a rabbit hole as it'll also require to add tax_country/tax_state to fully make sense 🤔

@Yopi
Copy link
Contributor Author

Yopi commented Dec 19, 2025

A few things there and there, but that's the right approach :)

Thank you for the good feedback!

On another level, I'm wondering if we should add tax_amount in the events metadata as well: merchants indeed only care about the raw amount, but I'm wondering if we might need the tax amount in the future. That said, it can be a rabbit hole as it'll also require to add tax_country/tax_state to fully make sense 🤔

That's a good question. If we think that it would be useful we might as well add it now I guess.

I also realised that we do revert_refund transactions which we might want to have an event for. Either as a negative amount with the same refund event, or a new event.

@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch 3 times, most recently from 3e737d3 to 8c55571 Compare December 19, 2025 09:05
@frankie567
Copy link
Member

That's a good question. If we think that it would be useful we might as well add it now I guess.

I gotta feeling (woohooo) that it'll be useful in the future. So I would say let's add it (+tax country/state).

I also realised that we do revert_refund transactions which we might want to have an event for. Either as a negative amount with the same refund event, or a new event.

Yeah let's do balance.refund_reversal. It's quite rarely used (6 transactions as of today!), but let's be complete.

@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch from 8c55571 to 8551ea3 Compare December 19, 2025 09:22
@Yopi
Copy link
Contributor Author

Yopi commented Dec 19, 2025

That's a good question. If we think that it would be useful we might as well add it now I guess.

I gotta feeling (woohooo) that it'll be useful in the future. So I would say let's add it (+tax country/state).

Perfect, I'll add it.

I also realised that we do revert_refund transactions which we might want to have an event for. Either as a negative amount with the same refund event, or a new event.

Yeah let's do balance.refund_reversal. It's quite rarely used (6 transactions as of today!), but let's be complete.

Should we do the same with the balance.dispute_reversal as well? 😅

@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch from 8551ea3 to 80b79b0 Compare December 19, 2025 09:57
@Yopi Yopi changed the title system-events: Add balance.{order,refund,dispute} events system-events: Add balance.{order,refund,refund_reversal,dispute} events Dec 19, 2025
@frankie567
Copy link
Member

frankie567 commented Dec 19, 2025

Should we do the same with the balance.dispute_reversal as well? 😅

So, the trick is that we only write the transaction when the dispute is closed (won or lost). If it's won, we write a Dispute + Dispute Reversal. If it's lost, just a Dispute. So I would be tempted to say that we only create an event balance.dispute when it's lost (because the merchant lost money) and be silent about won disputes.

EDIT: Actually, if we want to be clear about fees (see below), we probably need to have balance.dispute_reversal as well (because fees are applied even in case of won dispute).


Now that I think of it, there is also the fees dimension 😅 In this implementation, we store the amounts before Polar fees. If we want to show graphs with "net" amounts, we probably also need to store balance.fees events ☺️☺️

@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch 2 times, most recently from 82f4fbb to 14dc6ba Compare December 19, 2025 16:04
These can be used to build balance metrics in the
correct currency
@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch from 14dc6ba to 9246534 Compare January 5, 2026 10:34
To be able to track the fees separately
@Yopi Yopi force-pushed the yopi/system-events/balance-transactions branch from 6899d98 to 595cf43 Compare January 5, 2026 12:39
@Yopi Yopi requested a review from frankie567 January 5, 2026 12:47
@Yopi
Copy link
Contributor Author

Yopi commented Jan 5, 2026

I think this is good to go now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants