diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 60165d453..687ed4c4a 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -48,6 +48,7 @@ export type Invoice = { rate: number; desc: string; }[]; + lastError?: string; }; export type InvoiceList = { diff --git a/src/routes/console/organization-[organization]/billing/+page.svelte b/src/routes/console/organization-[organization]/billing/+page.svelte index 379814dd1..15d12017a 100644 --- a/src/routes/console/organization-[organization]/billing/+page.svelte +++ b/src/routes/console/organization-[organization]/billing/+page.svelte @@ -76,13 +76,19 @@ {#if $failedInvoice} - - - The scheduled payment for {$organization.name} failed - - To avoid service disruptions in organization's your projects, please verify your payment - details and update them if necessary. - + {#if $failedInvoice?.lastError} + + The scheduled payment for {$organization.name} failed due to following error: {$failedInvoice.lastError} + + {:else} + + + The scheduled payment for {$organization.name} failed + + To avoid service disruptions in organization's your projects, please verify your payment + details and update them if necessary. + + {/if} {/if} {#if defaultPaymentMethod?.failed && !backupPaymentMethod} diff --git a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte index a8caf4348..8339ac60b 100644 --- a/src/routes/console/organization-[organization]/billing/paymentHistory.svelte +++ b/src/routes/console/organization-[organization]/billing/paymentHistory.svelte @@ -22,7 +22,7 @@ } 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'; @@ -31,6 +31,7 @@ import { selectedInvoice, showRetryModal } from './store'; let showDropdown = []; + let showFailedError = false; let offset = 0; let invoiceList: InvoiceList = { @@ -51,6 +52,11 @@ ]); } + function retryPayment(invoice: Invoice) { + $selectedInvoice = invoice; + $showRetryModal = true; + } + $: if (offset !== null) { request(); } @@ -82,14 +88,45 @@ - - {status === 'requires_authentication' ? 'failed' : status} - + {#if invoice?.lastError} + + (showFailedError = true)} + button> + {status === 'requires_authentication' + ? 'failed' + : status} + + +
  • + The scheduled payment has failed. . +
  • +
    +
    + {:else} + + {status === 'requires_authentication' + ? 'failed' + : status} + + {/if}
    {formatCurrency(invoice.amount)} @@ -132,8 +169,7 @@ { - $selectedInvoice = invoice; - $showRetryModal = true; + retryPayment(invoice); showDropdown[i] = !showDropdown[i]; trackEvent(`click_retry_payment`, { from: 'button',