I am developing a game using cocos2d-x and I want to port it to Windows phone 8 as well as Android.
I plan to make the game free with in app purchases. But I do not yet know how to do that in windows phone 8 with cocos2d-x.
Has anyone else tried to do it before and succeeded with WP8?
Currently working on a project that will do that Cocos-2d-x running on Win8 and WinRT. Haven't gotten to the in-app purchase part yet, so don't take this as gospel, but my initial research indicates that it'll need to go through the XAML layer.
The trick isn't the In-App Purchase itself, as Microsoft seem to have the API for that fairly well covered; the trick is getting your Cocos2d-x modules communicating with the XAML layer. Unfortunately, currently nobody has made a good interface between the two, so you'll have to make your own. I'm not looking forward to that myself either.
I assume you need something now. What I can do is point you toward some resources that will help.
In-App Purchase in a Native C++ App: Windows Phone Dev Center