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

feature: Implement billing-integrations stripe CLI #1180

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

jshearer
Copy link
Contributor

@jshearer jshearer commented Sep 12, 2023

  • For the moment, invoices are created as drafts and have to be approved and sent/paid manually. A draft invoice can be edited, but not sent or paid.
  • One of the next steps is to display invoice PDFs or links to Stripe's hosted invoice page in the dashboard. Neither of these are available for draft invoices, so only invoices that are manually approved will show the PDF/hosted link.
  • These invoices are being entered as collection_method: SendInvoice, which requires that the associated customer has an email that can receive the invoice. Customers that have already entered payment details will have this email set, but rather than skip all of the customers that haven't gone through that process, I decided to pick the email address of an admin user on their tenant. This is only the default, and can be changed once created later.
Publish bills from the control-plane database as Stripe invoices

USAGE:
    billing-integrations stripe [OPTIONS] --connection-string <CONNECTION_STRING> --stripe-api-key <STRIPE_API_KEY> --month <MONTH>

OPTIONS:
        --all-tenants
            Generate invoices for all tenants that have bills in the provided month

        --connection-string <CONNECTION_STRING>
            Control-plane DB connection string

        --fail-fast
            Stop execution after first failure

    -h, --help
            Print help information

        --month <MONTH>
            The month to generate invoices for, in format "YYYY-MM-DD"

        --recreate-finalized
            Whether to delete and recreate finalized invoices

        --stripe-api-key <STRIPE_API_KEY>
            Stripe API key

        --tenants <TENANTS>
            Comma-separated list of tenants to publish invoices for

This change is Reviewable

Copy link
Member

@jgraettinger jgraettinger left a comment

Choose a reason for hiding this comment

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

IIRC we'd discussed this living in another crate that's not part of the workspace, that can have its own Cargo.toml and be invoked via cargo run. Is there a reason why flowctl is more appropriate?

@jgraettinger
Copy link
Member

I see you're also using the PostgREST API rather than sqlx for access. This presumes the capabilities of the current estuary_support/ role, but we actually want to remove that role. When creating reports for multiple tenants this is basically going to require direct DB access.

@jshearer
Copy link
Contributor Author

I thought you said that you'd be fine with a hidden flowctl command -- having it be in flowctl is nice because the boilerplate for storing/loading control-plane credentials is already handled.

@jshearer
Copy link
Contributor Author

But sure, if we're getting rid of estuary_support then I guess this won't work very well. I can change it so you have to provide it the actual database credentials and uses sqlx.

@jshearer
Copy link
Contributor Author

wait, another crate that's not even in the workspace? Do you want me to make a new repo? Or where would it go?

@jgraettinger
Copy link
Member

wait, another crate that's not even in the workspace? Do you want me to make a new repo? Or where would it go?

We do this already for derive-typescript, for example:
https://github.com/estuary/flow/blob/master/Cargo.toml#L4

How about it lives in the Flow repo, but is excluded from the workspace. It doesn't need to be built by CI, and we can cargo run it as-needed ?

@jshearer jshearer force-pushed the feature/stripe_invoices branch from aea8a8e to e9d8613 Compare September 13, 2023 15:42
* For the moment, invoices are created as drafts and have to be approved and sent/paid manually. A draft invoice can be edited, but not sent or paid.
* One of the next steps is to display invoice PDFs or links to Stripe's hosted invoice page in the dashboard. Neither of these are available for draft invoices, so only invoices that are manually approved will show the PDF/hosted link.
* These invoices are being entered as `collection_method: SendInvoice`, which _requires_ that the associated customer has an email that can receive the invoice. Customers that have already entered payment details will have this email set, but rather than skip all of the customers that haven't gone through that process, I decided to pick the email address of an `admin` user on their tenant. This is only the default, and can be changed once created later.
@jshearer jshearer force-pushed the feature/stripe_invoices branch from e9d8613 to 64fb45e Compare September 13, 2023 15:47
@jshearer
Copy link
Contributor Author

Moved into separate crate, and updated to use sqlx 👍

Copy link
Member

@jgraettinger jgraettinger left a comment

Choose a reason for hiding this comment

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

LGTM!

Not knowledgeable about Stripe's API, but for things i do understand this is great. Thanks for re-working it

@jshearer jshearer merged commit a8a9557 into master Sep 13, 2023
5 checks passed
@jshearer jshearer changed the title feature: Implement flowctl raw publish-stripe-invoices feature: Implement billing-integrations stripe CLI Sep 14, 2023
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.

2 participants