我们可以更新 braintree 订阅的付款方式吗?

Can we update payment method for braintree subscription?

我是 braintree 的新手。我们可以将付款方式更新为现有订阅吗?他们有什么办法可以更新付款方式。所以 用户可以更改他们的订阅卡吗? 根据 braintree 文档,这会起作用吗?

$result = $gateway->subscription()->update('old_subscription_id', [ 'id' => 'old_subscription_id', 'paymentMethodToken' => 'new_payment_method_token' ]);

完全公开,我在 Braintree 工作。如果您有任何其他问题,请联系 Support

您可以更新现有订阅以使用存储在您的 Vault. You can do this with an existing payment method, or by creating a new payment method with a paymentMethod()->create() API 请求中的任何其他付款方式。

话虽如此,您提供的请求可能有效,但我建议不要包含 id 参数,因为它是为设置新的订阅 ID 保留的。您希望编辑的订阅 ID 将放在第一个参数中,正如您在代码中所包含的那样。您可以简化请求,使其看起来更像这样:

$result = $gateway->subscription()->update('old_subscription_id', [
    'paymentMethodToken' => 'new_payment_method_token'
]);