英文:
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支持的更新:
英文:
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:
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论