/** * Initializes environment. This function can be called more than once with different storeId * * @param int $storeId * @return $this */ public function initEnvironment($storeId) { if ($this->getConfigData('environment', $storeId) == \Magento\Braintree\Model\Source\Environment::ENVIRONMENT_PRODUCTION) { $this->braintreeConfiguration->environment(\Magento\Braintree\Model\Source\Environment::ENVIRONMENT_PRODUCTION); } else { $this->braintreeConfiguration->environment(\Magento\Braintree\Model\Source\Environment::ENVIRONMENT_SANDBOX); } $this->braintreeConfiguration->merchantId($this->getConfigData(self::KEY_MERCHANT_ID, $storeId)); $this->braintreeConfiguration->publicKey($this->getConfigData(self::KEY_PUBLIC_KEY, $storeId)); $this->braintreeConfiguration->privateKey($this->getConfigData(self::KEY_PRIVATE_KEY, $storeId)); $this->merchantAccountId = $this->getConfigData(self::KEY_MERCHANT_ACCOUNT_ID, $storeId); $this->storeId = $storeId; //Need to set clientToken to null after initialization $this->clientToken = null; return $this; }