【问题标题】:Stripe Connect Express account refreshURL and returnURL are undefinedStripe Connect Express 帐户 refreshURL 和 returnURL 未定义
【发布时间】:2021-06-28 04:13:42
【问题描述】:

我正在使用 Stripe Connect Express(新用户,关注 STRIPE API DOCS)。我目前正在尝试在成功创建 Stripe Express 帐户后创建 AccountLink。

但是,我无法创建 AccountLink,因为在创建 AccountLink 时出现错误,因为 account.refresh_urlaccount.return_url 似乎是 undefined

exports.onCreateAuthUser = functions.auth.user().onCreate(async (user) => {
    // Set your secret key. Remember to switch to your live secret key in production.
    // See your keys here: https://dashboard.stripe.com/account/apikeys
    const strip = require('stripe')('sk_test_key_input_here');

    const account = await strip.accounts.create({
      type: 'express',
    });

    let refURL = account.refresh_url
    let retURL = account.return_url

    console.log("account log stuff -->", account, retURL, refURL, account.uid, account.userId, account.userRef, account.user, account.id, account.ref, account.pushId, account.customer_id)

    const accountLinks = await stripe.accountLinks.create({
       account: account.id,
       refresh_url: refURL,
       return_url: retURL,
       type: 'account_onboarding',
     });

 });

console.log 打印:

account log stuff --> undefined undefined undefined undefined undefined acct_1IbJSgPMwPhmaSsD undefined undefined undefined 

有谁知道为什么这些属性是未定义的......以及我可以如何修复它或有什么问题?

【问题讨论】:

    标签: api stripe-payments


    【解决方案1】:

    返回和刷新 URL 不是 Stripe 生成的 URL,它们是您提供给 Stripe 的 URL, 这样它们就可以将您的用户重定向到您的网站。

    return_url 是 Stripe 在用户完成入职流程后重定向的位置。

    至于refresh_url

    如果帐户链接已过期、以前曾访问过或无效,用户将被重定向到的 URL。您指定的 URL 应尝试使用用于创建原始帐户链接的相同参数生成新帐户链接,然后将用户重定向到新帐户链接的 URL,以便他们可以继续 Connect Onboarding。如果无法生成新帐户链接或重定向失败,您应该向用户显示有用的错误。

    https://stripe.com/docs/api/account_links/create#create_account_link-refresh_url

    【讨论】:

    • 我在哪里可以获得我提供给 Stripe 的 URL?
    • 这取决于您来实施/解决。它可能应该是您网站上的着陆页的 URL。
    猜你喜欢
    • 2021-03-30
    • 1970-01-01
    • 2020-06-21
    • 2020-11-06
    • 2017-12-16
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    相关资源
    最近更新 更多