Skip to content
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

[stripe] Finalized invoce debits, do not set credits to negative when updating #12787

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Sep 8, 2022

  1. We need to debit the credit amount in usage, not credit the credit amount
  2. We shouldn't try to update usage to negative values. This doesn't make sense (and isn't allowed by Stripe). Instead we set it to 0. This happens when a customer has for example bought a bundle or overpaid on an invoice.

Description

Related Issue(s)

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ requested a review from a team September 8, 2022 21:09
@github-actions github-actions bot added team: webapp Issue belongs to the WebApp team and removed size/S labels Sep 8, 2022
Base automatically changed from mp/stripe-use-attribution-id-metdata to main September 9, 2022 05:18
@roboquat roboquat added the size/L label Sep 9, 2022
@@ -118,7 +108,8 @@ func (s *BillingService) FinalizeInvoice(ctx context.Context, in *v1.FinalizeInv
ID: uuid.New(),
AttributionID: attributionID,
Description: fmt.Sprintf("Invoice %s finalized in Stripe", invoice.ID),
CreditCents: db.NewCreditCents(float64(creditsOnInvoice)),
// Apply negative value of credits to reduce accrued credit usage
CreditCents: db.NewCreditCents(float64(-creditsOnInvoice)),
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we'd do it the otherway around. Maybe we can create a PR with a migration that negates all credits and changes the respective code as well?

Copy link
Member

Choose a reason for hiding this comment

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

Actually thinking about it again, it might be fine as is. After all the table is called usage so positive means used negative means gained. 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

We can still make the change and drop the usage records manually

Copy link
Member Author

Choose a reason for hiding this comment

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

Spoke directly, we'll be keeping it as is to more closely align with Stripe which also doesn't want negative credits, but positive credits for usage

@easyCZ
Copy link
Member Author

easyCZ commented Sep 9, 2022

/hold for discussion

@easyCZ easyCZ force-pushed the mp/stripe-negative-usage branch from 27f05d9 to 8bf8561 Compare September 9, 2022 07:17
@roboquat roboquat added size/S and removed size/L labels Sep 9, 2022
@easyCZ
Copy link
Member Author

easyCZ commented Sep 9, 2022

/unhold

@roboquat roboquat merged commit 43e526b into main Sep 9, 2022
@roboquat roboquat deleted the mp/stripe-negative-usage branch September 9, 2022 07:27
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production deployed Change is completely running in production release-note-none size/S team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants