diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index a7e67bdc8..018b5ef69 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -1,7 +1,21 @@ import type { Client } from '@appwrite.io/console'; -import type { PaymentMethod } from '@stripe/stripe-js'; import type { Organization } from './organization'; +export type PaymentMethod = { + $id: string; + providerMethodId: string; + expiryMonth: number; + expiryYear: number; + last4: string; + country: string; + brand: string; +}; + +export type PaymentList = { + paymentMethods: PaymentMethod[]; + total: number; +}; + export class Billing { client: Client; @@ -198,7 +212,7 @@ export class Billing { //ACCOUNT - async listPaymentMethods(queries: [] = []): Promise { + async listPaymentMethods(queries: [] = []): Promise { const path = `/account/payment-methods`; const params = { queries diff --git a/src/routes/console/wizard/step2.svelte b/src/routes/console/wizard/step2.svelte index 52b0d235c..868e7635d 100644 --- a/src/routes/console/wizard/step2.svelte +++ b/src/routes/console/wizard/step2.svelte @@ -14,8 +14,10 @@ import { createOrganization } from './store'; import { Collapsible, CollapsibleItem } from '$lib/components'; import UsageRates from './usageRates.svelte'; + import type { PaymentList } from '$lib/stores/billing'; + import { paymentMethods } from '../account/payments/store'; - let methods = []; + let methods: PaymentList; let name: string; let promo: string; let redeemedCodes = []; @@ -24,7 +26,7 @@ onMount(async () => { methods = await sdk.forConsole.billing.listPaymentMethods(); - if (methods.length) { + if (methods?.total) { $createOrganization.paymentMethodId = methods[0].id; } }); @@ -45,25 +47,29 @@ Add a payment method to your organization. -
- {#if methods.length} - {#each methods as method} - +
+ {#if methods?.total} + {#each methods.paymentMethods as method} +
+ +
{/each} {/if}
- + {#if methods?.total} + + {/if} {#if $createOrganization.paymentMethodId === null}