代码之家  ›  专栏  ›  技术社区  ›  Vicky Gill

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

  •  4
  • Vicky Gill  · 技术社区  · 8 年前

    现在我出错了

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

    上面写着

    需要设置未捕获的异常“Braintree\exception\Configuration”,消息为“Braintree\Configuration::merchantId”(或需要将accessToken传递到Braintree\Gateway)。
    
    2 回复  |  直到 8 年前
        1
  •  2
  •   Lairen    8 年前

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

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

    使用我们的SDK时,您需要 set up your API Credentials appropriately 。您可以通过以下操作找到帐户的API凭据 instructions in our documentation 。我们现在都支持 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
  •  0
  •   Alessandro    6 年前

    我使用Laravel。在我的例子中,问题来自配置文件缓存。出于某些原因,Laravel没有从命令生成配置缓存: php artisan config:cache

    我解决了删除配置缓存的问题:

    php artisan config:clear
    

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

    我希望它有用。

    更新

    我的配置缓存未工作,因为我将 env() helper不在配置文件中,而是在其他文件中(在我的示例中为AppServiceProvider)。 在生产模式中。只能从配置文件调用env参数。。

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