#theproofficial
1 messages · Page 1 of 1 (latest)
Hi there, so what's the key issue that you want to resolve? avoid duplicate account creation?
Exactly.
https://stripe.com/docs/api/idempotent_requests#idempotent_requests you should use Idempotent Requests then
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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.
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
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
You didn't specify email in the account creation request https://admin.corp.stripe.com/request-log/req_kTYzf9TQasWX53 and that's why this account doesn't have an email.
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 });```
- I create account to get accountID
- I create account link with that accountID
I'd suggest you to put some logs in your code to print out the email that you pass to stripe.accounts.create function
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?
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.
req_STFXOs47v6yPTJ has the email
But req_kTYzf9TQasWX53 doesn't, isn't this the problem that you want to solve?
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
That's why I suggest you to put some logs in your program to find out
- why the code executed twice
- why the emial is missing in the request
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?
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.
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.
It is the "identity document" that is not requested during onboarding at least in test mode