Help writing a plugin to track user purchase and post back that using API?


I am writing a plugin to track user purchase and post back that using API.

First the user visit a third party listing site and logs in.
Then he clicks the listing and visits a wordpress store with this plugin.
I need to store that user info for 30 days.
In that window period if he makes purchase i will pay commission to the third party listing site.

Can you suggest any code examples or free and paid plugins to look at.