Braintree - 为什么只有默认卡用于启动订阅?

Braintree - Why is only the default card being used for starting a subscription?

我正在尝试了解如何为用户提供选择非默认付款方式/卡进行订阅的选项。请看下图:我有两张卡片。 Visa 是默认的支付卡。但如果用户选择万事达卡(非默认),则仅使用默认付款方式开始订阅。

我正在使用付款随机数来开始订阅。客户保存在不同的视图中,并且他们的付款方式得到验证。

客户端:

  let paymentNonce;
  initiateDropin().then((dropinInstance) => {
    dropinInstance.requestPaymentMethod(function (error, payload) {
      paymentNonce = payload.nonce;
    });
  });

服务器端:

result = braintree_gateway.subscription.create({
           'payment_method_nonce': payment_nonce,
           'plan_id': tier_chosen,
           'merchant_account_id': settings.BRAINTREE_MERCHANT_ACCOUNT_ID
         })

感谢您的帮助!

根据 braintree 文档,最好使用 payment_method_token 进行订阅创建请求。描述了可以使用 payment_method_nonce 的特定情况:

https://developer.paypal.com/braintree/docs/reference/request/subscription/create#payment_method_nonce

我明白了。我的客户端代码需要进行一些重组。单击“确认”按钮后调用请求付款方式功能。这创建了一个对应于非默认卡的随机数。

braintree.dropin
  .create({
    authorization: braintreeClientToken,
    container: '#braintree_dropin',
  })
  .then(function (dropinInstance) {
    document
      .getElementById('confirm_button')
      .addEventListener('click', function () {
        dropinInstance.requestPaymentMethod().then(function (payload) {
          let paymentNonce = payload.nonce;
  })

这已记录在案 here