config = $config; $this->objectManager = $objectManager; } /** * Creates instance of Braintree Adapter. * * @param int|null $storeId if null is provided as an argument, then current scope will be resolved * by \Magento\Framework\App\Config\ScopeCodeResolver (useful for most cases) but for adminhtml area the store * should be provided as the argument for correct config settings loading. * @return BraintreeAdapter */ public function create($storeId = null) { return $this->objectManager->create( BraintreeAdapter::class, [ 'merchantId' => $this->config->getMerchantId($storeId), 'publicKey' => $this->config->getValue(Config::KEY_PUBLIC_KEY, $storeId), 'privateKey' => $this->config->getValue(Config::KEY_PRIVATE_KEY, $storeId), 'environment' => $this->config->getEnvironment($storeId), ] ); } }