Integrate Log In with PayPal seamless checkout

The PayPal Identity API supports the seamless checkout feature, which enables customers to directly checkout by using their PayPal account. After logged in to your website through Log In with PayPal, the buyer can seamlessly checkout with PayPal without logging in to PayPal again.

For security reasons, seamless checkout is only available from 15 minutes to one hour from customer log in to your website. The access token expires after 15 minutes; however, you can extend this time to one hour if you choose to refresh the access token.

From an integration perspective, the seamless checkout feature seamlessly connects a Log In with PayPal secure login integration with a PayPal Express Checkout payment processing integration.

Note: Currently, seamless checkout can be implemented only with the Express Checkout API operations. Soon, we will support this feature with REST API calls. You can see a demo of seamless checkout on the PayPal Demo.

Configuration

The seamless checkout feature allows merchants to connect the customer's Log In with PayPal session with a PayPal Express Checkout transaction. To use this feature, complete these one-time configuration steps:

Enable seamless checkout for your Log In with PayPal app

Merchants with an existing Log In with PayPal integration can use the seamless checkout feature. Enable both Log In with PayPal and seamless checkout for your PayPal application.

Obtain NVP/SOAP API credentials

Merchants without an existing Express Checkout integration must obtain live NVP/SOAP API credentials to go live with this feature. However, you can test this feature with any existing API credentials. For merchants who are not familiar with Express Checkout, see the Log In with PayPal integration steps for a basic Express Checkout integration.

Note: You must use the seamless checkout feature with version 87.0 or higher of the PayPal NVP/SOAP Express Checkout API. For an introduction to Express Checkout, see the Express Checkout API Getting Started Guide.

Integration steps

Depending on your existing integration, you must make minimal changes to implement seamless checkout:

Log In with PayPal integration steps

In the Log In with PayPal integration step to get the user's consent:

  1. Pass the seamless checkout URI in the scope request parameter:

    https://uri.paypal.com/services/expresscheckout
    
  2. The scope response parameter returns the seamless checkout URI:

    https://uri.paypal.com/services/expresscheckout
    

For integration steps, see Integrate Log In with PayPal.

Express Checkout integration steps

Seamless checkout requires a one-line change to an existing Express Checkout integration. Pass the Log In with PayPal Access-Token in the IDENTITYACCESSTOKEN NVP (or IdentityTokenInfo SOAP) request field of the SetExpressCheckout API operation.

  1. Integrate Log In with PayPal on your website.

    When the buyer clicks the Log In with PayPal button on your site, a PayPal log in window appears.

  2. The buyer logs in successfully and browses the products on your site.

  3. When the buyer is ready to check out and chooses to pay with PayPal, call and pass the Log In with PayPal access token information to the SetExpressCheckout API operation. The SetExpressCheckout API operation returns a token. Include the token in the PayPal redirect URL which you use to redirect the buyer to PayPal. The buyer does not need to log in to PayPal again. Instead, the buyer is taken directly to the payment review page.

  4. After the buyer has reviewed the payment information on paypal.com, call GetExpressCheckoutDetails to obtain any transaction details that may have changed, such as shipping address. Use this information to populate a payment confirmation page on your site. Once the buyer confirms the payment on your payment confirmation page, call DoExpressCheckoutPayment to finalize the payment.

Note: To have PayPal to return the buyer's shipping address, your website must use HTTPS (the secure HTTP protocol).

Express Checkout Seamless Checkout code sample

The following basic Express Checkout integration is a seamless checkout integration because the Log In with PayPal access token is passed in the first step of this integration.

Set checkout parameters

POST Live: https://api-3t.paypal.com/nvp
Sandbox: https://api-3t.sandbox.paypal.com/nvp
METHOD SetExpressCheckout (NVP or SOAP API reference)
PAYMENTREQUEST_0_CURRENCYCODE Currency code for sale amount.
PAYMENTREQUEST_0_AMT Sale amount as decimal number.
RETURNURL URL to return customer to after payment setup.
VERSION 106.0
USER Seller API name (see Obtain API credentials)
PWD Seller API password (see Obtain API credentials)
SIGNATURE Seller API signature (see Obtain API credentials)
IDENTITYACCESSTOKEN The Log In with PayPal access token.
PAYMENTREQUEST_0_PAYMENTACTION The transaction type, Sale, Authorization, Order
PHP example
$ch = curl_init( 'https://api-3t.sandbox.paypal.com/nvp' );

$params = array(
   'method'                         => 'SetExpressCheckout',
   'PAYMENTREQUEST_0_AMT'           => '1.00',
   'PAYMENTREQUEST_0_CURRENCYCODE'  => 'USD',
   'returnUrl'                      => 'https://example.com/payment-request.php?result=success',
   'cancelUrl'                      => 'https://example.com/payment-request.php?result=canceled',
   'version'                        => '106.0',
   'user'                           => 'seller_1357834706_biz_api1.paypal.com',
   'pwd'                            => '1357834725',
   'signature'                      => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AdYAf2hyMbhVdgvRiPEYQJhaAJZn',
   'IDENTITYACCESSTOKEN'            => $accessToken,
   'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale'
);

curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $params ) );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

$response = curl_exec( $ch );

Validate transaction

Redirect the buyer to PayPal:

  • Sandbox

    https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=Token-Value
  • Live

    https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=Token-Value

After the buyer authorizes the payment on paypal.com, PayPal returns the buyer to your website. At this point, you can call GetExpressCheckoutDetails to obtain details about the buyer and transaction information that may have changed, such as, the buyer's shipping address.

POST Live: https://api-3t.paypal.com/nvp
Sandbox: https://api-3t.sandbox.paypal.com/nvp
METHOD GetExpressCheckoutDetails (NVP or SOAP API Reference)
TOKEN The value of the TOKEN response field returned (see Set checkout parameters)
VERSION 106.0
USER Seller API name (see Obtain API credentials)
PWD Seller API password (see Obtain API credentials)
SIGNATURE Seller API signature (see Obtain API credentials)
PHP example
$ch = curl_init( 'https://api-3t.sandbox.paypal.com/nvp' );

$params = array(
  'method'    => 'GetExpressCheckoutDetails',
  'token'     => TOKEN,
  'version'   => '106.0',
  'user'      => 'seller_1357834706_biz_api1.paypal.com',
  'pwd'       => '1357834725',
  'signature' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AdYAf2hyMbhVdgvRiPEYQJhaAJZn'
);

curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query( $params ) );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

$response = curl_exec( $ch );

Complete payment

POST Live: https://api-3t.paypal.com/nvp
Sandbox: https://api-3t.sandbox.paypal.com/nvp
METHOD DoExpressCheckoutPayment (NVP or SOAP API Reference)
TOKEN The value of the TOKEN response field returned (see Validate transaction)
PAYERID The value of the PAYERID response field returned (see Validate transaction)
VERSION 106.0
USER Seller API name (see Obtain API credentials)
PWD Seller API password (see Obtain API credentials)
SIGNATURE Seller API signature (see Obtain API credentials)
PHP example
$ch = curl_init( 'https://api-3t.sandbox.paypal.com/nvp' );

$params = array(
  'method'    => 'DoExpressCheckoutPayment',
  'token'     => TOKEN,
  'payerid'   => PAYERID,
  'version'   => '106.0',
  'user'      => 'seller_1357834706_biz_api1.paypal.com',
  'pwd'       => '1357834725',
  'signature' => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AdYAf2hyMbhVdgvRiPEYQJhaAJZn'
);

curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params) );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

$response = curl_exec( $ch );