我正在使用braintree rails dropin,只有我的第一笔交易成功反映在沙箱管理员中。我注意到每次调用时在控制器上生成的客户端令牌都是相同的。这是一个错误还是应该每次生成相同的令牌。我没有在文档中看到有关此问题的任何内容。
答案 0 :(得分:1)
完全披露:我在Braintree工作。如果您有任何其他问题,请随时联系support。
每次调用Braintree API时,客户端令牌都是唯一的。如果没有生成代码或示例令牌,则无法确认或解决此问题。但我怀疑这并没有真正发生。我怀疑你可能会看到它几乎完全一样。您可以在irb
:
?> irb
2.2.3p173 :001 > require 'braintree'
2.2.3p173 :002 > Braintree::Configuration.environment = :sandbox
2.2.3p173 :003 > Braintree::Configuration.merchant_id = 'yourid'
2.2.3p173 :004 > Braintree::Configuration.public_key = 'yourpubkey'
2.2.3p173 :005 > Braintree::Configuration.private_key = 'yourprivkey'
2.2.3p173 :006 > Braintree::ClientToken.generate().hash
I, [2016-05-12T16:38:15.694941 #14251] INFO -- : [Braintree] [12/May/2016 16:38:15 UTC] POST /merchants/yourid/client_token 201
=> -108931568589167346
2.2.3p173 :007 > Braintree::ClientToken.generate().hash
I, [2016-05-12T16:38:16.616599 #14251] INFO -- : [Braintree] [12/May/2016 16:38:16 UTC] POST /merchants/yourid/client_token 201
=> -816324802974143833
客户端令牌是一团数据,as the documentation says包含客户端初始化客户端SDK以与Braintree通信所需的所有授权和配置信息。在引擎盖下,您可以看到当前客户端令牌是base-64编码数据类型,其中包含一串Json。如果您看到authorizationFingerprint
:
2.2.3p173 :015 > require 'base64'
2.2.3p173 :018 > Base64.decode64(Braintree::ClientToken.generate())
I, [2016-05-12T16:39:32.974157 #14251] INFO -- : [Braintree] [12/May/2016 16:39:32 UTC] POST /merchants/yxcm2pqnmw2jwsgn/client_token 201
=> "{\"version\":2,\"authorizationFingerprint\":\"5845e00458d7e9b963c3490946432997b154e12345e7918001289edddd453d1b|created_at=2016-05-12T16:39:32.853698588+0000\\u0026merchant_id=yourid\\u0026public_key=dqgrxzv8f4syj95m\",\"configUrl\":\"https://api.sandbox.braintreegateway.com:443/merchants/yxcm2pqnmw2jwsgn/client_api/v1/configuration\",\"challenges\":[\"cvv\"],\"environment\":\"sandbox\",\"clientApiUrl\":\"https://api.sandbox.braintreegateway.com:443/merchants/yourid/client_api\",\"assetsUrl\":\"https://assets.braintreegateway.com\",\"authUrl\":\"https://auth.venmo.sandbox.braintreegateway.com\",\"analytics\":{\"url\":\"https://client-analytics.sandbox.braintreegateway.com/yxcm2pqnmw2jwsgn\"},\"threeDSecureEnabled\":true,\"paypalEnabled\":true,\"paypal\":{\"displayName\":\"Your company name\",\"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\":\"masterclient3\",\"billingAgreementsEnabled\":false,\"merchantAccountId\":\"somemerchantaccountid\",\"currencyIsoCode\":\"USD\"},\"coinbaseEnabled\":false,\"merchantId\":\"yourid\",\"venmo\":\"off\"}"
2.2.3p173 :019 > Base64.decode64(Braintree::ClientToken.generate())
I, [2016-05-12T16:40:05.758760 #14251] INFO -- : [Braintree] [12/May/2016 16:40:05 UTC] POST /merchants/yxcm2pqnmw2jwsgn/client_token 201
=> "{\"version\":2,\"authorizationFingerprint\":\"c68a6c2ce2becb3gdfe6e9c9d2f4bd65b912cc2b6a7980971231974ea37dd625|created_at=2016-05-12T16:40:05.605145848+0000\\u0026merchant_id=yourid\\u0026public_key=yourpubkey\",\"configUrl\":\"https://api.sandbox.braintreegateway.com:443/merchants/yourid/client_api/v1/configuration\",\"challenges\":[\"cvv\"],\"environment\":\"sandbox\",\"clientApiUrl\":\"https://api.sandbox.braintreegateway.com:443/merchants/yxcm2pqnmw2jwsgn/client_api\",\"assetsUrl\":\"https://assets.braintreegateway.com\",\"authUrl\":\"https://auth.venmo.sandbox.braintreegateway.com\",\"analytics\":{\"url\":\"https://client-analytics.sandbox.braintreegateway.com/yxcm2pqnmw2jwsgn\"},\"threeDSecureEnabled\":true,\"paypalEnabled\":true,\"paypal\":{\"displayName\":\"Your company name\",\"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\":\"masterclient3\",\"billingAgreementsEnabled\":false,\"merchantAccountId\":\"somemerchantaccountid\",\"currencyIsoCode\":\"USD\"},\"coinbaseEnabled\":false,\"merchantId\":\"yourid\",\"venmo\":\"off\"}"
如果您没有看到不同的authorizationFingerprints
,我会立即与Braintree Support联系。