diff --git a/src/lib/components/creditCardInfo.svelte b/src/lib/components/creditCardInfo.svelte
index eba14f06c..86c9d6c05 100644
--- a/src/lib/components/creditCardInfo.svelte
+++ b/src/lib/components/creditCardInfo.svelte
@@ -1,8 +1,10 @@
-
-
-
- Card ending in {paymentMethod?.last4}
- {paymentMethod?.brand}
-
+
+
+
+
+ {paymentMethod?.brand} ending in {paymentMethod?.last4}
+
+
+
Expires {paymentMethod?.expiryMonth}/{paymentMethod?.expiryYear}
-
+
-
-
-
-
+
+
- {
- console.log('test');
- }}>
- Delete
-
-
-
+
+
+
+ {
+ console.log('test');
+ }}>
+ Edit
+
+ {
+ console.log('test');
+ }}>
+ Delete
+
+
+
+
diff --git a/src/lib/elements/forms/inputRadio.svelte b/src/lib/elements/forms/inputRadio.svelte
index 97f1b14b4..cb3db08ce 100644
--- a/src/lib/elements/forms/inputRadio.svelte
+++ b/src/lib/elements/forms/inputRadio.svelte
@@ -1,7 +1,7 @@
@@ -33,65 +42,47 @@
Payment methods
-
-
- {#each $paymentMethods.paymentMethods as paymentMethod, i}
+ {#each filteredMethods as paymentMethod, i}
-
- {paymentMethod.brand} ending in {paymentMethod.last4}
- {paymentMethod.brand}
-
-
- Expires {paymentMethod.expiryMonth}/{paymentMethod.expiryYear}
-
-
-
- {#if paymentMethod.default}
-
- default payment method
-
- {/if}
- {#if paymentMethod.backup}
-
- backup payment method
-
- {/if}
-
-
-
-
-
- {
- console.log('test');
- }}>
- Edit
-
- {
- selectedMethod = paymentMethod.$id;
- showDelete = true;
- showDropdown[i] = false;
- }}>
- Delete
-
-
-
+
+
+
test
+
+
+
+ {
+ console.log('test');
+ }}>
+ Edit
+
+ {
+ selectedMethod = paymentMethod.$id;
+ showDelete = true;
+ showDropdown[i] = false;
+ }}>
+ Delete
+
+
+
+
+
{/each}
diff --git a/src/routes/console/account/payments/paymentModal.svelte b/src/routes/console/account/payments/paymentModal.svelte
index 6a91a19a8..90dcfd486 100644
--- a/src/routes/console/account/payments/paymentModal.svelte
+++ b/src/routes/console/account/payments/paymentModal.svelte
@@ -12,10 +12,8 @@
let name: string;
let error: string;
- let isStripeInitialized = false;
-
onMount(async () => {
- await initializeStripe(isStripeInitialized);
+ await initializeStripe();
});
async function handleSubmit() {
diff --git a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte
index 362acf7bf..6dad85f71 100644
--- a/src/routes/console/organization-[organization]/billing/paymentMethods.svelte
+++ b/src/routes/console/organization-[organization]/billing/paymentMethods.svelte
@@ -9,7 +9,7 @@
import { Button } from '$lib/elements/forms';
import PaymentModal from '$routes/console/account/payments/paymentModal.svelte';
import { hasStripePublicKey, isCloud } from '$lib/system';
- import { paymentMethods } from '$lib/stores/billing';
+ import { getCreditCardImage, paymentMethods } from '$lib/stores/billing';
import { onMount } from 'svelte';
import type { PaymentMethodData } from '$lib/sdk/billing';
@@ -127,6 +127,7 @@
Default
{#if $organization?.paymentMethodId}
{:else}
@@ -139,13 +140,19 @@
{#if $paymentMethods.total}
- {#each $paymentMethods.paymentMethods.filter((o) => o.$id !== $organization.backupPaymentMethodId) as paymentMethod}
+ {#each $paymentMethods.paymentMethods.filter((o) => !!o.last4 && o.$id !== $organization.backupPaymentMethodId) as paymentMethod}
addPaymentMethod(paymentMethod?.$id)}>
-
- Card ending in {paymentMethod.last4}
- {paymentMethod.brand}
-
+
+
+ Card ending in {paymentMethod.last4}
+
+
+
{/each}
{/if}
@@ -176,14 +183,20 @@
{#if $paymentMethods.total}
- {#each $paymentMethods.paymentMethods.filter((o) => o.$id !== $organization?.paymentMethodId) as paymentMethod}
+ {#each $paymentMethods.paymentMethods.filter((o) => !!o.last4 && o.$id !== $organization?.paymentMethodId) as paymentMethod}
addBackupPaymentMethod(paymentMethod?.$id)}>
-
- Card ending in {paymentMethod.last4}
- {paymentMethod.brand}
-
+
+
+ Card ending in {paymentMethod.last4}
+
+
+
{/each}
{/if}
diff --git a/src/routes/console/wizard/cloudOrganization/step2.svelte b/src/routes/console/wizard/cloudOrganization/step2.svelte
index 804822015..5d6609147 100644
--- a/src/routes/console/wizard/cloudOrganization/step2.svelte
+++ b/src/routes/console/wizard/cloudOrganization/step2.svelte
@@ -9,38 +9,42 @@
import { organization } from '$lib/stores/organization';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
- import { initializeStripe, submitStripeCard } from '$lib/stores/stripe';
+ import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
import { sdk } from '$lib/stores/sdk';
+ import { getCreditCardImage } from '$lib/stores/billing';
let methods: PaymentList;
let name: string;
let budgetEnabled = false;
let showRates = false;
- let isStripeInitialized = false;
-
onMount(async () => {
methods = await sdk.forConsole.billing.listPaymentMethods();
+ $createOrganization.paymentMethodId =
+ methods.paymentMethods.find((method) => !!method?.last4)?.$id ?? null;
- isStripeInitialized = await initializeStripe(isStripeInitialized);
+ // await initializeStripe();
});
async function handleSubmit() {
try {
- await submitStripeCard(name);
+ const method = await submitStripeCard(name);
+ $createOrganization.paymentMethodId = method.$id;
invalidate(Dependencies.PAYMENT_METHODS);
} catch (e) {
console.log(e.message);
}
}
- $: if ($createOrganization.paymentMethodId === null && !isStripeInitialized) {
- initializeStripe(isStripeInitialized);
+ $: if ($createOrganization.paymentMethodId === null && !$isStripeInitialized) {
+ initializeStripe();
}
$: if ($createOrganization.paymentMethodId) {
- isStripeInitialized = false;
+ isStripeInitialized.set(false);
}
+
+ $: filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4);
@@ -50,14 +54,23 @@
{#if methods?.total}
- {#each methods.paymentMethods as method}
+ {#each filteredMethods as method}
+ bind:group={$createOrganization.paymentMethodId}>
+
+
+ {method.brand} ending in {method.last4}
+
+
+
{/each}
{/if}
diff --git a/src/routes/console/wizard/cloudOrganization/step4.svelte b/src/routes/console/wizard/cloudOrganization/step4.svelte
index 6c9b7c478..03f84f387 100644
--- a/src/routes/console/wizard/cloudOrganization/step4.svelte
+++ b/src/routes/console/wizard/cloudOrganization/step4.svelte
@@ -18,6 +18,7 @@
const card = await sdk.forConsole.billing.getPaymentMethod(
$createOrganization.paymentMethodId
);
+ console.log(card);
return card;
} catch (error) {
console.log(error);
@@ -39,33 +40,36 @@
{/if}
-
-
Organization members
-
{collaboratorsNumber} invited
-
-
-
Payment
- {#await fetchCard()}
-
- {:then card}
-
Card ending in {card.last4} {card.brand}
- {/await}
-
-
+ {#if $createOrganization.billingPlan !== 'tier-0'}
+
+
Organization members
+
{collaboratorsNumber} invited
+
+
+
Payment
+ {#await fetchCard()}
+
+ {:then card}
+
Card ending in {card.last4} {card.brand}
+ {/await}
+
+ {/if}
-
- {plan.name} plan
- ${plan.price}
-
-
- Invited members
- ${plan.collaboratorPrice * collaboratorsNumber}
-
+ {#if $createOrganization.billingPlan !== 'tier-0'}
+
+ {plan.name} plan
+ ${plan.price}
+
+
+ Invited members
+ ${plan.collaboratorPrice * collaboratorsNumber}
+
+ {/if}
- Estimated total
+ Estimated total (in USD)
${totalExpences}
diff --git a/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte
index e8e85a45f..2762c449a 100644
--- a/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte
+++ b/src/routes/console/wizard/cloudOrganizationChangeTier/step2.svelte
@@ -9,7 +9,8 @@
import type { PaymentList } from '$lib/sdk/billing';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
- import { initializeStripe, submitStripeCard } from '$lib/stores/stripe';
+ import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
+ import { organization } from '$lib/stores/organization';
let methods: PaymentList;
let name: string;
@@ -18,12 +19,10 @@
// let error: string;
- let isStripeInitialized = false;
-
onMount(async () => {
methods = await sdk.forConsole.billing.listPaymentMethods();
-
- isStripeInitialized = await initializeStripe(isStripeInitialized);
+ $changeOrganizationTier.paymentMethodId =
+ $organization?.backupPaymentMethodId ?? methods.paymentMethods[0]?.$id ?? null;
});
async function handleSubmit() {
@@ -35,13 +34,15 @@
}
}
- $: if ($changeOrganizationTier.paymentMethodId === null && !isStripeInitialized) {
- initializeStripe(isStripeInitialized);
+ $: if ($changeOrganizationTier.paymentMethodId === null && !$isStripeInitialized) {
+ initializeStripe();
}
$: if ($changeOrganizationTier.paymentMethodId) {
- isStripeInitialized = false;
+ isStripeInitialized.set(false);
}
+
+ $: filteredMethods = methods?.paymentMethods.filter((method) => !!method?.last4);
@@ -51,7 +52,7 @@
{#if methods?.total}
- {#each methods.paymentMethods as method}
+ {#each filteredMethods as method}
-
-
Organization members
-
{collaboratorsNumber} invited
-
-
-
Payment
- {#await fetchCard()}
-
- {:then card}
-
Card ending in {card.last4} {card.brand}
- {/await}
-
+ {#if $changeOrganizationTier.billingPlan !== 'tier-0'}
+
+
Organization members
+
{collaboratorsNumber} invited
+
+
+
Payment
+ {#await fetchCard()}
+
+ {:then card}
+
Card ending in {card.last4} {card.brand}
+ {/await}
+
+ {/if}
-
- {plan.name} plan
- ${plan.price}
-
-
- Invited members
- ${plan.collaboratorPrice * collaboratorsNumber}
-
+ {#if $changeOrganizationTier.billingPlan !== 'tier-0'}
+
+ {plan.name} plan
+ ${plan.price}
+
+
+ Invited members
+ ${plan.collaboratorPrice * collaboratorsNumber}
+
+ {/if}
Estimated total