douqiao2008 2016-10-14 11:19
浏览 68
已采纳

Braintree:获取客户端令牌ID的问题

I'm trying to connect to Braintree payment system and get the client token ID with the following code:

<script src="https://js.braintreegateway.com/js/braintree-2.29.0.min.js"></script>
<script>
clientToken = <?php echo(Braintree_ClientToken::generate()); ?>;
alert(clientToken);

braintree.setup(clientToken, "dropin", {
  container: "payment-form"
});
</script>

But the code fails to fetch the client token. Please help me to solve this issue.

  • 写回答

1条回答 默认 最新

  • duanli9930 2016-10-14 12:04
    关注

    This will help you to get Client token:

    <script src="https://js.braintreegateway.com/v2/braintree.js"></script>
    <?php
    $clientToken = Braintree_ClientToken::generate(); // generate token
    ?>
    <script>
    clientToken = "<?php echo $clientToken;?>";
    alert(clientToken);
    braintree.setup(clientToken, "dropin", {
      container: "payment-form"
    });
    </script>
    

    You need to use quotes for clientToken in javascript.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 代码问题:df = pd.read_excel('c:\User\18343\Desktop\wpsdata.xlxs')路径读不到
  • ¥15 为什么视频算法现在全是动作识别?
  • ¥15 编写一段matlab代码
  • ¥15 用Python做岩石类别鉴定软件
  • ¥15 关于调取、提交更新数据库记录的问题
  • ¥15 之前删了盘从下vs2022遇见这个问题 搞了一整天了
  • ¥15 从Freecad中宏下载的DesignSPHysics,出现如下问题是什么原因导致的(语言-python)
  • ¥30 notepad++ 自定义代码补全提示
  • ¥15 MATLAB有限差分法解一维边值问题
  • ¥200 内网渗透测试 横向渗透 Windows漏洞 Windows权限维持