Hack 57 Build an Order-Tracking Page

 < Day Day Up > 

Hack 57 Build an Order-Tracking Page

figs/moderate.gif figs/hack57.gif

Keep your customers informed of order status using an automated system .

The Internet sped up everything, including your customers' expectations. Once you have the code in place to display the merchant transaction ID on your return page [Hack #52] and insert payment details into a database [Hack #82] , it's easy to create a page that enables customers to check on the status of an order. You need to place two new pages on your system: a query page that allows your customers to ask the question and a results page that gives them the answer. Figure 5-11 shows a completed results page.

Figure 5-11. A completed order-tracking page

An order-tracking page like this one is easy to implement and goes a long way in placating customers.

5.14.1 Asking the Question

The query page can be quite simple. All you need is a form that allows your customer to enter the transaction ID you previously provided. Once the customer clicks Submit, the results page takes over.

 <html><body> Enter the transaction ID corresponding to the order you wish to look up: <form action="order_tracking.asp" method="post"> <input type="text" name="txn_id"> <input type="button" value="submit" name="submit"> </form> </body></html> 

The form is only the beginning. Obviously, the preferred method is to display a list of all relevant transaction IDs, from which the customer can select one to view the transaction details. See [Hack #22] for more information, as well as [Hack #94] for a way to get this information using the PayPal API.

5.14.2 Getting the Answer

This example ( especially the tblOrders table) assumes a database structure similar to the structure used in [Hack #82] . Any web scripting language will work for this task. This example uses ASP:

 <% 'Read back customers input Dim txn_id Txn_id = Request ("txn_id") 'Connect to database and create recordset connStore = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=                 "C:/InetPub/wwwroot/database/dbPayPal.mdb") set rsOrder = Server.CreateObject("ADODB.Recordset") rsOrder.ActiveConnection = connStore rsOrder.Source = SELECT payer_email, payer_id, payment_status, txn_id,                  mc_gross, mc_fee, payment_date FROM tblOrders WHERE txn_id = '" &                  txn_id &"'" rsOrder.Open( ) %> <!--  Check to see if the order information can be found; if so, display it.--> <% If NOT rsOrder.EOF OR NOT rsOrder.BOF Then %> Here are the details of your order: <p> Customer Email: <%=rsOrder("payer_email")%> <br>Customer ID: <%=rsOrder("payer_id") %> <br>Payment Status:  <%=rsOrder("payment_status") %> <br>Transaction ID:  <%=rsOrder("txn_id") %> <br>Payment Gross: <%=rsOrder("mc_gross") %> <br>Payment Date: <%=rsOrder("payment_date") %> <% Else %> No matching Record Found. Please search again. <% End If %> 

5.14.3 Hacking the Hack

Here are a few ways you can extend this hack:

  • Place another copy of the query form on the results page. This way, if your customers need to query for more than one transaction ID, they won't have to use their browser's Back button to enter another.

  • Change the query page to accept a list of transaction IDs in a textarea box. Then modify the results page to display the results of searching for each.

  • Use Instant Payment Notifications (IPN) to send an email with a tracking link [Hack #67] .

 < Day Day Up > 

PayPal Hacks
PayPal Hacks
ISBN: 0596007515
EAN: 2147483647
Year: 2004
Pages: 169

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net