#mj_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1290654877717893212
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
how are you creating the Connected account? with the API or the OAuth flow?
hi soma, i'm using the embedded components and the sdk
import { env } from '~/env';
const stripe = new Stripe(env.STRIPE_SECRET_KEY!, {
apiVersion: '2024-06-20',
});
export default stripe;
createStripeConnectedAccount: protectedProcedure
.input(z.void())
.mutation(async ({ ctx }) => {
try {
const provider = await ctx.db.provider.findUnique({
where: { userId: ctx.session.user.id },
});
if (!provider || provider.userId !== ctx.session.user.id) {
return { success: false, message: 'Forbidden' };
}
const account = await stripe.accounts.create({
controller: {
stripe_dashboard: {
type: 'none',
},
fees: {
payer: 'application',
},
losses: {
payments: 'application',
},
requirement_collection: 'application',
},
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
},
country: 'US',
});
await ctx.db.provider.update({
where: { id: provider.id },
data: { stripeAccountId: account.id },
});
return { success: true, accountId: account.id };
} catch (error) {
console.error('Error creating Stripe account:', error);
throw error;
}
}),
this is my trpc router procedure. I see correct id being retrieved from my db, passed to hook, i get the instance back but it seems "fresh" instead of continuing the flow of the hanging account it retrieved. So instead of finishing steps i see
Add information to start accepting money
Budget Funeral partners with Stripe to help you receive payments and keep your personal bank and details secure.
and then i hit the stripe Add information button it's not re-logging me into the "hanging" account but rather creating a new one.
your code is calling stripe.accounts.create() which creates a new Stripe account. so only call this code once to make sure you don't create multiple Stripe accounts for the same user.
Please give me 10 minutes to re-test this and get back to you with req_ids for my issue.
I think we can put this request on hold, I think I fixed the issue on my end where I incorrectly allowed user to create new account instead of waiting to retrieve the old one.