【问题标题】:Braintree - paymentMethodNonceReceived not being invokedBraintree - paymentMethodNonceReceived 未被调用
【发布时间】:2015-03-20 00:27:03
【问题描述】:

我已经为 Braintree 设置了 dropin UI。我可以看到 UI 很好。在此之前,我创建了客户,我可以在 Braintree-sandbox 上看到客户。现在我想向客户添加付款方式。我正在尝试以下代码,但没有调用 paymentMethodNonceReceived。不知道为什么。

braintree.setup("<?=CLIENT_TOKEN_FROM_PHP?>", 
    "dropin", 
    {
      container: "divBrainTreeContainer",
      paymentMethodNonceReceived: function (event, nonce) {
        console.log(nonce);
        $('#formProfile').append('<input type="hidden" name="payment_method_nonce" value="'+nonce+'" />');
        $('#formProfile').submit();
      }
    }
);

【问题讨论】:

  • 我在 Braintree 的 SDK 团队工作。 divBraintTreeContainer 元素内是否有 form 元素?如果是这样,form 是否包含提交按钮?
  • 好的@kdetella,谢谢,没有提交按钮,我是通过javascript提交的,但是当我添加提交按钮时,我得到了payment_method_nonce。
  • @kdetella 这个关于提交按钮的事实在插入式 UI 页面或 Hello, Client 页面上的任何地方都没有显示。在某处添加它会很棒,因为我也被这个难住了!它不会阻止自定义 UI 上出现随机数。
  • @kdetella 我会谦虚地建议将此添加到您的文档中,因为我只花了半天时间试图弄清楚为什么从未调用过回调。不过,更一般地说,形式已成为过去。我不得不挖掘有关提交按钮标记的外观的信息。另外,我更希望有一个我可以调用的函数来启动付款并在完成后给我回电。

标签: javascript php payment-gateway braintree


【解决方案1】:

我正在使用以下 JavaScript 及其工作正常

  braintree.setup(clientToken, "custom", {
    id: "my-sample-form",
    hostedFields: {
      number: {
        selector: "#card-number"
      },
      cvv: {
        selector: "#cvv"
      },
      expirationMonth: {
        selector: "#expiration-month"
      },
      expirationYear: {
        selector: "#expiration-year"
      },
    },onPaymentMethodReceived:function(nonce){
        console.log(JSON.stringify(nonce));
        return false;

  }
    }

          ); 

以上给出了以下回复并且不提交表单:

{"nonce":"ff2662e1-f1fd-42a3-a16f-d8f3213a2406","details":{"lastTwo":"11","cardType":"Visa"},"type":"CreditCard"}

表示使用 onPaymentMethodReceived 而不是 paymentMethodNonceReceived

谢谢 http://www.web-technology-experts-notes.in/2015/06/braintree-payment-gateway-integration.html

【讨论】:

  • 我正在使用带有 js 的 Braintree,我在容器中提到的 div id 中添加了提交按钮,但我仍然无法获取 nonce,而是得到 Uncaught Error: Could not stringify event : JSON.stringify 不是一个函数。请帮忙
【解决方案2】:

根据@kdetella 的评论,&lt;form&gt; 元素内应该有一个submit 按钮来接收付款方式随机数。

【讨论】:

  • 我正在使用带有 js 的 Braintree,我在容器中提到的 div id 中添加了提交按钮,但我仍然无法获取 nonce,而是得到 Uncaught Error: Could not stringify event : JSON.stringify 不是函数
【解决方案3】:

https://github.com/braintree/braintree-web/issues/58

对于与多种支付方式的自定义集成,请使用 onSuccess 而不是 onPaymentMethodReceived。

braintree.setup(TOKEN, 'custom', {
  id: 'checkout',
  paypal: {
    container: 'paypal-container',
    onSuccess: function (nonce, email) {
      // This will be called as soon as the user completes the PayPal flow
      // nonce:String
      // email: String
    }
  },
  onPaymentMethodReceived: function(obj) {
    // This will be called when the user submits the form
  }
});

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-12-06
  • 1970-01-01
  • 2019-03-06
  • 1970-01-01
  • 1970-01-01
  • 2019-02-07
  • 2016-05-21
  • 2012-02-15
相关资源
最近更新 更多