Home arrow Web Services arrow Page 2 - Automated Billing and Faxing for the Web

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
  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

Automated Billing and Faxing for the Web - Starting the Transaction
(Page 2 of 5 )

To kick our example off, lets start with a simple HTML page that will initiate our transaction, as shown in Figure 6-3.

Figure 6-3.  Initial payment screen

It's not the world's most sophisticated marketing page, but it does the job and is easy to understand. The HTML for this simple page is shown in Example 6-1.

Example 6-1. Payment initialization form

<%@ page contentType="text/html; charset=iso-8859-1"
language="java" import="com.cascadetg.ch06.*" %>
<HEAD><title>ch06 : Simple Money Sender</title>
<link href="../../ch04/www/default.css"
rel="stylesheet" type="text/css">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
       <p><strong>ch06: Simple Money Sender</strong></p>
      <input type="hidden" name="cmd" value="_xclick">
      <input type="hidden" name="business"
      <input type="hidden" name="item_name" value="IPN Test">
      <input type="hidden" name="amount" value="0.01">
      <input type="hidden" name="return"
      <input type="hidden" name="notify_url"
     value=" ch06/www/notification.jsp"> 
<!-- Note: The notify_url field is not required if the IPN
      URL was set in your account profile)-->
      <input type="submit" name="submit" value="Send $0.01!"> 

Notice that the form is posted to the PayPal server, butreturnandnotify_urlform elements are used to point back to this server. The IP address shown,, is the WAN IP address and port for my server; youíll need to establish an Internet accessible address and port for your own system. Clicking the button takes the user to the PayPal server, as shown in Figure 6-4.

Figure 6-4.  Initiating the PayPal transaction

Once at the PayPal server, users can walk through the rest of the transaction using the PayPal service, including entering credit card information and shipping address. When the order is complete, they are returned to the original pay_form.jsp page, ready to send another $0.01.

The example uses a transaction of $0.01 for this; it isnít a transaction youíd ever use PayPal for because PayPal and credit card company fees will absorb the penny. You can use PayPalís management services to refund the quantities sent, which is especially important if you need to test sending larger monetary sums.

As an additional feature, the example in this chapter generates faxes when a refund is sent. If an order is cancelled, youíll probably want to let your (fictional) business partner know as soon as possible.

blog comments powered by Disqus

- 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 

Developer Shed Affiliates


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