Basically, three things need to happen when Place Order is clicked:
??? First, you must store the order somewhere in the database. You??™ll create a couple of new
tables (orders and order_detail) and write the code that saves the ordered products to
these tables.
??? Next, we must clear the shopping cart. After an order is placed, the shopping cart should
be empty. There??™s a chance customers will cancel their orders at the checkout stage??”we
don??™t want their carts hanging around and bloating our database with canceled orders.
PayPal and other payment processors offer mechanisms for programmatic notification
when an order has been paid for.
??? Finally, we send the visitor to the PayPal payment page to pay for the order.
?– Note Since we??™re in development Phase I, we still don??™t process payments ourselves but use a third-party
payment processor. Now, we no longer need the PayPal shopping cart, because we implemented our own in
the previous couple of chapters. Instead, we??™ll use PayPal??™s Single Item Purchases option, which takes the
visitor from our shopping cart to the PayPal payment page.
CHAPTER 14 ?– ACCEPTING CUSTOMER ORDERS 432
A problem that arises when using a third-party payment processor is that the customer can
cancel the order while at the checkout page, which is still at PayPal. This can result in orders that
are saved to the database for which no payment was completed.
Pages:
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547