Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/app/Resources/Account/AccountResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ public function toArray(Request $request): array
'currency_code' => $this->getCurrencyCode(),
'timezone' => $this->getTimezone(),
'updated_at' => $this->getUpdatedAt(),
'stripe_connect_setup_complete' => $this->getStripeConnectSetupComplete(),

'is_account_email_confirmed' => $this->getAccountVerifiedAt() !== null,
'is_saas_mode_enabled' => config('app.saas_mode_enabled'),

$this->mergeWhen(config('app.saas_mode_enabled'), [
'stripe_account_id' => $this->getStripeAccountId(),
'stripe_connect_setup_complete' => $this->getStripeConnectSetupComplete(),
]),
$this->mergeWhen($this->getConfiguration() !== null, fn() => [
'configuration' => new AccountConfigurationResource($this->getConfiguration()),
]),
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/layouts/Event/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const EventLayout = () => {
</NavLink>
);
});

const handleStatusToggle = () => {
const message = event?.status === 'LIVE'
? t`Are you sure you want to make this event draft? This will make the event invisible to the public`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {useCreateOrGetStripeConnectDetails} from "../../../../../../queries/useC
import {useGetAccount} from "../../../../../../queries/useGetAccount.ts";
import {LoadingMask} from "../../../../../common/LoadingMask";
import {Anchor, Button, Grid, Group, Text, ThemeIcon, Title} from "@mantine/core";
import {StripeConnectDetails} from "../../../../../../types.ts";
import {Account} from "../../../../../../types.ts";
import paymentClasses from "./PaymentSettings.module.scss";
import classes from "../../ManageAccount.module.scss";
import {useEffect, useState} from "react";
import {IconAlertCircle, IconBrandStripe, IconCheck, IconExternalLink} from '@tabler/icons-react';
import {formatCurrency} from "../../../../../../utilites/currency.ts";
import {showSuccess} from "../../../../../../utilites/notifications.tsx";

interface FeePlanDisplayProps {
configuration?: {
Expand Down Expand Up @@ -45,26 +46,30 @@ const FeePlanDisplay = ({configuration}: FeePlanDisplayProps) => {
<Card variant={'lightGray'}>
<Title order={4}>{configuration.name}</Title>
<Grid>
<Grid.Col span={{base: 12, sm: 6}}>
<Group gap="xs" wrap={'nowrap'}>
<Text size="sm">
{t`Transaction Fee:`}{' '}
<Text span fw={600}>
{formatPercentage(configuration.application_fees.percentage)}
{configuration.application_fees.percentage > 0 && (
<Grid.Col span={{base: 12, sm: 6}}>
<Group gap="xs" wrap={'nowrap'}>
<Text size="sm">
{t`Transaction Fee:`}{' '}
<Text span fw={600}>
{formatPercentage(configuration.application_fees.percentage)}
</Text>
</Text>
</Text>
</Group>
</Grid.Col>
<Grid.Col span={{base: 12, sm: 6}}>
<Group gap="xs" wrap={'nowrap'}>
<Text size="sm">
{t`Fixed Fee:`}{' '}
<Text span fw={600}>
{formatCurrency(configuration.application_fees.fixed)}
</Group>
</Grid.Col>
)}
{configuration.application_fees.fixed > 0 && (
<Grid.Col span={{base: 12, sm: 6}}>
<Group gap="xs" wrap={'nowrap'}>
<Text size="sm">
{t`Fixed Fee:`}{' '}
<Text span fw={600}>
{formatCurrency(configuration.application_fees.fixed)}
</Text>
</Text>
</Text>
</Group>
</Grid.Col>
</Group>
</Grid.Col>
)}
</Grid>
</Card>

Expand All @@ -79,8 +84,16 @@ const FeePlanDisplay = ({configuration}: FeePlanDisplayProps) => {
);
};

const ConnectStatus = (props: { stripeDetails: StripeConnectDetails }) => {
const ConnectStatus = ({account}: { account: Account }) => {
const [fetchStripeDetails, setFetchStripeDetails] = useState(false);
const [isReturningFromStripe, setIsReturningFromStripe] = useState(false);
const stripeDetailsQuery = useCreateOrGetStripeConnectDetails(
account.id,
!!account?.stripe_account_id || fetchStripeDetails
);

const stripeDetails = stripeDetailsQuery.data;
const error = stripeDetailsQuery.error as any;

useEffect(() => {
if (typeof window === 'undefined') {
Expand All @@ -91,11 +104,40 @@ const ConnectStatus = (props: { stripeDetails: StripeConnectDetails }) => {
);
}, []);

useEffect(() => {
if (fetchStripeDetails && !stripeDetailsQuery.isLoading) {
setFetchStripeDetails(false);
showSuccess(t`Redirecting to Stripe...`);
window.location.href = String(stripeDetails?.connect_url);
}

}, [fetchStripeDetails, stripeDetailsQuery.isFetched]);

if (error?.response?.status === 403) {
return (
<>
<Card className={classes.tabContent}>
<div className={paymentClasses.stripeInfo}>
<Group gap="xs" mb="md">
<ThemeIcon size="lg" radius="md" variant="light">
<IconAlertCircle size={20}/>
</ThemeIcon>
<Title order={2}>{t`Access Denied`}</Title>
</Group>
<Text size="md">
{error?.response?.data?.message}
</Text>
</div>
</Card>
</>
);
}

return (
<div className={paymentClasses.stripeInfo}>
<Title mb={10} order={3}>{t`Payment Processing`}</Title>

{props.stripeDetails?.is_connect_setup_complete ? (
{stripeDetails?.is_connect_setup_complete ? (
<>
<Group gap="xs" mb="md">
<ThemeIcon size="sm" variant="light" radius="xl" color="green">
Expand Down Expand Up @@ -145,12 +187,19 @@ const ConnectStatus = (props: { stripeDetails: StripeConnectDetails }) => {
size="sm"
leftSection={<IconBrandStripe size={20}/>}
onClick={() => {
if (typeof window !== 'undefined')
window.location.href = String(props.stripeDetails?.connect_url);
if (!stripeDetails) {
setFetchStripeDetails(true);
return;
} else {
if (typeof window !== 'undefined') {
showSuccess(t`Redirecting to Stripe...`);
window.location.href = String(stripeDetails?.connect_url)
}
}
}}
>
{(!isReturningFromStripe) && t`Connect with Stripe`}
{(isReturningFromStripe) && t`Complete Stripe Setup`}
{(!isReturningFromStripe && !account?.stripe_account_id) && t`Connect with Stripe`}
{(isReturningFromStripe || account?.stripe_account_id) && t`Complete Stripe Setup`}
</Button>
<Group gap="xs">
<Anchor
Expand Down Expand Up @@ -184,29 +233,6 @@ const ConnectStatus = (props: { stripeDetails: StripeConnectDetails }) => {

const PaymentSettings = () => {
const accountQuery = useGetAccount();
const stripeDetailsQuery = useCreateOrGetStripeConnectDetails(accountQuery.data?.id);
const stripeDetails = stripeDetailsQuery.data;
const error = stripeDetailsQuery.error as any;

if (error?.response?.status === 403) {
return (
<>
<Card className={classes.tabContent}>
<div className={paymentClasses.stripeInfo}>
<Group gap="xs" mb="md">
<ThemeIcon size="lg" radius="md" variant="light">
<IconAlertCircle size={20}/>
</ThemeIcon>
<Title order={2}>{t`Access Denied`}</Title>
</Group>
<Text size="md">
{error?.response?.data?.message}
</Text>
</div>
</Card>
</>
);
}

return (
<>
Expand All @@ -216,10 +242,12 @@ const PaymentSettings = () => {
/>
<Card className={classes.tabContent}>
<LoadingMask/>
{(accountQuery.data?.configuration || stripeDetails) && (
{(accountQuery.data?.configuration) && (
<Grid gutter="xl">
<Grid.Col span={{base: 12, md: 6}}>
{stripeDetails && <ConnectStatus stripeDetails={stripeDetails}/>}
{accountQuery.isFetched && (
<ConnectStatus account={accountQuery.data}/>
)}
</Grid.Col>
<Grid.Col span={{base: 12, md: 6}}>
{accountQuery.data?.configuration && (
Expand Down
Loading
Loading