简体   繁体   中英

Braintree: issues with getting client token 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM