mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge branch 'cloud' of github.com:appwrite/console into sync-main-cloud
This commit is contained in:
@@ -279,6 +279,7 @@ export const paymentMissingMandate = writable<PaymentMethodData>(null);
|
||||
|
||||
export async function checkForMandate(org: Organization) {
|
||||
const paymentId = org.paymentMethodId ?? org.backupPaymentMethodId;
|
||||
if (!paymentId) return;
|
||||
const paymentMethod = await sdk.forConsole.billing.getPaymentMethod(paymentId);
|
||||
if (paymentMethod.mandateId === null && paymentMethod.country === 'in') {
|
||||
headerAlert.add({
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function unmountPaymentElement() {
|
||||
elements = null;
|
||||
}
|
||||
|
||||
export async function submitStripeCard(name: string, urlRoute?: string) {
|
||||
export async function submitStripeCard(name: string, organizationId?: string) {
|
||||
try {
|
||||
// If a payment method was created during initialization, use it, otherwise create a new one
|
||||
if (!paymentMethod) {
|
||||
@@ -62,16 +62,20 @@ export async function submitStripeCard(name: string, urlRoute?: string) {
|
||||
// // Element needs to be submitted before confirming the setup intent
|
||||
elements.submit();
|
||||
|
||||
const baseUrl = 'https://cloud.appwrite.io/console/';
|
||||
const baseUrl = 'https://cloud.appwrite.io/console';
|
||||
const accountUrl = `${baseUrl}/account/payments?clientSecret=${clientSecret}`;
|
||||
const orgUrl = `${baseUrl}/organization-${organizationId}/billing?clientSecret=${clientSecret}`;
|
||||
|
||||
const returnUrl = new URL(organizationId ? orgUrl : accountUrl);
|
||||
|
||||
returnUrl.searchParams.append('clientSecret', clientSecret);
|
||||
returnUrl.searchParams.append('paymentMethodId', paymentMethod.$id);
|
||||
|
||||
const { setupIntent, error } = await get(stripe).confirmSetup({
|
||||
elements,
|
||||
clientSecret,
|
||||
confirmParams: {
|
||||
return_url: `${baseUrl}${
|
||||
urlRoute ??
|
||||
`organization-${get(organization).$id}/billing?clientSecret=${clientSecret}`
|
||||
}`,
|
||||
return_url: returnUrl.toString(),
|
||||
payment_method_data: {
|
||||
billing_details: {
|
||||
name
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
{#if hasInstallations}
|
||||
{#await loadInstallations()}
|
||||
<div class="u-flex u-gap-16">
|
||||
<div class="u-width-full-line">
|
||||
<ul class="u-width-full-line">
|
||||
<InputSelect
|
||||
disabled
|
||||
id="installation"
|
||||
@@ -86,7 +86,7 @@
|
||||
}
|
||||
]}
|
||||
value={null} />
|
||||
</div>
|
||||
</ul>
|
||||
<ul class="u-width-full-line">
|
||||
<InputSearch placeholder="Search repositories" disabled />
|
||||
</ul>
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Heading size="1" tag="h3">{$page.error.status || 'Invalid Argument'}</Heading>
|
||||
<Heading size="3" tag="h4">{$page.error.message}</Heading>
|
||||
<Button href="/console">Back to the console</Button>
|
||||
<div class="u-flex-vertical u-gap-16">
|
||||
<Heading size="1" tag="h3">{$page.error.status || 'Invalid Argument'}</Heading>
|
||||
<Heading size="4" tag="h4" trimmed={false}>{$page.error.message}</Heading>
|
||||
<Button href="/console">Back to the console</Button>
|
||||
</div>
|
||||
</Container>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { INTERVAL } from '$lib/constants';
|
||||
import { BillingPlan, INTERVAL } from '$lib/constants';
|
||||
import { Logs } from '$lib/layout';
|
||||
import Footer from '$lib/layout/footer.svelte';
|
||||
import Header from '$lib/layout/header.svelte';
|
||||
@@ -258,12 +258,14 @@
|
||||
organization.subscribe(async (org) => {
|
||||
if (!org) return;
|
||||
if (isCloud) {
|
||||
calculateTrialDay(org);
|
||||
await paymentExpired(org);
|
||||
await checkForUsageLimit(org);
|
||||
checkForMarkedForDeletion(org);
|
||||
await checkPaymentAuthorizationRequired(org);
|
||||
await checkForMandate(org);
|
||||
if (org?.billingPlan !== BillingPlan.STARTER) {
|
||||
calculateTrialDay(org);
|
||||
await paymentExpired(org);
|
||||
await checkPaymentAuthorizationRequired(org);
|
||||
await checkForMandate(org);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,8 +3,19 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import PaymentMethods from './paymentMethods.svelte';
|
||||
import BillingAddress from './billingAddress.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { confirmPayment } from '$lib/stores/stripe';
|
||||
|
||||
let showPayment = false;
|
||||
|
||||
onMount(async () => {
|
||||
if ($page.url.searchParams.has('clientSecret')) {
|
||||
const clientSecret = $page.url.searchParams.get('clientSecret');
|
||||
const paymentMethodId = $page.url.searchParams.get('paymentMethodId');
|
||||
await confirmPayment('', clientSecret, paymentMethodId);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
export let show = false;
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const card = await submitStripeCard(name);
|
||||
const card = await submitStripeCard(name, $page?.params?.organization ?? null);
|
||||
invalidate(Dependencies.PAYMENT_METHODS);
|
||||
dispatch('submit', card);
|
||||
show = false;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
if (!selectedPaymentMethodId) {
|
||||
const method = await submitStripeCard(name);
|
||||
const method = await submitStripeCard(name, $organization.$id);
|
||||
selectedPaymentMethodId = method.$id;
|
||||
}
|
||||
isBackup
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
try {
|
||||
if (paymentMethodId === null) {
|
||||
try {
|
||||
const method = await submitStripeCard(name);
|
||||
const method = await submitStripeCard(name, $organization.$id);
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
|
||||
if (card?.last4) {
|
||||
paymentMethodId = card.$id;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { PaymentBoxes } from '$lib/components/billing';
|
||||
import { addCreditWizardStore } from '../store';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
|
||||
let methods: PaymentList;
|
||||
let name: string;
|
||||
@@ -21,7 +22,7 @@
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const method = await submitStripeCard(name);
|
||||
const method = await submitStripeCard(name, $organization.$id);
|
||||
$addCreditWizardStore.paymentMethodId = method.$id;
|
||||
invalidate(Dependencies.PAYMENT_METHODS);
|
||||
} catch (e) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { createPlatform } from './wizard/store';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { onboarding } from '../../store';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import Step1 from './wizard/android/step1.svelte';
|
||||
import Step2 from './wizard/android/step2.svelte';
|
||||
@@ -12,10 +11,7 @@
|
||||
import Step4 from './wizard/step4.svelte';
|
||||
|
||||
async function onFinish() {
|
||||
await Promise.all([
|
||||
$onboarding && invalidate(Dependencies.PROJECT),
|
||||
invalidate(Dependencies.PLATFORMS)
|
||||
]);
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
createPlatform.reset();
|
||||
wizard.hide();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
import Step3 from './wizard/apple/step3.svelte';
|
||||
import Step4 from './wizard/step4.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { onboarding } from '../../store';
|
||||
|
||||
async function onFinish() {
|
||||
await Promise.all([
|
||||
$onboarding && invalidate(Dependencies.PROJECT),
|
||||
invalidate(Dependencies.PLATFORMS)
|
||||
]);
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
|
||||
createPlatform.reset();
|
||||
wizard.hide();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
import Step3 from './wizard/flutter/step3.svelte';
|
||||
import Step4 from './wizard/step4.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { onboarding } from '../../store';
|
||||
|
||||
async function onFinish() {
|
||||
await Promise.all([
|
||||
$onboarding && invalidate(Dependencies.PROJECT),
|
||||
invalidate(Dependencies.PLATFORMS)
|
||||
]);
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
|
||||
createPlatform.reset();
|
||||
wizard.hide();
|
||||
}
|
||||
|
||||
@@ -9,13 +9,10 @@
|
||||
import Step3 from './wizard/web/step3.svelte';
|
||||
import Step4 from './wizard/step4.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { onboarding } from '../../store';
|
||||
|
||||
async function onFinish() {
|
||||
await Promise.all([
|
||||
$onboarding && invalidate(Dependencies.PROJECT),
|
||||
invalidate(Dependencies.PLATFORMS)
|
||||
]);
|
||||
await Promise.all([invalidate(Dependencies.PROJECT), invalidate(Dependencies.PLATFORMS)]);
|
||||
|
||||
createPlatform.reset();
|
||||
wizard.hide();
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { initializeStripe, isStripeInitialized, submitStripeCard } from '$lib/stores/stripe';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { symmetricDifference } from '$lib/helpers/array';
|
||||
import { showUsageRatesModal } from '$lib/stores/billing';
|
||||
import { PaymentBoxes } from '$lib/components/billing';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let methods: PaymentList;
|
||||
let filteredMethods: PaymentMethodData[];
|
||||
@@ -48,15 +48,10 @@
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await submitStripeCard(name);
|
||||
const latestMethods = await sdk.forConsole.billing.listPaymentMethods();
|
||||
const paymentMethod = symmetricDifference(
|
||||
methods.paymentMethods,
|
||||
latestMethods.paymentMethods
|
||||
)[0] as PaymentMethodData;
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(paymentMethod.$id);
|
||||
const method = await submitStripeCard(name, $page?.params?.organization ?? null);
|
||||
const card = await sdk.forConsole.billing.getPaymentMethod(method.$id);
|
||||
if (card?.last4) {
|
||||
$changeOrganizationTier.paymentMethodId = paymentMethod.$id;
|
||||
$changeOrganizationTier.paymentMethodId = method.$id;
|
||||
} else {
|
||||
throw new Error(
|
||||
'The payment method you selected is not valid. Please select a different one.'
|
||||
|
||||
Reference in New Issue
Block a user