stripe default_source 和 default_payment_method 之间的区别是什么?

huangapple go评论61阅读模式
英文:

What's the difference between stripe default_source and default_payment_method?

问题

我正在使用以下代码将卡片设为默认值:

if ($form_state['input']['default'] == TRUE) {
    // 将当前卡片设为默认值。
    try {
        $stripe->customers->update(
            $customer['id'],
            ['invoice_settings' => ['default_payment_method' => $card['id']]]
        );
    } catch (\Stripe\Exception\InvalidRequestException $e) {
        watchdog('store', $e->getMessage(), array(), WATCHDOG_ERROR);
    }
}

因为根据https://stripe.com/docs/api/payment_methods/attach和https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method文档的建议,应使用default_payment_method参数。

它可以正常工作,正确标记$customer['invoice_settings']['default_payment_method']数组值。

然而,当我通过Stripe界面添加新卡片时,$customer['default_source']会默默地标记它。

所以我想知道它们之间有什么区别,哪一个更好使用?如果default_source是过时的旧参数,那么为什么Stripe自己的UI仍在使用它?

2023年1月10日更新:除了接受的答案外,这是Stripe支持的更新:

stripe default_source 和 default_payment_method 之间的区别是什么?

英文:

I'm using the following code to make a card default:

 if ($form_state['input']['default'] == TRUE) {
      // Set the current card as default.
      try {
        $stripe->customers->update(
          $customer['id'],
          ['invoice_settings' => ['default_payment_method' => $card['id']]]
        );
      } catch (\Stripe\Exception\InvalidRequestException $e) {
        watchdog('store', $e->getMessage(), array(), WATCHDOG_ERROR);
      }
    }

because per documentation on https://stripe.com/docs/api/payment_methods/attach and https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method, it's advised to use the default_payment_method parameter.

And it works fine marking properly the $customer['invoice_settings']['default_payment_method'] array value.

However, when I add a new card via Stripe UI, then $customer['default_source'] gets silently marked for it.

So I wonder what's the difference between them and which one is preferable to use? If the default_source is a outdated legacy parameter, then why Stripe's own UI keeps using it?

UPDATE of January 10, 2023: In addition to the accepted answer, here is the update from Stripe support on the subject matter:

stripe default_source 和 default_payment_method 之间的区别是什么?

答案1

得分: 1

invoice_settings.default_payment_method 是建议设置的参数,用于设置客户的默认付款方式。default_source 是旧版参数。

英文:

invoice_settings.default_payment_method is the recommended parameter to be set for setting up the default payment method of a customer. default_source is the legacy parameter.

huangapple
  • 本文由 发表于 2023年1月9日 11:58:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053062.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定