How does electricity buyback work?

This is often called “net metering” and is available from many utility companies. If you generate more electricity than you use, the excess goes back to your utility company, spinning the meter backward and giving you a credit for the electricity your PV system generated.