I am working with braintree paypal checkout function, i found jquery code for that, i need to place Braintree Sandbox Auth Key in jquery variable, i created account in braintree, i tried all that code, but in jquery console log it says authrization failed, can anyone please help me where can i find that code ? Here is my sameple code
<!DOCTYPE html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script src="https://js.braintreegateway.com/web/3.11.0/js/client.min.js"></script>
<script src="https://js.braintreegateway.com/web/3.11.0/js/paypal-checkout.min.js"></script>
</head>
<body>
<div id="paypal-button-container"></div>
<script>
var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk';
// Render the PayPal button
paypal.Button.render({
// Pass in the Braintree SDK
braintree: braintree,
// Pass in your Braintree authorization key
client: {
sandbox: BRAINTREE_SANDBOX_AUTH,
production: '<insert production auth key>'
},
// Set your environment
env: 'sandbox', // sandbox | production
// Wait for the PayPal button to be clicked
payment: function(data, actions) {
// Make a call to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1', currency: 'USD' }
}
]
}
});
},
// Wait for the payment to be authorized by the customer
onAuthorize: function(data, actions) {
// Call your server with data.nonce to finalize the payment
console.log('Braintree nonce:', data.nonce);
// Get the payment and buyer details
return actions.payment.get().then(function(payment) {
console.log('Payment details:', payment);
});
}
}, '#paypal-button-container');
</script>
</body>
I need to place code in this variable var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk';
can anyone help me to resolve this issue ?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact [email protected].
It looks like you are setting your
BRAINTREE_SANDBOX_AUTH
variable to a Merchant ID, rather than a Client Token. In order to initiate the Braintree checkout, you will need to generate, then pass in aclient_token
.You generate the
client_token
on your server, then pass it into your client-side call:braintree.client.create()
.If successful,
braintree.client.create()
will return a client instance that you can use to create a PayPal checkout component withbraintree.paypalCheckout.create()
.Within the paypalCheckout component, you can configure your PayPal button using
paypal.Button.render()
.