Modifing an API to take PayPal notifications, locate a Post by Tag ID and flip Published to Pending

Hey,
Have some pretty good research done, now I need some expertise...
Have a chunk of code that reads the return info from PayPal...
Now I have to get it to retrieve a Post by TagID
Once located I want to flip the Published status to Pending Review on that one Post.

I know the commands -- looked them up... but I've never created an API before.

Here's what I do have -- If this is your cup of tea -- we should talk!!
OK, couldn't post it without it getting scrambled... so see the attached screenshot!

Thanks!
Robert