You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Stripe Connected Account搭建市场平台及PaymentIntent创建疑问

Stripe Connect 关联账户支付问题解答

1. 关联账户场景下是否需要传入customer和支付方法参数?

是必须传入的,官方示例为了突出Connect专属参数,省略了普通支付流程的通用参数,并非不需要。
你使用的是Stripe Connect的「先归集再转账」(Destination)模式,开发逻辑和你已掌握的普通PaymentIntent流程几乎完全一致,仅需要额外新增两个Connect专属参数即可:

  • application_fee_amount:你要收取的手续费,以货币最小单位计算,1欧元对应值为100
  • transfer_data.destination:接收剩余款项的卖家关联账户ID
    改造后的可用代码参考:
public function addPaymentCreateIntent(Request $request)
{
    $stripeId = $request->input('stripeId');
    $paymentMethod = PaymentMethod::retrieve($request->input('paymentMethodId'));
    $paymentMethod->attach(['customer' => $stripeId]);
    
    $amount = (int) ($request->input('total')*100);
    // 固定1欧元手续费,单位为欧分
    $platformFee = 100;
    
    $paymentIntent = PaymentIntent::create([
        'amount' => $amount,
        'payment_method' => $paymentMethod['id'],
        'payment_method_types' => ['card'],
        'currency' => 'eur',
        'customer' => $stripeId,
        'metadata' => [
            'user_id' => $request->input('user_id'),
            'last4' => $paymentMethod['card']['last4'],
            'brand' => $paymentMethod['card']['brand'],
        ],
        // 新增Connect专属参数
        'application_fee_amount' => $platformFee,
        'transfer_data' => [
            'destination' => '你的卖家关联账户ID',
        ],
    ], 
    ['idempotency_key' =>  sha1(Carbon::now()) ]);

    return response()->json([
        'paymentIntent' => $paymentIntent,
    ], 200);  
}

后续的支付确认、回调处理逻辑和你原有普通支付流程完全一致,无需额外调整。

2. 为什么网络上很难找到关联账户支付流程的完整示例?

主要有3个原因:

  • Stripe Connect适配的业务场景非常多,对应有Destination、Direct Charge、Separate Charge & Transfer等多种实现模式,不同模式的逻辑差异极大,不存在通用的全流程示例
  • Connect涉及卖家资质审核、跨境合规、税务申报、退款分账规则等大量和业务强绑定的非开发逻辑,多数团队的实现方案都和自身业务规则深度绑定,不会公开对外分享
  • Connect属于Stripe的进阶功能,官方文档和相关教程默认使用者已经掌握普通PaymentIntent的完整开发流程,只会突出Connect专属的差异部分,不会重复编写基础支付的代码示例

内容的提问来源于stack exchange,提问作者gabogabans

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 10:36:04