PayPal APIs_ Up and Running_ A Developer's Guide - Michael Balderas [5]
Table 1-4. ACK parameter values
Type of response Value
Successful response Success, SuccessWithWarning
Partially successful response (relevant only for parallel payments; some of the payments were successful and others were not) PartialSuccess
Error response code Failure, FailureWithWarning, Warning
Putting it together
Now that we know how the response is formatted, we can extend the simpletransactionrequestprocessor.php file to handle the information returned in the $response string (see Example 1-3).
Example 1-3. simpletransactionrequestprocessor.php
//Parse $Response and handle values
$decoderesponse = explode ('&', $response);
foreach($decoderesponse as $key => $value){
switch ($key){
case "ACK":
$ack = htmlspecialchars(urldecode($value));
break;
case "var1":
$var1 = htmlspecialchars(urldecode($value));
break; default:
break;
}
}
//Your code to display or handle values returned.........
This is just a glimpse of what you can do with the PayPal API. The different integration methods, testing platforms, and credentials make it easy to debug and use the PayPal API to accept payments in just about any application. Next, we take a look at the simplest PayPal API method for accepting payments: Express Checkout.
Chapter 2. PayPal Express Checkout
Express Checkout is PayPal’s premier checkout solution. It allows a customer to check out on your site, log into his PayPal account, and purchase your goods or services. Express Checkout puts PayPal in charge of data security with regard to the customer’s billing and credit card information and removes that liability from the merchant. In this chapter, we will look at generic versus Express Checkout workflows, Express Checkout API operations, a simple Express Checkout integration, as well as an in-depth integration method.
Checkout Process Workflows
Let’s start by looking at the process flow of a typical checkout and an Express Checkout.
Generic Checkout Workflow
Figure 2-1 shows the typical checkout flow a user experiences when buying goods or services online, which includes the following steps:
Customer clicks the checkout button on your shopping cart page.
Customer enters all shipping information.
Customer chooses her payment method and provides all the relevant billing and payment information.
Customer reviews order and pays.
Customer receives her order confirmation.
As you can see, this typical checkout method requires the customer to provide a lot of information at the time of purchase. This is where PayPal’s Express Checkout can be a real time saver for your customers.
Figure 2-1. Generic checkout workflow
Express Checkout Workflow
Figure 2-2 shows the checkout workflow a user experiences when using PayPal’s Express Checkout:
Customer chooses Express Checkout by clicking the “Check out with PayPal” button on your site.
Customer logs into PayPal.
Customer reviews the transaction on PayPal.
Customer confirms the order and pays from your site.
Customer receives an order confirmation.
Figure 2-2. PayPal Express Checkout workflow
With Express Checkout, the customer does not need to enter his billing and shipping information each time. Consequently, customers can make purchases and move on to other tasks much more quickly.
Generic Versus Express Checkout Workflow
Table 2-1 outlines the process steps required to complete a payment during a generic checkout and Express Checkout. As you can see, Express Checkout saves both time and processing steps.
Table 2-1. Generic checkout versus Express Checkout