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

feat: Billing Service #14756

Merged
merged 22 commits into from Apr 30, 2024
Merged

feat: Billing Service #14756

merged 22 commits into from Apr 30, 2024

Conversation

exception
Copy link
Contributor

@exception exception commented Apr 25, 2024

What does this PR do?

Introduces a new Billing Service to Platform API. For now, it is used to automate billing and usage for platform-enabled teams.

Relies upon Stripe for handling subscriptions.

How to Test

  • You need to have a valid platform-enabled team locally
  • You need to configure config/stripe.config.json for the plans you need to test
  • You need Stripe API key and you need to install stripe client
  • Run stripe listen --events customer.subscription.created,customer.subscription.updated --forward-to localhost:5555/api/v2/billing/webhook
  • Do a POST to localhost:5555/api/v2/billing/{{your team id}}/subscribe. The body needs to have the desired plan, eg "plan": "STARTER". You will get a redirect URI, which you need to visit` and run through the subscribe flow. This will trigger a webhook call which will update your team with the required billing data on Prisma.

Copy link
Contributor

github-actions bot commented Apr 25, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@graphite-app graphite-app bot requested a review from a team April 25, 2024 16:48
@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Apr 25, 2024
@dosubot dosubot bot added api area: API, enterprise API, access token, OAuth billing area: billing, stripe, payments, paypal, get paid ✨ feature New feature or request labels Apr 25, 2024
@graphite-app graphite-app bot requested a review from a team April 25, 2024 16:48
Copy link

vercel bot commented Apr 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
platform-starter-kit ❌ Failed (Inspect) Apr 30, 2024 7:44pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview Apr 30, 2024 7:44pm
cal ⬜️ Ignored (Inspect) Visit Preview Apr 30, 2024 7:44pm
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Apr 30, 2024 7:44pm

Copy link

graphite-app bot commented Apr 25, 2024

Graphite Automations

"Add foundation team as reviewer" took an action on this PR • (04/25/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add platform team as reviewer" took an action on this PR • (04/25/24)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Contributor

github-actions bot commented Apr 25, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link

deploysentinel bot commented Apr 25, 2024

Current Playwright Test Results Summary

✅ 315 Passing - ⚠️ 5 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 04/30/2024 08:01:01pm UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: edfe409

Started: 04/30/2024 07:57:15pm UTC

⚠️ Flakes

📄   apps/web/playwright/event-types.e2e.ts • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Event Types tests -- future user Different Locations Tests Can add Link Meeting as location and book with it
Retry 1Initial Attempt
0.42% (1) 1 / 236 run
failed over last 7 days
3.81% (9) 9 / 236 runs
flaked over last 7 days
Event Types tests -- legacy user Different Locations Tests Can remove location from multiple locations that are saved
Retry 1Initial Attempt
0% (0) 0 / 190 runs
failed over last 7 days
21.05% (40) 40 / 190 runs
flaked over last 7 days

📄   apps/web/playwright/eventType/limit-tab.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Limits Tab - Event Type Check the functionalities of the Limits Tab
Retry 1Initial Attempt
0% (0) 0 / 191 runs
failed over last 7 days
3.14% (6) 6 / 191 runs
flaked over last 7 days

📄   packages/embeds/embed-core/playwright/tests/preview.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Preview Preview - embed-core should load
Retry 1Initial Attempt
0% (0) 0 / 222 runs
failed over last 7 days
39.64% (88) 88 / 222 runs
flaked over last 7 days

📄   packages/embeds/embed-react/playwright/tests/basic.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
React Embed Element Click Popup should verify that the iframe got created with correct URL - namespaced
Retry 1Initial Attempt
13.33% (30) 30 / 225 runs
failed over last 7 days
45.78% (103) 103 / 225 runs
flaked over last 7 days

View Detailed Build Results


apps/api/v2/src/modules/billing/billing.repository.ts Outdated Show resolved Hide resolved
async subscribeTeamToStripe(
@Param("teamId") teamId: number,
@Body() input: SubscribeToPlanInput
): Promise<SubscribeTeamToBillingResponseDto> {
Copy link
Contributor

Choose a reason for hiding this comment

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

the main goal is to force a standard on the shape of api responses
and so that that the DTO only targets the actual data sent back

Promise<ApiResponse < DTO> >

Copy link

socket-security bot commented Apr 30, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package Note
Install scripts npm/core-js-pure@3.37.0
  • Install script: postinstall
  • Source: node -e "try{require('./postinstall')}catch(e){}"

View full report↗︎

Next steps

What is an install script?

Install scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.

Packages should not be running non-essential scripts during install and there are often solutions to problems people solve with install scripts that can be run at publish time instead.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/core-js-pure@3.37.0


return {
status: "success",
data: {},
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to return an empty data, Promise<ApiResponse<SubscribeTeamToBillingResponseDto | undefined>>

@keithwillcode keithwillcode enabled auto-merge (squash) April 30, 2024 19:48
@keithwillcode keithwillcode merged commit 1cfd2f7 into main Apr 30, 2024
36 of 39 checks passed
@keithwillcode keithwillcode deleted the chore/platform-billing branch April 30, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api area: API, enterprise API, access token, OAuth billing area: billing, stripe, payments, paypal, get paid core area: core, team members only ✨ feature New feature or request High priority Created by Linear-GitHub Sync ❗️ migrations contains migration files platform Anything related to our platform plan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants