0

我正在使用braintree rails dropin,只有我的第一笔交易成功反映在沙盒管理员中。我注意到每次调用时在控制器上生成的客户端令牌都是相同的。这是一个错误还是应该每次都生成相同的令牌。我在文档中没有看到有关此问题的任何内容。

4

1 回答 1

1

全面披露:我在布伦特里工作。如果您还有其他问题,请随时联系支持人员

对于 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

客户端令牌是一个数据块,如文档所述,包含客户端初始化客户端 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 支持

于 2016-05-12T19:04:52.887 回答