Chosen Solution

Been a while ago, my all electrical devices burnt because power surge that I lived, fortunately I repaired all devices except magsafe 2 45 watt, I replaced all broken power components of magsafe 2 (capacitor, varistor, fuse and inductor) then I connected 39k ohm resistor to output pins (0.6v without connecting 39k ohm) and I saw 15v on output, It worked technically and charged my MacBook as well but sometimes light turns off suddenly and charging stops, after unplugging cable and plugging it again, It starts charging again but not for long, I can’t estimate what’s wrong with it, thanks in advance.

Here’s one system I serviced a few years ago

Clearly the DC-In Board needed replacing as it was to far gone from a knockoff charger.

Use a cotton swab (Q-Tip) with some 75 % or better isopropyl alcohol and if needed use a fresh (soft) pink pencil eraser to polish the contact surface rolling it in your fingers as you press down. Make sure the white insulated area is also clean as the piled up junk can mess up the ability of the contacts to make a good connection. Use a cotton swab (Q-Tip) with a bit of kitchen cleaner to get rid of the junk Here’s more on knockoff chargers: Don’t Replace Your MacBook Charger With a Cheap KnockoffOEM MagSafe Chargers vs Cheap Imposters: Teardown for TruthLacking safety features, cheap MacBook chargers create big sparksFAKE Magsafe MacBook Chargers on eBay - Watch before buying a Mac Charger

Try resetting the SMC on the computer. Sometimes the SMC can affect the MagSafe charger. Hold the shift, control, option, and power buttons for 10 seconds then see if that fixed your problem. If it didn’t, I would get a new MagSafe adapter.