Skip to content

[stripe] Handle invoice finalization #12456

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

Merged
merged 1 commit into from
Aug 31, 2022
Merged

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented Aug 28, 2022

Description

Implements invoice Finalization.

When an invoice is finalized, a webhook triggeres this RPC (through public-api).

  1. We fetch the Invoice
  2. We fetch the reportId from the invoice
  3. We fetch the subscription for the invoice to get the teamId/userId
  4. We filter the report to relevant instances (by attribution ID)
  5. We mark all instances for that Attribution ID as billed

Related Issue(s)

Fixes #

How to test

Release Notes

NONE

Documentation

Werft options:

  • /werft with-preview

@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch from 6e06398 to 227269c Compare August 28, 2022 18:46
@roboquat roboquat added size/XXL and removed size/M labels Aug 28, 2022
@easyCZ easyCZ changed the base branch from main to mp/billing-report-id-2 August 28, 2022 18:47
@easyCZ easyCZ force-pushed the mp/billing-report-id-2 branch from 18023bc to d02d891 Compare August 28, 2022 18:47
@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch from 227269c to 744a66e Compare August 28, 2022 18:47
@roboquat roboquat added size/L and removed size/XXL labels Aug 28, 2022
@easyCZ easyCZ force-pushed the mp/billing-report-id-2 branch 2 times, most recently from ac6dd91 to 5e513f2 Compare August 30, 2022 09:07
Base automatically changed from mp/billing-report-id-2 to main August 30, 2022 09:36
@roboquat roboquat added size/XL and removed size/L labels Aug 30, 2022
@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch from f13f667 to d377bbf Compare August 30, 2022 09:52
@roboquat roboquat added size/L and removed size/XL labels Aug 30, 2022
@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch from d377bbf to d3916a3 Compare August 30, 2022 09:56
@easyCZ easyCZ marked this pull request as ready for review August 30, 2022 13:04
@easyCZ easyCZ requested a review from a team August 30, 2022 13:04
@github-actions github-actions bot added the team: webapp Issue belongs to the WebApp team label Aug 30, 2022
Copy link
Contributor

@andrew-farries andrew-farries left a comment

Choose a reason for hiding this comment

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

/hold

@@ -91,3 +91,14 @@ func ListUsage(ctx context.Context, conn *gorm.DB, attributionId AttributionID,
}

type UsageReport []WorkspaceInstanceUsage

func (r UsageReport) FilterToAttributionID(attributionID AttributionID) UsageReport {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it's worth adding a test for this method (as it is exported by the db package)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good shout. Will add it.

I've also rebased and used the new contentservice.UsageReport struct

Copy link
Member Author

Choose a reason for hiding this comment

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

Added tests

@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch 2 times, most recently from a3ae174 to 5eda2d9 Compare August 31, 2022 07:39
@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch 2 times, most recently from d429fdd to 2887e47 Compare August 31, 2022 13:40
@easyCZ
Copy link
Member Author

easyCZ commented Aug 31, 2022

/unhold

@easyCZ easyCZ force-pushed the mp/stripe-finalize-invoice branch from 2887e47 to b0dffc5 Compare August 31, 2022 13:53
@roboquat roboquat merged commit 28f6980 into main Aug 31, 2022
@roboquat roboquat deleted the mp/stripe-finalize-invoice branch August 31, 2022 14:06
@roboquat roboquat added deployed: webapp Meta team change is running in production deployed Change is completely running in production labels Aug 31, 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/L team: webapp Issue belongs to the WebApp team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants