简体   繁体   English

使用Braintree插入式用户界面选择定期结算的付款方式 - 或:查找paymentMethodNonce的付款方式

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

I'm building a simple payment system using Braintree payments, PHP and JavaScript. 我正在使用Braintree支付,PHP和JavaScript构建一个简单的支付系统。 I'm using Braintree's Drop-in UI, and would like to create subscriptions (ie recurring billing). 我正在使用Braintree的Drop-in UI,并且想要创建订阅(即定期计费)。

For this, I'm using: 为此,我正在使用:

// $_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
]);

This works fine, and creates a subscription using the customer's 'default payment method'. 这样可以正常工作,并使用客户的“默认付款方式”创建订阅。 However, I don't see any way for the customer to change his default payment method. 但是,我认为客户无法更改其默认付款方式。 There does not seem to be an option for this in the drop-in UI. 在Drop-in UI中似乎没有这个选项。

Does this mean I cannot use the drop-in UI for recurring billing? 这是否意味着我无法使用Drop-in UI进行定期结算? Should I write my own UI to allow customers to change their default payment method? 我应该编写自己的UI以允许客户更改其默认付款方式吗?


There is a way to make a payment method the default one. 有一种方法可以将付款方式设为默认付款方式。 I could use that one, however, I only receive a paymentMethodNonce from the client. 我可以使用那个,但是,我只从客户端收到paymentMethodNonce。 How do I find the paymentMethod linked to that nonce? 如何找到与该nonce链接的paymentMethod?

I work at Braintree. 我在布伦特里工作。 If you have more questions, you can always get in touch with our support team . 如果您有更多问题,可以随时与我们的支持团队联系

You don't need a special method for this, you can pass the nonce directly to Braintree_PaymentMethod::create : 你不需要一个特殊的方法,你可以将nonce直接传递给Braintree_PaymentMethod::create

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM