apiKey = $apiKey; } /** @return string|null */ public function getApiKey() { return $this->apiKey; } /** * Save merchant ID. * * @param string $merchantId Merchant UUID. * @throws \InvalidArgumentException If the format is invalid. */ public function saveMerchantId( $merchantId ) { if ( ! self::isValidUuid( $merchantId ) ) { throw new \InvalidArgumentException( 'Invalid merchant ID format. Expected UUID format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' ); } $this->merchantId = $merchantId; } /** @return string|null */ public function getMerchantId() { return $this->merchantId; } /** Clear all stored credentials. */ public function clearCredentials() { $this->apiKey = null; $this->merchantId = null; } /** Check if API key and merchant ID are configured. */ public function isConfigured() { return null !== $this->apiKey && null !== $this->merchantId; } /** Validate API key format. */ public static function isValidApiKey( $apiKey ) { return is_string( $apiKey ) && 1 === preg_match( self::API_KEY_PATTERN, $apiKey ); } /** Validate UUID format. */ public static function isValidUuid( $uuid ) { return is_string( $uuid ) && 1 === preg_match( self::UUID_PATTERN, $uuid ); } }