【问题标题】:Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway)Braintree\Configuration::merchantId 需要设置(或者 accessToken 需要传递给 Braintree\Gateway)
【发布时间】:2018-08-23 23:13:46
【问题描述】:

现在我出错了

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).

【问题讨论】:

    标签: php paypal braintree braintree-sandbox


    【解决方案1】:

    全面披露:我在 Braintree 工作。如果您还有其他问题,请随时联系 [支持][支持]

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

    使用我们的 SDK 时,您需要set up your API Credentials appropriately。您可以通过instructions in our documentation 找到您帐户的 API 凭证。我们现在支持class level and instance methods

    类级别示例

    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'
    ]);
    

    【讨论】:

    • 即使付款方式被禁用并且您没有使用它,您也会收到此错误,这很糟糕。
    【解决方案2】:

    我使用 Laravel。就我而言,问题来自配置文件缓存。由于某种原因,Laravel 没有从命令生成配置缓存: php artisan config:cache.

    我解决了删除配置缓存:

    php artisan config:clear
    

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

    希望对你有用。

    更新

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-08
      • 2018-05-12
      • 1970-01-01
      • 2015-11-14
      • 2015-06-01
      • 2022-09-23
      • 1970-01-01
      • 2019-10-12
      相关资源
      最近更新 更多