【发布时间】:2021-08-27 06:30:46
【问题描述】:
我正在尝试将 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 的帮助,但他们无法帮助我。他们唯一告诉我的是在这里选择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");
}
};
提前感谢您的帮助!
鲁尔丹。
【问题讨论】:
标签: node.js express stripe-payments