I had some issues with PayPal too, albeit not with this sample. I used nodejs. This library works fine, you might want to compare notes with the one you are using and see if you find any difference. (The endpoints are certainly different). See here specifically.