How to Create One-Time Payments Using Express Checkout

This guide describes how to complete an Express Checkout transaction using the Set-Get-Do series of API operations.

For demonstration purposes, this guide makes requests using the PayPal Sandbox. For information on making calls using the Classic APIs, including obtaining the needed API credentials and how to make test calls using the Sandbox, see Apps 101.

The figure below shows the flow of calls through a typical Express Checkout transaction. It illustrates how the transaction flow interacts with the PayPal customer and how your requests interact with PayPal (the Sandbox in this example).

This figure illustrates a typical Set, Get, Do Express Checkout transaction.

1. Set Up the Payment Information

When a customer initiates a check out, call SetExpressCheckout to specify the payment action, amount of payment, return URL, and cancel URL.

Note: Example calls are shown in cURL, and the code is wrapped and commented for readability.

The SetExpressCheckout response contains a token value that you use in subsequent calls to complete the transaction:

2. PayPal Returns a Token

If the SetExpressCheckout request is successful, PayPal returns a token string in the Token response field. The default lifetime of this token is 3 hours. You will need this token in the subsequent steps.

# SetExpressCheckout response



Important You must URL-decode the returned token value before you can use it in other Express Checkout calls.

3. Redirect the Customer to PayPal for Approval

Using the token valued returned from SetExpressCheckout, redirect the customer to PayPal so they can approve the transaction:<tokenValue>

The redirect presents the customer with a PayPal log-in page. After the customer logs in, PayPal displays the transaction details on the Payments Review page. The customer approves the payment on this page by clicking Continue.

4. PayPal Redirects the Customer Back to Your Site

If the customer approves the payment, PayPal directs the customer to the payment confirmation page (the return URL specified in your SetExpressCheckout call in Step 1). If the customer doesn't authorize the payment, PayPal directs the customer to the cancel URL that you also specified in your SetExpressCheckout call, and you can attempt to re-initiate the checkout.

5. Obtain Approved Payment Details

If the customer approves the payment, call GetExpressCheckoutDetails to obtain the PayerID (which uniquely identifies the customer), and any other details you might need for transaction processing. For example, you can use the transaction details to display the customer's shipping data, and other information, on your payment confirmation page.

Use the following sample by replacing <tokenValue> with the token from the SetExpressCheckoutPayment response:

The response from this call includes the PayerID value, which is needed to capture the payment:

# GetExpressCheckoutDetails response



6. Complete the Transaction

In addition to the transaction details, your payment confirmation page should include a Confirm button. When the customer confirms the payment, call DoExpressCheckoutPayment to capture (collect) the payment. The following sample shows how to specify the PayerID and token value returned from the previous calls:

When PayPal processes DoExpressCheckoutPayment, it captures the payment by transferring the funds from the customer account to the appropriate merchant account and sends a confirmation e-mail to the customer.

Learn More

For more details on how to use Express Checkout, see the following resources:

For information on using the PayPal APIs, how to use the Sandbox for testing, and how to move your app into production, see links provided on the Apps 101 page.