Help with cURL Implementation, Instamojo Payment gateway

I will post it, my code isn’t exactly readable though. I will post the proper tutorial if I can to help others. Many of the tutorials on the internet is not free.