While there are many different types of web services and modes of integrating them into anything, many services these days are integrated with similar steps. Since you posed the question in abstract form, I'll offer an abstracted answer — maybe it'll trigger further questions.
I'll use payments as an example.
User does something on a machine (orders a t-shirt).
Their actions update a database, session, or some sort of storage (or chain of actions).
If appropriate, one of the results of the users action (1) will also trigger the system to push content to a web service (like PayPal). Often formatting in XML, you'll send a response with nested parameters. Your store would send the t-shirt price and quantity.
The service receives the XML request (often containing an 'API Key' or such) and processes it. In PayPal's case after the user completes the t-shirt order, it will redirect you back to your own website, along with order information. (synchronous)
The service optionally completes processing (or performing some asynchronous action) and then sends an XML request to your server. You parse the request in PHP and then process the data. For instance, the request may have a property like 'order_status'
. The property could contain 'complete','pending', 'failed'
. You could then use PHP to update your database to reflect this.
Your web site reflects the changes made to the database by the service to the user. For instance, information on an 'Order Status' or 'Recent Orders' page.
There are nice libraries and many previously created PHP classes for many different web services. You could even try searching GitHub. And: UPS, PayPal, Google Checkout, Facebook, and many others have examples and API documentation to write your own implementations if you so desire/require.
Edit: PayPal-specific information
When PayPal sends the (asynchronous) IPN response, it is in POST data, which you can read and validate according to their specs.
The easiest way I found to handle IPN (to avoid the tinker time) is Micah Carrick's PayPal class. I disliked the naming and wanted to polish the waiting screen (just in case), you can see my changes on this gist.