#warre002-connect-node

1 messages ยท Page 1 of 1 (latest)

autumn flame
#

Hello ๐Ÿ‘‹
Can you share the example code and the guide you're following for this?

gloomy burrow
#

This is my code```

// Creates an account on Stripe with the already known data
async function createAccountID(land_code, email){
const account = await stripe.accounts.create({
country: land_code,
type: 'custom',
email: email,
capabilities: {
card_payments: {
requested: true
},
transfers: {
requested: true
},
},
});

return account

}

async function createAccountLink(stripe_id){
const accountLink = await stripe.accountLinks.create({
account: stripe_id,
refresh_url: 'http://localhost:4000/payments/reauth?stripe_id='+stripe_id, // This should redirect to the server with the stripe_id in the link as a parameter. The api generates the new link
return_url: 'http://localhost:4000/payments/return', // redirects back to the server and should redirect to the stripe url
type: 'account_onboarding',
});

return accountLink

}

router.get("", CheckJWT, async (req,res) => {
const land_code = req.body.land_code
const email = req.body.email

if(land_code, email){
    const accountId = await createAccountID(land_code, email)
    const accountLink = await createAccountLink(accountId.id)
    res.json({success: true, link: accountLink.url})
} else {
    res.json({success: false, message: "Provide your land code and email."})
}  

})

#

Could the problem be that you've to set redirect pages in stripe?

autumn flame
#

are you seeing any network request failing in your console? or any error messages?

gloomy burrow
#

no

#

I will see again just to be sure

#

sorry, I found the problem

autumn flame
#

ah nice, what was it?

gloomy burrow
#

Well just a stupid mistake, I wasn't returning anything on the page it was redirecting to.

#

Sorry for wasting a bit of your time.

autumn flame
#

NP! ๐Ÿ™‚ Glad you're unblocked