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

时间:2016-10-14 11:19:50

标签: javascript php braintree

我正在尝试连接到Braintree支付系统并使用以下代码获取客户端令牌ID:

<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>

但代码无法获取客户端令牌。请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

这将帮助您获取客户端令牌:

<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>

您需要在javascript中使用clientToken的引号。