Enable In-Context Checkout
Important: This integration method is deprecated as of January 1, 2017. PayPal continues to support existing merchants using this method, but please be advised new features and enhancements will not be applied to these integrations. For new integrations, see the PayPal Checkout Integration Guide.
Add the In-Context JavaScript
To integrate In-Context Checkout, include the PayPal checkout.js
JavaScript on the page that hosts your PayPal button.
Note: Load and run the checkout.js script from //www.paypalobjects.com/api/. Do not download a local copy to your server and load it from there.
<script src="https://www.paypalobjects.com/api/checkout.js" async></script>
Basic integration example
A basic Express Checkout integration assumes that you are sending the API calls from your own server using a form
or an a
tag. The following example integration script calls paypal.checkout.setup
and must be loaded after the form
or a
tag:
<form id="myContainer" method="post" action="/checkout"></form>
<script>
window.paypalCheckoutReady = function () {
paypal.checkout.setup('<Your-Merchant-ID>', {
environment: 'sandbox',
container: 'myContainer'
});
};
</script>
<script src="https://www.paypalobjects.com/api/checkout.js" async></script>
In advanced Express Checkout integrations, checkout.js
is initiated through a click
event, as described in Advanced In-Context JavaScript settings.
Note: The
paypalCheckoutReady
function runs after the script loads.
Try It!
JavaScript button demo
For more information, see the In-Context API functions.
In-Context Checkout processing
The checkout.js
script completes this processing:
- The
setup
call automatically populates and displays the PayPal Checkout out button in your container. - When the buyer clicks the button, the script uses AJAX to manage the form submit in the background.
- The form submit invokes your code on the server to call the
SetExpressCheckout
method. - Your server code redirects the buyer to a PayPal URL with the token appended.
- The script manages the redirect within a secure pop-up window on your website.
- After the buyer checks out, PayPal redirects the buyer to the return URL specified in the
SetExpressCheckout
call.
Note: For assistance with implementing In-Context Checkout, contact your PayPal integration engineer.
Debugging tips
To turn on console debugging logs:
- Open the console panel in your browser developer tools.
-
In your console, enter this setting:
document.cookie="PPDEBUG=true"
Note: The console setting is case-sensitive.
- Refresh the page.
Note: To disable Quirks Mode and Compatibility View in Internet Explorer, add
<!DOCTYPE html>
and<meta http-equiv="X-UA-Compatible" content="IE=edge" />
to the page that initiates the checkout flow.
Next
Complete one of these tasks:
- For manual, AJAX, conditional, or Mark integrations, specify advanced settings.
- For all other use cases, initiate a payment.