Got caught by the RPF for a crime I didn't commit

Today I got busted by a RPF officer while I was on my way to meet someone. I was booked under section 156 (Travelling on roof, step or engine of a train) in the Railway Act of 1989. Truth to be told, I was waiting by the door to deboard the train when this random RPF officer entered the carriage and escorted 15-20 people out, including me. We were taken to the nearest RPF office and then made to listen to a half-an-hour lecture on the dangers involved before directly asking us to pay the penalty. We were given a choice to pay the penalty right away or pay it directly at court, either way I didn't have the money on me. Since I was already late to meeting this person, I made an excuse that I had a doctor's appointment and left the station. I was made to submit my phone inorder to guarantee that I'd return back with the money. Fast forward few hours, I returned back to the station and told the officer that I needed my phone back and that I didn't have the money to pay the penalty. Ofc he started to lose his shit, so I patiently explained him that I was only waiting to deboard the train when the RPF officer busted me which doesn't necessarily put me at fault. The officer then asked me to wait for another half-an-hour hour until the officer who booked me returned back. One-and-a-half hour later, I was sent to another officer since the other one didn't show up. He asked me what was the purpose of my doctor's visit and told him that I was mentally depressed. Mf started to mock at my illness and continued to judge me based on my appearance and attire. He then straight up went ahead and called me a liar for faking my illness and not bringing the money that I promised (which I didn't). I quietly listened to his shit and finally told him that I can't pay the penalty for a crime that I didn't commit. He then labelled me as "arrogant" and demanded that I pay the penalty inorder to retrieve my phone. I stood stubborn until he got tired of my shit and made me write a letter (in his words) to the head of the station explaining that I was booked for travelling on footboard and since I had a doctor's appointment today, I will appear at the court tomorrow. He made me sign that letter and let me go home warning that I'll get a 15 days remand if I didn't show up at the court tomorrow. Now, I'm home and confused not knowing how to proceed as I don't know much about the law and court functions. My mobile is still with the officer and I'm typing this from my dad's phone. He also mentioned that I will have to pay ₹500 inorder to start a case which is exactly the amount that I have to pay as penalty, but sure as hell I didn't buy it. Is it true that I would have to pay ₹500 inorder to start a new case in court? What are the best options I've got here? Little background info: I'm 19 and I don't have a lawyer. I'm also afraid that there's a high chance that they might use the letter against me as a confession to 'Standing by the door'.