问题条纹与使用 NODEJS 的能力
Problem Stripe with with capabilities using NODEJS
我正在尝试将 Stripe 集成到我的 MERN 应用程序中进行测试。我从今天早上开始就有问题了。
raw: {
message: 'You must provide an account with capabilities when creating an account link of type "account_onboarding" for an account in a country that is not enabled for Express. You can enable FR in your Country and Capabilities settings at https://dashboard.stripe.com/settings/applications/express',
param: 'account',
}
我联系了 Stripe 的帮助,但他们帮不了我。他们唯一告诉我的是 select FR 在这里:https://dashboard.stripe.com/settings/applications/express .
问题依旧。没有区别:)
这是我的代码:
try {
// 1. find user from db
const user = await User.findById(req.user._id).exec();
console.log("USER ==> ", user);
// 2. if user don't have stripe_account_id yet, create now
if (!user.stripe_account_id) {
const account = await stripe.accounts.create({
type: "express",
});
console.log("ACCOUNT ===> ", account);
user.stripe_account_id = account.id;
user.save();
}
// 3. create login link based on account id (for frontend to complete onboarding)
let accountLink = await stripe.accountLinks.create({
account: user.stripe_account_id,
refresh_url: process.env.STRIPE_REDIRECT_URL,
return_url: process.env.STRIPE_REDIRECT_URL,
type: "account_onboarding",
});
// prefill any info such as email
accountLink = Object.assign(accountLink, {
"stripe_user[email]": user.email || undefined,
});
// console.log("ACCOUNT LINK", accountLink);
let link = `${accountLink.url}?${queryString.stringify(accountLink)}`;
console.log("LOGIN LINK", link);
res.send(link);
// 4. update payment schedule (optional. default is 2 days
} catch (err) {
console.log("STRIPE ERROR", err);
res.status(400).send("Stripe failed");
}
};
提前感谢您的帮助!
鲁尔丹。
寻找解决方案后。我在这里的文档中找到:https://stripe.com/docs/connect/express-accounts
我只是在 stripe.create.accouts() 中添加国家/地区。
新功能现在看起来像这样:
try {
// 1. find user from db
const user = await User.findById(req.user._id).exec();
// 2. if user dont have stripe_account_id yet, then create new
if (!user.stripe_account_id) {
const account = await stripe.accounts.create({
country: 'FR',
type: 'express',
capabilities: {
card_payments: {
requested: true,
},
transfers: {
requested: true,
},
},
});
// console.log('ACCOUNT => ', account.id)
user.stripe_account_id = account.id;
await user.save();
}
// 3. create account link based on account id (for frontend to complete onboarding)
let accountLink = await stripe.accountLinks.create({
account: user.stripe_account_id,
refresh_url: process.env.STRIPE_REDIRECT_URL,
return_url: process.env.STRIPE_REDIRECT_URL,
type: "account_onboarding",
});
// console.log(accountLink)
// 4. pre-fill any info such as email (optional), then send url resposne to frontend
accountLink = Object.assign(accountLink, {
"stripe_user[email]": user.email,
});
// 5. then send the account link as response to fronend
console.log(accountLink.url)
res.send(`${accountLink.url}?${queryString.stringify(accountLink)}`);
} catch (err) {
console.log("CREATE CONNECT ERR ", err);
}
}; ```
Have a nice day :)
我正在尝试将 Stripe 集成到我的 MERN 应用程序中进行测试。我从今天早上开始就有问题了。
raw: {
message: 'You must provide an account with capabilities when creating an account link of type "account_onboarding" for an account in a country that is not enabled for Express. You can enable FR in your Country and Capabilities settings at https://dashboard.stripe.com/settings/applications/express',
param: 'account',
}
我联系了 Stripe 的帮助,但他们帮不了我。他们唯一告诉我的是 select FR 在这里:https://dashboard.stripe.com/settings/applications/express .
问题依旧。没有区别:)
这是我的代码:
try {
// 1. find user from db
const user = await User.findById(req.user._id).exec();
console.log("USER ==> ", user);
// 2. if user don't have stripe_account_id yet, create now
if (!user.stripe_account_id) {
const account = await stripe.accounts.create({
type: "express",
});
console.log("ACCOUNT ===> ", account);
user.stripe_account_id = account.id;
user.save();
}
// 3. create login link based on account id (for frontend to complete onboarding)
let accountLink = await stripe.accountLinks.create({
account: user.stripe_account_id,
refresh_url: process.env.STRIPE_REDIRECT_URL,
return_url: process.env.STRIPE_REDIRECT_URL,
type: "account_onboarding",
});
// prefill any info such as email
accountLink = Object.assign(accountLink, {
"stripe_user[email]": user.email || undefined,
});
// console.log("ACCOUNT LINK", accountLink);
let link = `${accountLink.url}?${queryString.stringify(accountLink)}`;
console.log("LOGIN LINK", link);
res.send(link);
// 4. update payment schedule (optional. default is 2 days
} catch (err) {
console.log("STRIPE ERROR", err);
res.status(400).send("Stripe failed");
}
};
提前感谢您的帮助!
鲁尔丹。
寻找解决方案后。我在这里的文档中找到:https://stripe.com/docs/connect/express-accounts
我只是在 stripe.create.accouts() 中添加国家/地区。
新功能现在看起来像这样:
try {
// 1. find user from db
const user = await User.findById(req.user._id).exec();
// 2. if user dont have stripe_account_id yet, then create new
if (!user.stripe_account_id) {
const account = await stripe.accounts.create({
country: 'FR',
type: 'express',
capabilities: {
card_payments: {
requested: true,
},
transfers: {
requested: true,
},
},
});
// console.log('ACCOUNT => ', account.id)
user.stripe_account_id = account.id;
await user.save();
}
// 3. create account link based on account id (for frontend to complete onboarding)
let accountLink = await stripe.accountLinks.create({
account: user.stripe_account_id,
refresh_url: process.env.STRIPE_REDIRECT_URL,
return_url: process.env.STRIPE_REDIRECT_URL,
type: "account_onboarding",
});
// console.log(accountLink)
// 4. pre-fill any info such as email (optional), then send url resposne to frontend
accountLink = Object.assign(accountLink, {
"stripe_user[email]": user.email,
});
// 5. then send the account link as response to fronend
console.log(accountLink.url)
res.send(`${accountLink.url}?${queryString.stringify(accountLink)}`);
} catch (err) {
console.log("CREATE CONNECT ERR ", err);
}
}; ```
Have a nice day :)