【问题标题】:Braintree - Why is only the default card being used for starting a subscription?Braintree - 为什么只有默认卡用于开始订阅?
【发布时间】:2021-06-29 13:23:33
【问题描述】:

我正在尝试了解如何为用户提供一个选项,让他们为其订阅选择非默认付款方式/卡。请看下图: 我有两张卡。 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
         })

感谢您的帮助!

【问题讨论】:

    标签: python django braintree


    【解决方案1】:

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

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

    【讨论】:

    • 如何从客户端获取支付方式token? @Pavlo.P
    • 付款方式令牌可以保存在您的服务器中并从那里获取。但是从 Drop-in 没有办法做到这一点。可以加check isPaymentMethodRequestable,见:developer.paypal.com/braintree/docs/guides/drop-in/…
    【解决方案2】:

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

    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

    【讨论】:

      猜你喜欢
      • 2019-03-01
      • 2018-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-25
      • 2014-03-04
      • 2021-06-26
      • 2016-07-31
      相关资源
      最近更新 更多