diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index f81d81faf..c1a3ffa8b 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -1,4 +1,3 @@ -import type { Tier } from '$lib/stores/billing'; import type { Campaign } from '$lib/stores/campaigns'; import type { Client, Models } from '@appwrite.io/console'; import type { PaymentMethod } from '@stripe/stripe-js'; @@ -30,42 +29,6 @@ export type PaymentList = { total: number; }; -export type Invoice = { - $id: string; - $createdAt: Date; - $updatedAt: Date; - permissions: string[]; - teamId: string; - aggregationId: string; - plan: Tier; - amount: number; - tax: number; - taxAmount: number; - vat: number; - vatAmount: number; - grossAmount: number; - creditsUsed: number; - currency: string; - from: string; - to: string; - status: string; - dueAt: string; - clientSecret: string; - usage: { - name: string; - value: number /* service over the limit*/; - amount: number /* price of service over the limit*/; - rate: number; - desc: string; - }[]; - lastError?: string; -}; - -export type InvoiceList = { - invoices: Invoice[]; - total: number; -}; - export type Estimation = { amount: number; grossAmount: number; @@ -89,7 +52,7 @@ export type EstimationDeleteOrganization = { credits: number; discount: number; items: EstimationItem[]; - unpaidInvoices: Invoice[]; + unpaidInvoices: Models.Invoice[]; }; export type Coupon = { @@ -657,41 +620,6 @@ export class Billing { ); } - async listInvoices(organizationId: string, queries: string[] = []): Promise { - const path = `/organizations/${organizationId}/invoices`; - const params = { - organizationId, - queries - }; - - const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'get', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } - - async getInvoice(organizationId: string, invoiceId: string): Promise { - const path = `/organizations/${organizationId}/invoices/${invoiceId}`; - const params = { - organizationId, - invoiceId - }; - const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'get', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } - async getInvoiceView( organizationId: string, invoiceId: string @@ -732,36 +660,6 @@ export class Billing { ); } - async updateInvoiceStatus(organizationId: string, invoiceId: string): Promise { - const path = `/organizations/${organizationId}/invoices/${invoiceId}/status`; - const uri = new URL(this.client.config.endpoint + path); - return await this.client.call('PATCH', uri, { - 'content-type': 'application/json' - }); - } - - async retryPayment( - organizationId: string, - invoiceId: string, - paymentMethodId: string - ): Promise { - const path = `/organizations/${organizationId}/invoices/${invoiceId}/payments`; - const params = { - organizationId, - invoiceId, - paymentMethodId - }; - const uri = new URL(this.client.config.endpoint + path); - return await this.client.call( - 'post', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } - async listUsage( organizationId: string, startDate: string = undefined, diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index 491a3b487..a6b8914c1 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -5,7 +5,7 @@ import { toLocaleDate } from '$lib/helpers/date'; import { plansInfo, upgradeURL } from '$lib/stores/billing'; import { organization } from '$lib/stores/organization'; - import type { Aggregation, CreditList, Invoice, Plan } from '$lib/sdk/billing'; + import type { Aggregation, CreditList, Plan } from '$lib/sdk/billing'; import { abbreviateNumber, formatCurrency, formatNumberWithCommas } from '$lib/helpers/numbers'; import { humanFileSize } from '$lib/helpers/sizeConvertion'; import { BillingPlan } from '$lib/constants'; @@ -21,10 +21,11 @@ } from '@appwrite.io/pink-svelte'; import { IconInfo, IconTag } from '@appwrite.io/pink-icons-svelte'; import CancelDowngradeModel from './cancelDowngradeModal.svelte'; + import type { Models } from '@appwrite.io/console'; export let currentPlan: Plan; export let creditList: CreditList; - export let currentInvoice: Invoice | undefined = undefined; + export let currentInvoice: Models.Invoice | undefined = undefined; export let currentAggregation: Aggregation | undefined = undefined; let showCancel: boolean = false;