refactor: Billing service (#15366)
* WIP: Billing service * WIP * Update __handler.ts * Update index.ts * WIP * WIP Signed-off-by: zomars <[email protected]> * WIP Signed-off-by: zomars <[email protected]> * Update delete.handler.ts * Update delete.handler.ts * Update internal-team-billing.ts * WIP * Type fixes Signed-off-by: zomars <[email protected]> * WIP Signed-off-by: zomars <[email protected]> * Discard changes to apps/api/v2/src/ee/event-types/event-types_2024_04_15/controllers/event-types.controller.ts * Discard changes to packages/app-store/skype/config.json * style: update text area (#15934) * chore: update text-editor input * chore: update text-editor input * final update * Update Editor.tsx --------- Co-authored-by: unknown <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> * fix: #15697 Assignment warning modal poping up ,even when hosts are added . (#15699) * removed reduntand check on assignedusers * update for managed eventtype * formatted * comments * Updated comments * extracted checkForEmptyAssignment and added tests * updated comments * updated to show dialog also when not yet saved * update translations * updated comments * updated translation * updated types * chore: update naming and comments * Delete apps/web/lib/checkForEmptyAssignment.ts deleted since file was renamed * Delete apps/web/test/lib/checkForEmptyAssignment.test.ts deleted as the file is renamed to be more descriptive * update to do teamcheck before * chore: revert name to CheckForEmptyAssignment * updated check conditions * updated useEffect dependencies --------- Co-authored-by: Anik Dhabal Babu <[email protected]> * fix: getting an error when a team member tries to leave (#15925) a team Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Amit Sharma <[email protected]> * feat: add transitions to more components (#15916) * add transitions to more components * chore: Remove duplicate class * fix: Change minimum number of teams required for org self-serve (#15955) * fix: Change minimum number of teams required for org self-serve Signed-off-by: Souptik Datta <[email protected]> * refactor: Use a new constant for displaying org helper text dialogue Signed-off-by: Souptik Datta <[email protected]> * Update packages/lib/constants.ts * Update turbo.json --------- Signed-off-by: Souptik Datta <[email protected]> Co-authored-by: Keith Williams <[email protected]> * feat: pwa ready and add shortcut for quick access (#15957) * chore: Update site.webmanifest with additional display properties * chore: Update site.webmanifest with additional display properties * Update apps/web/public/site.webmanifest --------- Co-authored-by: Keith Williams <[email protected]> * i18n: update translations for "by proceeding, ..." (#15921) * feat: Add title attribute to iframe in embed.ts (#15944) * feat: Add title attribute to iframe in embed.ts * Update packages/embeds/embed-core/src/embed.ts --------- Co-authored-by: Hariom Balhara <[email protected]> * fix: Assignment reminder modal appears when deleting a team event type (#15544) * fix: Assignment reminder modal appears when deleting a team event type * update * Update EventTypeSingleLayout.tsx * Update event-types-single-view.tsx * update * Early return https://handbook.cal.com/engineering/best-practices/prefer-early-returns --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Hariom <[email protected]> * fix: Add CORP and COEP headers to embedded pages (#15275) * Add CORP headers * Improve test * Add unit tests as well --------- Co-authored-by: Keith Williams <[email protected]> * feat: No-show bookings - do not count towards a member's round robin assignment (#15323) * feat: No-show bookings - do not count towards a member's round robin assignment * filter no show organizer * remove logs * fix: filter bookings where host attendee is no show * fix: use not condition for noShow * chore: test * add default false for noShowHost * Revert "chore: test" This reverts commit c914a8fc4a14ca9c7d8c4a08ff8b0f463789171c. * chore: integration test * fix: noShowHost not working for null * Update packages/lib/server/getLuckyUser.ts * chore: update test description --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: gh0st91848 <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> * refactor: v1 orgs unlimited teams (#15908) * refactor: v1 orgs unlimited teams * fix: response message ownerId --------- Co-authored-by: Keith Williams <[email protected]> * fix: refresh connect atoms on token change (#15933) * added dropdown * change comment * fix: added types --------- Co-authored-by: Morgan <[email protected]> Co-authored-by: Keith Williams <[email protected]> * fix: Next.js bundle analysis (#15903) * fix: Next.js bundle analysis * Added the main checkout back * fix: type in webhook payload (#15912) Co-authored-by: CarinaWolli <[email protected]> * fix: auto accept (#15975) * fix: auto accept * Update packages/lib/server/repository/organization.ts Co-authored-by: Hariom Balhara <[email protected]> --------- Co-authored-by: Hariom Balhara <[email protected]> * fix: Broken GitHub workflows (#15979) * test: Delete credential endpoint (#15322) * Init * Add mock trpc context * Intro mockDatabaseClient * Introduce mockDatabaseClient class * Add delete video app test * Add calendar test * Remove unused func from bookingScenario * Remove console.log * Add app repository * Add createMany method to event type repository * Remove instance of MockDatabaseClient from video test * Add destination calendar repository * Remove instances of MockDatabaseClient * abstract logic to own handler * Remove dev dependency * Clean up * Type fix * Pull yarn.lock from main --------- Co-authored-by: Anik Dhabal Babu <[email protected]> * fix: #15967 Show better error when wrong variable is used in custom event name (#15974) * update to show exact err msg with custom event name * updated tests for validateCustomEventName --------- Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> * WIP Signed-off-by: zomars <[email protected]> * Update yarn.lock * Update publish.handler.ts * Update internal-team-billing.test.ts * rename create to init * remove sync services * wip tests for delete team * wip tets * wip tests * tests/internal-test * remove return that is inaccessable * remove team calls to use repository * remove redudant file * update team repo * add stripe mocks and test * fix constants * tests to main stripe handler * remove logs * fix constants * Update packages/features/ee/billing/api/webhook/_customer.subscription.deleted.team-plan.ts Co-authored-by: Omar López <[email protected]> * move workflow logic to a service * use static method > creating new class * fix: remove http code deep in repo + tests * Feedback * Update index.ts * Type fix * Lazy load fixes --------- Signed-off-by: zomars <[email protected]> Signed-off-by: Souptik Datta <[email protected]> Co-authored-by: Rohan Advani <[email protected]> Co-authored-by: unknown <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: Vijay <[email protected]> Co-authored-by: Somay Chauhan <[email protected]> Co-authored-by: Amit Sharma <[email protected]> Co-authored-by: Hichem Fantar <[email protected]> Co-authored-by: Souptik Datta <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Johannes Maendle <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: gh0st91848 <[email protected]> Co-authored-by: Lauris Skraucis <[email protected]> Co-authored-by: Morgan <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: sean <[email protected]>
This commit is contained in:
46 files changed
+1848
-337
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type Stripe from "stripe";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import { mockStripeSubscription } from "../mockData";
|
||||
|
||||
interface MockStripeProps {
|
||||
subscriptions: {
|
||||
cancel: () => Promise<Stripe.Subscription>;
|
||||
update: () => Promise<Stripe.Subscription>;
|
||||
retrieve: () => Promise<Stripe.Subscription>;
|
||||
};
|
||||
}
|
||||
|
||||
vi.mock("stripe", () => {
|
||||
return vi.fn(() => {
|
||||
return {
|
||||
subscriptions: {
|
||||
cancel: () => Promise.resolve(mockStripeSubscription),
|
||||
update: () => Promise.resolve(mockStripeSubscription),
|
||||
retrieve: () => Promise.resolve(mockStripeSubscription),
|
||||
},
|
||||
} as MockStripeProps;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
import type Stripe from "stripe";
|
||||
|
||||
export const mockStripeCustomer: Stripe.Customer = {
|
||||
id: "cus_xxx",
|
||||
object: "customer",
|
||||
address: null,
|
||||
balance: -4972,
|
||||
created: 1689812247,
|
||||
currency: "cad",
|
||||
default_source: null,
|
||||
delinquent: false,
|
||||
description: null,
|
||||
discount: null,
|
||||
email: "[email protected]",
|
||||
invoice_prefix: "xxx",
|
||||
invoice_settings: {
|
||||
custom_fields: null,
|
||||
default_payment_method: null,
|
||||
footer: null,
|
||||
rendering_options: null,
|
||||
},
|
||||
livemode: false,
|
||||
metadata: {},
|
||||
name: null,
|
||||
next_invoice_sequence: 17,
|
||||
phone: null,
|
||||
preferred_locales: [],
|
||||
shipping: null,
|
||||
tax_exempt: "none",
|
||||
test_clock: null,
|
||||
};
|
||||
|
||||
export const mockEnv = {
|
||||
DATABASE_URL: "xxx",
|
||||
NODE_ENV: "xxx",
|
||||
NEXTAUTH_SECRET: "xxx",
|
||||
NEXTAUTH_URL: "xxx",
|
||||
REDDIT_CLIENT_ID: "xxx",
|
||||
REDDIT_CLIENT_SECRET: "xxx",
|
||||
BUNNY_PASSWORD: "xxx",
|
||||
STRIPE_TEST_KEY: "xxx",
|
||||
STRIPE_LIVE_KEY: "xxx",
|
||||
STRIPE_WEBHOOK_SECRET: "xxx",
|
||||
NEXT_URL: "xxx",
|
||||
OPEN_AI_KEY: "xxx",
|
||||
OPEN_AI_ORG: "xxx",
|
||||
SENDGRID_API_KEY: "xxx",
|
||||
IBM_API_KEY: "xxx",
|
||||
IBM_URL: "xxx",
|
||||
NEXT_PUBLIC_NODE_ENV: "xxx",
|
||||
SENTRY_DSN: "xxx",
|
||||
NEXT_PUBLIC_SENTRY_DSN: "xxx",
|
||||
};
|
||||
|
||||
export const mockStripeSubscription: Stripe.Subscription & { plan: Stripe.Plan } = {
|
||||
id: "sub_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
object: "subscription",
|
||||
application: null,
|
||||
application_fee_percent: null,
|
||||
automatic_tax: { enabled: false },
|
||||
billing_cycle_anchor: 1718226165,
|
||||
billing_thresholds: null,
|
||||
cancel_at: 1749762165,
|
||||
cancel_at_period_end: true,
|
||||
canceled_at: 1718227398,
|
||||
collection_method: "charge_automatically",
|
||||
created: 1718226165,
|
||||
currency: "usd",
|
||||
current_period_end: 1749762165,
|
||||
current_period_start: 1718226165,
|
||||
customer: "cus_xxxxxxxxxxxxxx",
|
||||
days_until_due: null,
|
||||
default_payment_method: "pm_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
default_source: null,
|
||||
default_tax_rates: [],
|
||||
description: null,
|
||||
discount: null,
|
||||
ended_at: 1749762165,
|
||||
items: {
|
||||
object: "list",
|
||||
data: [],
|
||||
has_more: false,
|
||||
url: "/v1/subscription_items?subscription=sub_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
},
|
||||
latest_invoice: "in_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
livemode: false,
|
||||
metadata: {},
|
||||
next_pending_invoice_item_invoice: null,
|
||||
pause_collection: null,
|
||||
payment_settings: {
|
||||
payment_method_options: {
|
||||
acss_debit: null,
|
||||
bancontact: null,
|
||||
card: { request_three_d_secure: "automatic" },
|
||||
customer_balance: null,
|
||||
konbini: null,
|
||||
us_bank_account: null,
|
||||
},
|
||||
payment_method_types: null,
|
||||
save_default_payment_method: "off",
|
||||
},
|
||||
pending_invoice_item_interval: null,
|
||||
pending_setup_intent: null,
|
||||
pending_update: null,
|
||||
plan: {
|
||||
id: "price_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
object: "plan",
|
||||
active: true,
|
||||
aggregate_usage: null,
|
||||
amount: 14400,
|
||||
amount_decimal: "14400",
|
||||
billing_scheme: "per_unit",
|
||||
created: 1718225939,
|
||||
currency: "usd",
|
||||
interval: "year",
|
||||
interval_count: 1,
|
||||
livemode: false,
|
||||
metadata: {},
|
||||
nickname: null,
|
||||
product: "prod_xxxxxxxxxxxxxx",
|
||||
tiers_mode: null,
|
||||
transform_usage: null,
|
||||
trial_period_days: null,
|
||||
usage_type: "licensed",
|
||||
},
|
||||
schedule: null,
|
||||
start_date: 1718226165,
|
||||
status: "canceled",
|
||||
test_clock: "clock_xxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
transfer_data: null,
|
||||
trial_end: null,
|
||||
trial_start: null,
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import { UserPermissionRole } from "@calcom/prisma/enums";
|
||||
import type { GetSessionFn } from "@calcom/trpc/server/createContext";
|
||||
import { createContext } from "@calcom/trpc/server/createContext";
|
||||
import type { UserProfile } from "@calcom/types/UserProfile";
|
||||
|
||||
const sessionGetter: GetSessionFn = () =>
|
||||
Promise.resolve({
|
||||
user: {
|
||||
name: "",
|
||||
email: "",
|
||||
image: "",
|
||||
id: 1,
|
||||
username: "" /* Not used in this context */,
|
||||
role: UserPermissionRole.USER,
|
||||
profile: {
|
||||
id: null,
|
||||
organizationId: null,
|
||||
organization: null,
|
||||
username: "",
|
||||
upId: "",
|
||||
} satisfies UserProfile,
|
||||
},
|
||||
hasValidLicense: true /* To comply with TS signature */,
|
||||
expires: "" /* Not used in this context */,
|
||||
upId: "",
|
||||
});
|
||||
|
||||
export async function mockTRPCContext() {
|
||||
const req: NextApiRequest = { url: "/api/clients", headers: { "accept-language": "en" } } as NextApiRequest;
|
||||
const res: NextApiResponse = {} as NextApiResponse;
|
||||
const ctx = await createContext({ req, res }, sessionGetter);
|
||||
return ctx;
|
||||
}
|
||||
Reference in new issue
Block a user