Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Create a Web storefront using PHP and PayPal, Part 3: Setting up orders, shipping, and e-mail

An introduction to transactions using PHP Data Objects

Martin Brown (mcb@mcslp.com), Freelance Writer
Martin Brown has been a professional writer for more than eight years. He is the author of numerous books and articles across a range of topics. His expertise spans myriad development languages and platforms -- Perl, Python, Java, JavaScript, Basic, Pascal, Modula-2, C, C++, Rebol, Gawk, Shell script, Windows, Solaris, Linux, BeOS, Mac OS/X and more -- as well as Web programming, systems management, and integration. He is a regular contributor to ServerWatch.com, LinuxToday.com and IBM developerWorks, and a regular blogger at Computerworld, The Apple Blog, and other sites. He is a Subject-Matter Expert (SME) for Microsoft.
Tyler Anderson (tyleranderson5@yahoo.com), Freelance Writer, Stexar Corp.
Tyler Anderson graduated with a degree in computer science from Brigham Young University in 2004 and is currently in his last semester as a master's student in computer engineering. In the past, he worked as a database programmer for DPMG.com, and he is currently an engineer for Stexar Corp., based in Beaverton, Ore.

Summary:  This series chronicles the building of a Web storefront in PHP using PHP Data Objects to access a Derby database. The storefront includes a user manageable shopping cart that allows item purchases using PayPal, and includes the ability for merchants to notify customers via e-mail on successful orders automatically. This final part covers the addition of transactions, a shipping component, and an e-mail notification feature.

View more content in this series

Date:  22 Nov 2005
Level:  Intermediate PDF:  A4 and Letter (399 KB | 30 pages)Get Adobe® Reader®

Activity:  6179 views
Comments:  

Before you start

This tutorial is for those interested in expanding the storefront created in "Create a Web storefront using PHP, Derby and PayPal, Part 1" and enhanced in Part 2 of this three-part series by integrating transactions, shipping, and e-mail functionality. This tutorial assumes knowledge of PHP, including PHP Data Objects (PDO) and user sessions, as covered in Part 1.

About this series

The staff at Ghastly Computers is excited about completing the storefront and putting it to use. This tutorial will cover the finishing touches -- mainly, adding the functionality to the storefront that will allow customers to ship purchased items to the proper destinations.

Part 1 focused on setting up a Derby database and creating the basic storefront. You will access Derby through PDO. User sessions are started to help set up for Part 2 where a shopping cart is associated with a user's session ID. The shopping cart is stored in the Derby database, and the user's session ID becomes the ID of the cart. The shopping cart, if it contains items, is shown under the listing of categories in the storefront. The cart displays Manage cart and Checkout links. Checking out involves taking a user's ship-to/bill-to information, which will be submitted for payment to PayPal. After completing the payment to PayPal, the user is then shown a Thank you page, and is given a new session ID.

Part 3 covers viewing orders, and notification for shipping and e-mail. Transactions using PDO will also be introduced. Adding shipping to the checkout process will be incorporated via UPS, offering real-time shipping prices. E-mail notification will be sent to the customer showing an order summary. PayPal, by default, also sends a payment confirmation e-mail messages to the user and the merchant.


About this tutorial

This tutorial will add some finishing touches to the store application so the staff at Ghastly Computers can actually ship the products its customers are buying. You will start with an administration interface that will enable you to complete the order process (from the administration side). Then, on the user side, you'll add steps that will ensure that orders are correctly placed (by using transactions), add shipping costs and choices to our application (using UPS), and finally add the ability to send an e-mail to the customer when the transaction has been completed and the order has been shipped.


Prerequisites

To follow along, you will need to install and test the following tools:

Web server
Pick any Web server and operating system. Feel free to use Apache V2.X, or the IBM HTTP Server.
PHP
Due to the use of PHP data objects, the latest version, PHP V5.1, is necessary to fully follow along in this tutorial. Note that V5.1 is is a release candidate (RC) and is not yet an official release. Be sure to configure PHP with the following option to include support for Derby: --with-pdo-odbc=ibm-db2,/home/db2inst1/sqllib. See Resources for information about configuring Apache or the IBM HTTP Server with PHP.
Database
This tutorial uses Derby. Download Derby V10.1, the current IBM DB2 JDBC Universal Driver, and the DB2® run-time client from IBM. Be sure to follow the instructions on each page carefully. Follow either the Linux® or Windows® instructions for downloading and installing the DB2 run-time client.

You may also use Cloudscape for this tutorial. The internals of Cloudscape are the same as Derby. However, the DB2 JDBC Universal Driver and other things are packaged into Cloudscape, and it is supported by IBM. Download Cloudscape V10.1, and the DB2 run-time client from IBM.
Java™
Derby requires Java technology. I have found the gcj provided in Red Hat Linux distributions insufficient. Download Java technology from Sun.

1 of 9 | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, SOA and Web services
ArticleID=133594
TutorialTitle=Create a Web storefront using PHP and PayPal, Part 3: Setting up orders, shipping, and e-mail
publish-date=11222005
author1-email=mcb@mcslp.com
author1-email-cc=troy@backstopmedia.com
author2-email=tyleranderson5@yahoo.com
author2-email-cc=troy@backstopmedia.com