I'm using Braintree with Ruby and JS to try and do a basic implementation of the Braintree Drop-In UI.
Here are some relevant code snippets:
Transactions Controller Creating The Token
@client_token = Braintree::ClientToken
Page Initializing The Token
<script>
braintree.setup(“<%= @client_token %>”, 'dropin', {
container: 'checkout'
});
</script>
And for some reason I end up with the decrypted version of the token. Output looks like this:
{"version":1,"authorizationFingerprint":"9802dc7676997d457eb5c656470227a27828f15b12ec4acd3c2cec67782a3001|created_at=2015-03-23T04:29:28.438506721+0000\u0026merchant_id=8gtvngmjy6tmsxz4\u0026public_key=6rp8nrfbvmyfqjf8","configUrl":"
https://api.sandbox.braintreegateway.com:443/merchants/8gtvngmjy6tmsxz4/client_api/v1/configuration
","challenges":["cvv"],"clientApiUrl":"
https://api.sandbox.braintreegateway.com:443/merchants/8gtvngmjy6tmsxz4/client_api
","assetsUrl":"https://assets.braintreegateway.com","authUrl":"
https://auth.venmo.sandbox.braintreegateway.com","analytics":{"url":"
https://client-analytics.sandbox.braintreegateway.com
"},"threeDSecureEnabled":true,"threeDSecure":{"lookupUrl":"
https://api.sandbox.braintreegateway.com:443/merchants/8gtvngmjy6tmsxz4/three_d_secure/lookup
"},"paypalEnabled":true,"paypal":{"displayName":"None","clientId":null,"privacyUrl":"
http://example.com/pp","userAgreementUrl":"http://example.com/tos
","baseUrl":"https://assets.braintreegateway.com","assetsUrl":"
https://checkout.paypal.com
","directBaseUrl":null,"allowHttp":true,"environmentNoNetwork":true,"environment":"offline","unvettedMerchant":false,"braintreeClientId":"masterclient","merchantAccountId":"gbsgnv46xscgk868","currencyIsoCode":"USD"},"coinbaseEnabled":false}"
And that is certainly not what the Client Token should look like.
Why am I ending up with the decrypted version?
It looks like that is an old version of the client token. Upgrading the gem version will provide you with an encoded client token instead of json.