#theproofficial

1 messages · Page 1 of 1 (latest)

viscid pathBOT
finite gale
#

Hi there, so what's the key issue that you want to resolve? avoid duplicate account creation?

finite gale
amber scroll
#

I think the problem is elsewhere, if you look at the code, I am creating an account link based on the stripeaccountID, but the final product ends up with a new accountID and without the email, so it's almost like it ignores that original accountID and all it's information.

finite gale
amber scroll
#

req_STFXOs47v6yPTJ acc1
req_kTYzf9TQasWX53 acc2
req_V9u8oX6DKbR4Rr acc1
req_ZpJTMhYbwRKGPk acc2

2 accounts, acc1 has the email, acc2 has all the other data

#

acc2 is the one actually being used it seems

finite gale
amber scroll
#

But I am not even creating another account, I am just creating an account link for the existing account, check the code: ```// If the user doesn't have a connected Stripe account, create one for them
if (!user.connectedStripeAccountId) {
const account = await stripe.accounts.create({
type: "express",
capabilities: {
card_payments: { requested: true },
transfers: { requested: true },
},
email: user.email,

        // Add additional details for the account, if needed
      });

      user.connectedStripeAccountId = account.id;
      await user.save();

      // Create an Account Link for the user
      const accountLink = await stripe.accountLinks.create({
        account: user.connectedStripeAccountId,
        refresh_url: `${process.env.NEXTAUTH_URL}/api/stripe/refresh-account-link?accountId=${user.connectedStripeAccountId}`,
        return_url: `${process.env.NEXTAUTH_URL}/balance`,
        type: "account_onboarding",
      });

      // Store the account link URL in your database or use it on the front-end to redirect the user
      const accountLinkUrl = accountLink.url;

      // Return the account link URL to the front-end so the user can be redirected to the setup process
      res.status(200).json({ accountLinkUrl });```
#
  1. I create account to get accountID
#
  1. I create account link with that accountID
finite gale
#

I'd suggest you to put some logs in your code to print out the email that you pass to stripe.accounts.create function

amber scroll
#

I am not sure how that would help, could you please let me in on your reasoning?

#

Account 1 already uses the correct email, Account 2 has none

#

But account 2 is the one presumably created by the accountlink?

finite gale
#

Based on the logs that you shared, that request doesn't include an email. If you expect an email to be included, you should print it out in the log to verify.

amber scroll
#

req_STFXOs47v6yPTJ has the email

finite gale
#

But req_kTYzf9TQasWX53 doesn't, isn't this the problem that you want to solve?

amber scroll
#

Well my problem is that somehow I have 2 accounts and one has the email and the other one has all the other data but no email

#

ideally just get rid of the one with the email and perhaps assign the email to the other one

finite gale
#

That's why I suggest you to put some logs in your program to find out

  1. why the code executed twice
  2. why the emial is missing in the request
amber scroll
#

Weird, I just added logs and now it doesn't create two accounts.

#

One request, and it has the email: req_xcSjtXUtW55wbZ

#

This kind of confuses me even more, I will have to retry a few times.

#

Okay, I do not know how to reproduce it.

#

I have one more question though.

#

I just tested the whole creation and so on, and after the account is created and setup (through the stripe onboarding), it still says "restricted soon" on the accounts page. Is there a way to ensure that the user inputs all the necessary data on the first onboarding, so he doesn't have to go in to do it manually? Or is it only in test-mode that it's not required in the onboarding, and in live mode it would be requested?

finite gale
#

Regardless of live or test mode, your user need to provide necessary information for onboaridng. You can check the account's requirements hash for the needed information.

amber scroll
#

I found the original problem with the 2 accounts, not sure about "restricted soon" bug since it is kind of rare, but thanks for the help.

amber scroll