I am working on Braintree for the first time and getting problems at the first stage. I canβt access dropin functions and others .. I need help to figure it out.
I followed these steps: https://developers.braintreepayments.com/javascript+php/start/overview
The first step is the Javascript Client! - I followed, as already mentioned, added a script
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
Then the HTML part is added.
<form id="checkout" method="post" action="/checkout"> <div id="dropin"></div> <input type="submit" value="Pay $10"> </form>
And finally I added below script in the script tag.
braintree.setup("CLIENT_TOKEN_KEY", 'dropin', { container: 'checkout' })
I checked the Token client key received from our server.
for the next step, I added the configurations mentioned
Braintree_Configuration::environment('sandbox'); Braintree_Configuration::merchantId('use_your_merchant_id'); //updated with our merchant id Braintree_Configuration::publicKey('use_your_public_key'); // updated with our public key Braintree_Configuration::privateKey('use_your_private_key'); //updated with our private key
then added
$clientToken = Braintree_ClientToken::generate(array( "customerId" => $aCustomerId ));
Now the problems that I get -
When I updated $ aCustomerId with our customer ID, I had a fatal error in the field "customer_id" undefined in Braintree_ClientToken. Thus, the remote array ("client" => $ aCustomerId) received the client token.
This client token is used in brantree.setup('TOKEN_KEY','dropin',{container:'checkout'}) and received
Error: Unable to find valid container. -braintree.js(line 18)
I also once mentioned var braintree = Braintree.create("CLIENT_TOKEN_KEY"); above brantree.setup('TOKEN_KEY','dropin',{container:'checkout'}) , while I have TypeError: braintree.setup is not a function
Iβm trying to figure this out from the last two days, but still I havenβt got a dropin screen as shown in the demo.
Hope for good help.