This uses PayPal's SOAP API in a similar manner to other parts of this API. I adapted this about a year ago to provide these functions, basing it on code from other parts of the API.