feat: fix account again
This commit is contained in:
parent
8b794be985
commit
ccb9c50894
|
|
@ -21,11 +21,8 @@ export const AddAccount: FC<{ openBankAccount: (country: string) => void }> = (
|
|||
const [country, setCountry] = useState('');
|
||||
return (
|
||||
<div className="bg-sixth p-[32px] text-[20px] w-full max-w-[600px] mx-auto flex flex-col gap-[24px] rounded-[4px] border border-[#172034] relative">
|
||||
Please select your country where your business is registered.
|
||||
Please select your country where your business is.
|
||||
<br />
|
||||
<span className="bg-red-400 text-red-950 font-[600]">
|
||||
THIS IS IRREVERSIBLE.
|
||||
</span>
|
||||
<Select
|
||||
label="Country"
|
||||
name="country"
|
||||
|
|
@ -141,7 +138,7 @@ export const Seller = () => {
|
|||
const { data } = useSWR('/marketplace/account', accountInformation);
|
||||
|
||||
const connectBankAccount = useCallback(async () => {
|
||||
if (!data?.account) {
|
||||
if (!data?.connectedAccount) {
|
||||
modals.openModal({
|
||||
size: '100%',
|
||||
classNames: {
|
||||
|
|
@ -198,7 +195,7 @@ export const Seller = () => {
|
|||
onClick={connectBankAccount}
|
||||
loading={connectedLoading}
|
||||
>
|
||||
{!data?.account
|
||||
{!data?.connectedAccount
|
||||
? 'Connect Bank Account'
|
||||
: 'Update Bank Account'}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export class SubscriptionRepository {
|
|||
},
|
||||
select: {
|
||||
account: true,
|
||||
connectedAccount: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ export class SubscriptionRepository {
|
|||
updateConnectedStatus(account: string, accountCharges: boolean) {
|
||||
return this._user.model.user.updateMany({
|
||||
where: {
|
||||
account
|
||||
account,
|
||||
},
|
||||
data: {
|
||||
connectedAccount: accountCharges,
|
||||
|
|
|
|||
|
|
@ -282,33 +282,31 @@ export class StripeService {
|
|||
}
|
||||
|
||||
async createAccountProcess(userId: string, email: string, country: string) {
|
||||
const account =
|
||||
(await this._subscriptionService.getUserAccount(userId))?.account ||
|
||||
(await this.createAccount(userId, email, country));
|
||||
return { url: await this.addBankAccount(account) };
|
||||
const account = await this._subscriptionService.getUserAccount(userId);
|
||||
|
||||
if (account?.account && account?.connectedAccount) {
|
||||
return { url: await this.addBankAccount(account.account) };
|
||||
}
|
||||
|
||||
if (account?.account && !account?.connectedAccount) {
|
||||
await stripe.accounts.del(account.account);
|
||||
}
|
||||
|
||||
const createAccount = await this.createAccount(userId, email, country);
|
||||
|
||||
return { url: await this.addBankAccount(createAccount) };
|
||||
}
|
||||
|
||||
async createAccount(userId: string, email: string, country: string) {
|
||||
const account = await stripe.accounts.create({
|
||||
type: 'custom',
|
||||
// controller: {
|
||||
// stripe_dashboard: {
|
||||
// type: 'express',
|
||||
// },
|
||||
// fees: {
|
||||
// payer: 'application',
|
||||
// },
|
||||
// losses: {
|
||||
// payments: 'application',
|
||||
// },
|
||||
// },
|
||||
capabilities: {
|
||||
transfers: {
|
||||
requested: true,
|
||||
},
|
||||
card_payments: {
|
||||
requested: true,
|
||||
},
|
||||
},
|
||||
tos_acceptance: {
|
||||
service_agreement: 'recipient',
|
||||
},
|
||||
metadata: {
|
||||
service: 'gitroom',
|
||||
|
|
|
|||
Loading…
Reference in New Issue