diff --git a/src/lib/actions/analytics.ts b/src/lib/actions/analytics.ts index ad6f5ab71f..181592ef0c 100644 --- a/src/lib/actions/analytics.ts +++ b/src/lib/actions/analytics.ts @@ -263,6 +263,7 @@ export enum Submit { PaymentMethodCreate = 'submit_payment_method_create', PaymentMethodUpdate = 'submit_payment_method_update', PaymentMethodDelete = 'submit_payment_method_delete', + RetryPayment = 'submit_retry_payment', BillingAddressCreate = 'submit_billing_address_create', BillingAddressUpdate = 'submit_billing_address_update', BillingAddressDelete = 'submit_billing_address_delete', diff --git a/src/lib/components/billing/paymentBoxes.svelte b/src/lib/components/billing/paymentBoxes.svelte index 240ad1c0cc..e964c3d773 100644 --- a/src/lib/components/billing/paymentBoxes.svelte +++ b/src/lib/components/billing/paymentBoxes.svelte @@ -1,12 +1,18 @@ - + - - - {element.brand} ending in {element.last4} - + + + + + {element.brand} ending in {element.last4} + + + {#if element.$id === backupMethod} + Backup + {:else if element.$id === defaultMethod} + Default + {/if} + + {#if !!defaultMethod && element.$id !== defaultMethod && group === element.$id && showSetAsDefault && element.$id !== backupMethod} +
    + +
+ {/if}
@@ -73,6 +102,14 @@ + {#if showSetAsDefault} + + {/if}
diff --git a/src/lib/components/cardGrid.svelte b/src/lib/components/cardGrid.svelte index 67e0d2ad40..b9356a15ea 100644 --- a/src/lib/components/cardGrid.svelte +++ b/src/lib/components/cardGrid.svelte @@ -3,6 +3,7 @@ export let danger = false; export let hideOverflow = false; + export let hideFooter = false; @@ -14,7 +15,7 @@ - {#if $$slots.actions} + {#if $$slots.actions && !hideFooter}
diff --git a/src/lib/components/radioBoxes.svelte b/src/lib/components/radioBoxes.svelte index 4e3b4bf924..4a798660be 100644 --- a/src/lib/components/radioBoxes.svelte +++ b/src/lib/components/radioBoxes.svelte @@ -13,7 +13,7 @@ {#if total} {#each elements as element} {@const value = element[variableName]?.toString()} -
+
    -
+ {/each} {/if} -
+
    {#if total} @@ -37,5 +37,5 @@ {#if group === null} {/if} -
+ diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 96d6baee48..698f783777 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -523,6 +523,28 @@ export class Billing { ); } + 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/lib/stores/stripe.ts b/src/lib/stores/stripe.ts index 963adcf9e6..5730a4c866 100644 --- a/src/lib/stores/stripe.ts +++ b/src/lib/stores/stripe.ts @@ -101,9 +101,15 @@ export async function submitStripeCard(name: string, urlRoute?: string) { } } -export async function confirmPayment(orgId: string, clientSecret: string, paymentMethodId: string) { +export async function confirmPayment( + orgId: string, + clientSecret: string, + paymentMethodId: string, + route?: string +) { try { - const url = `${window.location.origin}/console/organization-${orgId}/billing`; + const url = + window.location.origin + (route ? route : `/console/organization-${orgId}/billing`); const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentMethodId); diff --git a/src/routes/console/organization-[organization]/billing/availableCredit.svelte b/src/routes/console/organization-[organization]/billing/availableCredit.svelte index 8ae74d81da..a2eed718bc 100644 --- a/src/routes/console/organization-[organization]/billing/availableCredit.svelte +++ b/src/routes/console/organization-[organization]/billing/availableCredit.svelte @@ -1,5 +1,5 @@ - + Available credit

Appwrite credit will automatically be applied to your next invoice.

-
-
-

Credit balance

- {formatCurrency(balance)} + {#if $organization?.billingPlan === BillingPlan.STARTER} + + Upgrade to Pro to add credits + Upgrade to a Pro plan to add credits to your organization. For more information on what + you can do with a Pro plan, + view our pricing guide. + + {:else} +
+
+

Credit balance

+ {formatCurrency(balance)} +
+ {#if creditList?.total} + + {/if}
{#if creditList?.total} - + + + Date Added + Expiry Date + Amount + + + {#each creditList.credits as credit} + + + {toLocaleDate(credit.$createdAt)} + + + {toLocaleDate(credit.expiration)} + + + {formatCurrency(credit.credits)} + + + {/each} + +
+
+

Total results: {creditList?.total}

+ +
+ {:else} + Add credits {/if} -
- {#if creditList?.total} - - - Date Added - Expiry Date - Amount - - - {#each creditList.credits as credit} - - - {toLocaleDate(credit.$createdAt)} - - - {toLocaleDate(credit.expiration)} - - - {formatCurrency(credit.credits)} - - - {/each} - -
-
-

Total results: {creditList?.total}

- -
- {:else} - Add credits + {/if} + + + {#if $organization?.billingPlan === BillingPlan.STARTER} + {/if} diff --git a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte index 112732418e..edf381c3f4 100644 --- a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte @@ -3,6 +3,7 @@ import { CardGrid, DropList, + DropListItem, DropListLink, EmptySearch, Heading, @@ -21,13 +22,17 @@ } from '$lib/elements/table'; import { toLocaleDate } from '$lib/helpers/date'; import { formatCurrency } from '$lib/helpers/numbers'; - import type { InvoiceList } from '$lib/sdk/billing'; + import type { Invoice, InvoiceList } from '$lib/sdk/billing'; import { sdk } from '$lib/stores/sdk'; import { VARS } from '$lib/system'; import { Query } from '@appwrite.io/console'; import { onMount } from 'svelte'; + import RetryPaymentModal from './retryPaymentModal.svelte'; + import { trackEvent } from '$lib/actions/analytics'; let showDropdown = []; + let showRetryModal = false; + let selectedInvoice: Invoice | null = null; let offset = 0; let invoiceList: InvoiceList = { @@ -125,6 +130,22 @@ event="download_invoice"> Download PDF + + {#if false} + { + selectedInvoice = invoice; + showRetryModal = true; + showDropdown[i] = !showDropdown[i]; + trackEvent(`click_retry_payment`, { + from: 'button', + source: 'billing_invoice_menu' + }); + }}> + Retry payment + + {/if} @@ -147,3 +168,7 @@ {/if} + +{#if selectedInvoice} + +{/if} diff --git a/src/routes/console/organization-[organization]/billing/replaceCard.svelte b/src/routes/console/organization-[organization]/billing/replaceCard.svelte index 8dfc4fe501..e253489906 100644 --- a/src/routes/console/organization-[organization]/billing/replaceCard.svelte +++ b/src/routes/console/organization-[organization]/billing/replaceCard.svelte @@ -1,16 +1,16 @@ + + + +

+ Your payment of ${invoice.amount} due on {toLocaleDate( + invoice.dueAt + )} has failed. Retry your payment to avoid service interruptions with your projects. +

+ + + + + + + + +
diff --git a/src/routes/console/organization-[organization]/excesLimitModal.svelte b/src/routes/console/organization-[organization]/excesLimitModal.svelte index e39b817693..bead52e175 100644 --- a/src/routes/console/organization-[organization]/excesLimitModal.svelte +++ b/src/routes/console/organization-[organization]/excesLimitModal.svelte @@ -62,10 +62,6 @@ Your usage exceeds the {tierToPlan($organization.billingPlan).name} plan limits - Appwrite Pro is now available. To facilitate a smooth transition for your projects, Starter plan - will maintain its current state of unlimited resource usage. This extension will be in effect - until January 31st, 2024. - {#if $organization.billingPlan === BillingPlan.STARTER}

Usage for {$organization.name} organization has reached the limits of the {tierToPlan(