【问题标题】:Problem Stripe with with capabilities using NODEJS带有使用 NODEJS 的功能的问题 Stripe
【发布时间】: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


    【解决方案1】:

    在寻找解决方案之后。我在这里的文档中找到: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 :)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-17
      • 1970-01-01
      • 2011-05-24
      • 2021-10-31
      • 1970-01-01
      • 1970-01-01
      • 2017-07-24
      • 1970-01-01
      相关资源
      最近更新 更多