Skip to content

Instantly share code, notes, and snippets.

@braintreeps
Last active October 28, 2019 21:24
Show Gist options
  • Save braintreeps/8bf7d6f17d6c3c34c0352d3e3f451cdd to your computer and use it in GitHub Desktop.
Save braintreeps/8bf7d6f17d6c3c34c0352d3e3f451cdd to your computer and use it in GitHub Desktop.
Deferred Client Code Snippet 1
<!-- add both the client script and the hosted fields script to the page -->
<script src="https://js.braintreegateway.com/web/3.55.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.55.0/js/hosted-fields.min.js"></script>
<script>
// create the client instance using a client token or tokenization key
braintree.client.create({
authorization: 'client_token_or_tokenization_key'
}, function (clientErr, clientInstance) {
// pass the client instance into the Hosted Fields create method
braintree.hostedFields.create({
client: clientInstance,
// the rest of the Hosted Fields configuration goes here
}, function (hostedFieldsErr, hostedFieldsInstance) {
// finish by adding event listeners to trigger tokenization requests on a button click
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment