I believe karma exists. Maybe it is an existential justice system, maybe not. It isn’t necessarily instant and may take a long time, but it happens. The rub is that you may never know it happens where you were wronged and are hoping for karmic retribution.
So what can you do to be on the right side of karma? Be intentional in a positive way. This means to be intentional and positive in what you do, what you say and how you act. There is a difference between generosity and compassion as compared with cruelty or greed.
One idea is to be nice. You can’t do it all of the time, but only you control your mood and actions. And people appreciate dealing with nice people. Another thing you can do is to do the right thing. It makes a difference to others and will make you feel better about yourself.
This is about character and how you want to live your life. It may affect how you are viewed by others, but that shouldn’t be the focus; you should want to be a good person just because. There is truth in the statement that you get what you put out into the world. What do you want to get??