Stripe支付:来源 vs 令牌/卡?

28

我正在使用Stripe设置定期付款。 我正在使用react-stripe-elements收集信用卡信息,看起来有两种方法可以保存卡片以便日后使用:

  • this.props.stripe.createToken()
  • this.props.stripe.createSource()

然后在后端创建客户:

  • stripe.customers.create({ source: tokenId })
  • stripe.customers.create({ source: sourceId })

结果在Stripe仪表板中显示如下:

  • tokenId

    • tokenId卡片 enter image description here
  • sourceId

    • sourceId来源

enter image description here

  • sourceId卡片

enter image description here

我的问题是这两种模式的区别是什么?我应该使用其中一种吗?我注意到在 tokenId 模式中,卡片显示了 cvc/zip 检查已通过,而在 sourceId 模式中,卡片并没有显示。但是,sourceId 模式还明确表示卡片可以充值和重复使用,这是否意味着使用 tokenId 模式保存的卡片不可重复使用?sourceId 卡片中的日志/事件更有用吗?两种模式的返回对象结构也不同。

如果能得到任何帮助,将不胜感激,提前致谢!

2个回答

18

令牌(Token)是对用户卡片细节进行标记化处理后生成的字符串值,您可以将其用于一次性或订阅付款(前提是附加到客户之前不要立即使用它来收费)。

但是源(Source)选项提供了更多选择,因为当接受其他支付方式(如支付宝或微信支付等)时,它是您唯一的选项,除了银行卡以外,其他支付方式都无法使用令牌API。正如@Daniel Winterstein所说,令牌是Stripe旧版API,Stripe决定保留它只是为了向后兼容,但您应该使用源(Source)作为捕获用户付款详细信息的标准API。


8
Token是API的旧部分--现在没有理由使用它,因为Source可以完成Token的所有功能并且更多。 - Daniel Winterstein
@DanielWinterstein 仍然有许多使用令牌的原因。想象一下,第三方 PCI-DSS 可以访问您的 Stripe 帐户,但只能使用受限 API 密钥。他们向您发送一个令牌,您可以在不必成为 PCI-DSS 的情况下进行收费。此外,卡片也可以用于定期收费。 - Mazzy
“Charging a reusable source without doing so” 是什么意思? - Mazzy
@Mazzy,抱歉让你感到困惑,但我已经更正了我的答案,希望现在你能理解。 - kasongoyo

0

对于 Laravel,这个方法适用于我。

$stripe = new \Stripe\StripeClient(env('STRIPE_SECRET'));

            $stripe->paymentIntents->create(
            [
                "amount" => 100 * $request->amount,
                "currency" => "usd",
                "description" => orgName() . ' ' . $request->plan_name .' subscription plan payment'
            ]
        );

        $stripe->customers->create(
            [
                'name' => $request->name,
                'address' => [
                'line1' => 'Delhi',
                'postal_code' => '110001',
                'city' => 'Delhi',
                'state' => 'DL',
                'country' => 'IN',
                ],
            ]
        );

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接