繁体   English   中英

需要设置Braintree\Configuration::merchantId(或者需要将accessToken传给Braintree\Gateway)

[英]Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway)

现在我得到了错误

Uncaught exception 'Braintree\Exception\Configuration' with message 'Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway).

问题是,如果我的商户 ID 不是它创建子商户的方式,因为我可以在我的仪表板中看到子商户帐户,但我将调用此方法:

$webhookNotification = Braintree\WebhookNotification::parse($sampleNotification['bt_signature'], $sampleNotification['bt_payload']);

它说

Uncaught exception 'Braintree\Exception\Configuration' with message 'Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway).

全面披露:我在布伦特里工作。 如果您有任何其他问题,请随时联系[support][support]

商家 ID是所有 Braintree API 调用所需的 API 凭据,连同公钥和私钥。 您可以在没有商户 ID 的情况下在仪表板中看到子商户,因为我们的系统将您登录仪表板视为有效身份验证,而不是依赖于 API 凭据。

使用我们的 SDK 时,您需要适当地设置 API 凭据 您可以按照我们文档中的说明找到您帐户的 API 凭据。 我们现在支持类级别和实例方法

类级别示例

Braintree_Configuration::environment('sandbox');
Braintree_Configuration::merchantId('use_your_merchant_id');
Braintree_Configuration::publicKey('use_your_public_key');
Braintree_Configuration::privateKey('use_your_private_key');

实例方法示例

$gateway = new Braintree_Gateway([
    'environment' => 'sandbox',
    'merchantId' => 'use_your_merchant_id',
    'publicKey' => 'use_your_public_key',
    'privateKey' => 'use_your_private_key'
]);

我使用 Laravel。 就我而言,问题出在配置文件缓存中。 出于某种原因,Laravel 不会从命令生成配置缓存: php artisan config:cache

我解决了删除配置缓存:

php artisan config:clear

但在我的案例中,真正的问题是 Laravel 配置缓存生成。

我希望它有用。

更新

我的配置缓存不起作用,因为我没有将env()助手放在配置文件中,而是放在其他文件中(在我的例子中:AppServiceProvider)。 在生产模式下,.env 参数只能从配置文件中调用。

如果在部署期间使用 config:cache 命令,则必须确保仅从配置文件中调用 env 函数,而不是从应用程序的其他任何地方调用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM