Make sure you enable debugging, Make sure the log is being written to (and you've also enabled logging). Then, run a test again and look at the log.
Do i have to use GeneratePK function myself & other function to send email , or WebAPI is doing this for us.
The example does that. But only if you configure everything correctly (including setting the "CheckScript", "BuyPage", and "ThankYouPage" variables to the publicly-accessible locations of the included pages.)