Payment Methods and the Checkout Sequence


Several commerce methods exist when it comes time to pay for the purchases in the shopping cart. The "right" method for you depends on your businessmerchant accounts through banking institutions often require you to have a business license, a reseller's permit, and other pieces of paper proving that you're a legitimate business. If you're simply a person who has a few items to sell, you might not want to go through all that paperwork. However, you still have options!

Regardless of the payment method you choose, one thing is certain: If you are passing credit card information over the Web, you must do so over an SSL connection. Obtaining an SSL certificate and installing it on your system is covered in Chapter, "Setting Up a Secure Web Server." You do not have to use this secure connection during the user's entire shopping experience, just from the point at which sensitive information is captured, such as the checkout form.

Creating the Checkout Form

At this point in the book, you should be well versed in creating a simple form. At the beginning of this chapter, the store_orders table was created with fields to be used as a guideline for your form:

  • order_name

  • order_address

  • order_city

  • order_state

  • order_zip

  • order_tel

  • order_email

Additionally, your form will need fields for the credit card number, expiration date, and the name on the credit card. Another nice feature is to repeat the user's shopping cart contents with an item subtotal so that the customer remembers what he's paying for and approximately how much the order will cost. Also at this point of the checkout sequence, you offer any shipping options you might have. Shipping and sales tax would be calculated in the next step of the process.

From the point of clicking the submit button on the form, the checkout sequence depends on the payment method you are using. The next section goes through the basic steps and offers suggestions on various methods of payment processing.

Performing the Checkout Actions

If you have obtained a merchant account through your bank, you can utilize real-time payment services such as VeriSign's PayFlo Pro. PHP no longer contains a built-in set of functions that enable direct access to the PayFlo libraries from VeriSign, but you can still create a simple script to handle the credit card transaction. You can learn more about PayFlo Pro at the VeriSign website: http://www.verisign.com/products-services/payment-processing/online-payment/payflow-pro/index.html. The comments area of the PHP Manual section for the old PayFlo functions contains several options for using PayFlo and PHP:http://www.php.net/pfpro.

VeriSign's product is one of several transaction-processing gateways that exist for use by merchants. Your bank will usually provide a list of merchants it prefers you to use. If you stray from your bank's list of preferred vendors, be sure to research your selected vendor thoroughly to avoid any delays with deposits and to ensure you're getting the best deal.

After you have selected a transaction processor, your checkout script should follow a path such as the following:

  1. Total the items, add tax, and add shipping. This gives you the total amount to authorize from the credit card.

  2. Perform credit card authorization for the total amount.

  3. You will receive either a success or failure response from your card processing routine. If the response is a failure, print a message to the user, and the transaction is over. If the response is a success, continue to step 4.

  4. Write the basic order information to a table such as store_orders, including the authorization code you will receive on successful authorization. Get the id value of this record using mysql_insert_id().

  5. For each item in the shopping cart that is tied to this user, insert a record into store_orders_itemmap. Each record will reference the id (as order_id) gathered in the previous step.

  6. Delete the shopping cart items for this user.

  7. Display the order with authorization code in place of the credit card information on the screen so that the user can print it and hold it as a receipt. You can also send this information via email to the user.

Each of the steps listed previouslywith the exception of the actual payment authorization codeare the same simple steps you have been using throughout this book, and there's no reason to make them more difficult than they need to be!




Sams Teach Yourself PHP, MySQL And Apache All in One
Sams Teach Yourself PHP, MySQL and Apache All in One (3rd Edition)
ISBN: 0672328739
EAN: 2147483647
Year: 2004
Pages: 327

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