For decades, military aircraft have carried defenses against heat seeking missiles. These systems consist of special cameras (that detect heat as well as images and movement) and computers that spot the tell-tale heat and movement of an oncoming heat-seeking missile. The system then (either automatically or under pilot control) dispenses flares or uses a laser or searchlight "gun" (in a turret) to deceive the heat sensor on the nose of the missile about where the aircraft really is. The flares have been around for decades, the laser or high intensity searchlight in a small, computer controlled, turret is a more recent development. If the systems are bought in large quantities (over a thousand) you can get the price down to about one or two million dollars. This is for a system using the newer laser based countermeasure, where a third of the total cost is for the detection system (two to six small cameras and a computer to figure out if it's a real attack and command the countermeasures to act) and two thirds is the cost of the laser and the ball turret it operates from. Using the older flare systems, the cost is about a third less, and the detection and countermeasures system cost about the same.
The laser systems have not had much use in actual combat yet, but have been tested extensively by equipping an unpiloted drone (usually an old F-4 fighter) with the system, and then firing many different types of heat seeking missiles at it. The most common air-to-air missiles are heat seekers and these defensive systems can stop those missiles as well. It's a reasonable bet that the new laser countermeasures systems will work. There are a number of advantages to using the laser based systems (which use other forms of controlled light as well). Most modern surface-to-air missiles are designed to recognize flares, and ignore them. Laser systems don't have to be reloaded, and can be reprogrammed to defeat "smarter" computers installed in new heat seeking missiles. Lasers are also not a fire danger, like flares.
These defensive systems add 200-400 pounds of weight to an aircraft.
Airliners are more expensive to equip with these missile defense systems, because more cameras are needed and the expense of modifying the aircraft to install is great (anytime you modify a commercial aircraft, lots of engineers and government officials are involved.) The cost per aircraft can be as much as four million dollars.