【问题标题】:Stripe - Create Checkout Session with Stripe ConnectStripe - 使用 Stripe Connect 创建结帐会话
【发布时间】:2021-06-24 03:25:29
【问题描述】:

我正在尝试使用以下逻辑为未经身份验证的客户实施结帐程序:

  1. 收集客户电子邮件

  2. 使用以下逻辑生成 Stripe 客户:

    const customer = await stripe.customers
     .create({
         email,
         name,
     })
     .then((customer) => customer)
     .catch((error) => {
         console.log(error);
         return null;
     });
    
  3. 创建令牌以将帐户传递给我的 Stripe Connect 业务合作伙伴帐户。

    const tempCustomerToken = await stripe.tokens.create(
             {
                 customer: customerAccId,
             },
             {
                 stripeAccount: vendorStripeAcc,
             }
         );
    
  4. 根据业务伙伴的账户创建客户。

    const tempCustomer = await stripe.customers.create(
             {
                 source: tempCustomerToken.id,
             },
             {
                 stripeAccount: vendorStripeAcc,
             }
         );
    
  5. 使用业务合作伙伴账户中的客户 ID 创建结帐会话。

    const session = await stripe.checkout.sessions.create(
             {
                 payment_method_types: ['card', 'alipay'],
                 customer: tempCustomer.id,
                 line_items: items,
                 success_url: 'https://example.com/success',
                 cancel_url: 'https://example.com/cancel',
                 payment_intent_data: {
                     application_fee_amount: 50
                 },
             },
             {
                 stripeAccount: vendorStripeAcc,
             }
         );
    

第 2 步失败并出现此错误 - The customer must have an active payment source attached.

但是,我希望客户在 Stripe Checkout 会话期间提供他们的付款方式,因此当我创建客户时,我不想向他们询问任何付款信息。

有没有办法实现以下目标:

  1. 在我的 Stripe 账户上使用电子邮件和无付款方式创建 Stripe 客户。
  2. 将此客户分享给 Stripe Connect 业务合作伙伴。
  3. 允许客户使用Stripe Checkout 会话在Stripe Connect 业务供应商帐户上进行direct 购买。

【问题讨论】:

    标签: javascript node.js stripe-payments


    【解决方案1】:

    您所描述的流程用于您希望在平台帐户上拥有一个客户和一张卡,然后在连接的帐户上复制该卡以接受一次性付款。这个想法是,作为一个平台,您可以收集一次卡的详细信息,并且可以代表第三方供应商接受未来的付款。

    当您执行此操作时,平台中的客户和关联帐户上的客户不会以任何方式关联或关联。它们只是 2 个独立的对象,您可以克隆一次卡片以避免再次收集卡片详细信息。

    在您的示例中,尽管您没有卡片,也不想收集卡片。这意味着没有理由在平台帐户上创建客户或尝试在连接的帐户上克隆它。您似乎只想接受已连接帐户的付款。

    您应该完全跳过所有步骤,而只需在连接的帐户上创建一个结帐会话。在您完成结帐时,它会收集卡详细信息、接受付款并在关联的帐户上为您创建一个客户,以保存卡详细信息以供将来付款。

    您将无法在平台上使用该客户,也无法在其卡上使用该客户,但 Stripe Connect 的构建方式预计会出现该部分。

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 2021-03-30
      • 1970-01-01
      • 2020-09-30
      • 1970-01-01
      • 2021-12-24
      • 2021-07-13
      • 1970-01-01
      • 2022-01-01
      相关资源
      最近更新 更多