Home arrow Web Services arrow Page 3 - Automated Billing and Faxing for the Web
WEB SERVICES

Automated Billing and Faxing for the Web


If you do a lot of payment processing through PayPal, you can save some serious time by automating the process. This article will show you how. It is excerpted from chapter six of the book Real World Web Services, written by Will Iverson (O'Reilly; ISBN: 059600642X). Copyright © 2006 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

Author Info:
By: O'Reilly Media
Rating: 5 stars5 stars5 stars5 stars5 stars / 6
August 23, 2007
TABLE OF CONTENTS:
  1. · Automated Billing and Faxing for the Web
  2. · Starting the Transaction
  3. · Getting a Transaction Notification
  4. · Getting a Transaction Notification continued
  5. · Responding to the Transaction

print this article
SEARCH DEVARTICLES

Automated Billing and Faxing for the Web - Getting a Transaction Notification
(Page 3 of 5 )

When an order is processed, PayPal generates a notification that is then posted to the URL specified in the form as the hidden field notify_url. This is an example of a web service that relies on ordinary HTTP—no fancy SOAP or other RPC underpinnings. 

Using a simple HTTP request/response is perhaps the most basic, universal real world web service. It works with virtually every programming language and requires no special configuration to use. It’s a classic case of the simple solution being the best solution.

Example 6-2 shows the JSP used to receive notifications from the PayPal server.

Example 6-2. Notification JSP

<%@ page contentType="text/html; charset=iso-8859-1"
language="java" import="com.cascadetg.ch06.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/ xhtml1/DTD/xhtml1-transitional.dtd">
<%
new PayPalReciept().handleRequest(request, response);
response.setStatus(200);
%>

The lineresponse.setStatus(200)notifies PayPal that the notification has successfully been handled. By default, PayPal resends the notification until it gets a status code of200back, indicating that the transmission was successful. Disabling this line or substituting a different response code is an easy way to generate additional test load for your server without having to manually enter a lot of transactions.

The bulk of the work for this application is handled by supporting Java classes, as shown in Figure 6-5.

The first class, shown in Example 6-3, exposes one main method,handleRequest(), to the JSP page. In thehandleRequest()method, the first thing to be done is verify that the data sent by PayPal is correct with theverifyRequest()method. TheverifyRequest() method retrieves the parameters sent by PayPal and then posts


Figure 6-5.  PayPal and Fax classes

them back to PayPal via an HTTPS connection, with an additional parameter added (cmd=_notify-validate).


blog comments powered by Disqus
WEB SERVICES ARTICLES

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials