使用 Braintree 插件 UI 到 select 定期计费的支付方式——或者:找到 paymentMethodNonce 的支付方式

Using the Braintree drop-in UI to select the payment method for recurring billing -- or: finding the payment method of a paymentMethodNonce

我正在使用 Braintree 支付构建一个简单的支付系统,PHP 和 JavaScript。我正在使用 Braintree 的 Drop-in UI,并希望创建订阅(即定期计费)。

为此,我使用:

// $_customer is a Braintree_Customer object; a customer stored in the Vault
$subscription_create = Braintree_Subscription::create([
  'id' => $_customer->id,
  'planId' => 'some_package',
  'paymentMethodToken' => $_customer->defaultPaymentMethod()->token
]);

这很好用,并使用客户的 'default payment method' 创建订阅。但是,我看不到客户可以更改其默认付款方式的任何方式。在 UI.

中似乎没有这个选项

这是否意味着我不能使用 drop-in UI 进行定期计费?我应该自己编写 UI 以允许客户更改他们的默认付款方式吗?


There is a way 将付款方式设置为默认付款方式。我可以使用那个,但是,我只从客户那里收到一个 paymentMethodNonce。我如何找到链接到该随机数的 paymentMethod?

我在布伦特里工作。如果有更多问题,可以随时get in touch with our support team.

你不需要特殊的方法,你可以pass the nonce directly to Braintree_PaymentMethod::create:

$result = Braintree_PaymentMethod::create(array(
    'customerId' => '12345',
    'paymentMethodNonce' => 'nonce-from-the-client'
));