PayPal Checkout REST API Demo

Digital SLR Camera

Sample Sandbox Buyer Accounts

Buyer EmailPassword

Pricing Details

Handling Fee
Estimated Shipping
Shipping Discount
Total Amount



This code sample demonstrates the Express Checkout flow called In-Context Checkout. You need to meet the eligibility criteria to determine whether your integration will be a good candidate for the In-Context Checkout experience option.
  1. Click on the ‘PayPal Check Out’ button or "Proceed to Checkout" button to see the experience.
  2. If you get any Firewall warning, add rule to the Firewall to allow incoming connections for your application.
  3. Checkout with PayPal using a Sandbox Buyer account provided on this page, and you're done!
  4. The sample code uses default sandbox REST App credentials which are set in PayPal.config. You can get your own REST app credentials by creating a REST app with the steps outlined here.
  5. Make following changes in PayPal.config:
    • If using your own Sandbox Seller account, update MERCHANT_ID with your merchant id. To get your merchant id, log into your Sandbox or Live business account as per the integration. The merchant ID can be found under My Account > Profile > My business info > Merchant account ID.
    • Also, update SANDBOX_CLIENT_ID and SANDBOX_CLIENT_SECRET values with your REST app Sandbox Seller credentials.
    • SANDBOX_FLAG: Kept true for working with Sandbox, it will be false for live.

Demo flows

Two flows using In-Context are demonstrated: a shortcut flow, and another that allows the customer to provide alternate shipping information.
PayPal Check Out (shortcut flow)
  1. Click PayPal Check Out (Index.aspx)
  2. PayPal lightbox opens (StartPayment.aspx)
  3. Select shipping method (PlaceOrder.aspx)
  4. Receive confirmation (Pay.aspx)
Proceed to Checkout (allows manual input of shipping address)
  1. Click PayPal Check Out (Index.aspx)
  2. Provide shipping information and click Place Order (Shipping.aspx)
  3. PayPal lightbox opens (StartPayment.aspx)
  4. Select shipping method (PlaceOrder.aspx)
  5. Receive confirmation (Pay.aspx)

In-Context Checkout REST integration steps

  1. Learn about the In-Context Checkout flow.
  2. Meet the prerequisites.
  3. Copy the html form to your checkout page. Note the id of the form (myContainer).
<form id="myContainer" action="StartPayment.aspx" method="POST">
        <input type="hidden" name="csrf" value="<%= Session["csrf"] %>" />
        Camera:<input type="text" name="camera_amount" value="300" readonly /><br />
        Tax:<input type="text" name="tax" value="5" readonly /><br />
        Insurance:<input type="text" name="insurance" value="10" readonly /><br />
        Handling:<input type="text" name="handling_fee" value="5" readonly /><br />
        Est. Shipping:<input type="text" name="estimated_shipping" value="2" readonly /><br />
        Shipping Discount:<input type="text" name="shipping_discount" value="-2" readonly /><br />
        Total:<input type="text" name="total_amount" value="320" readonl /><br />
        Currency:<input type="text" name="currencyCodeType" value="USD" readonly /><br />
  1. Include the following JavaScript in your checkout page. The setup call automatically populates and displays the PayPal Check Out button in your container. In this example, the container is the form itself.
<script type="text/javascript">
        window.paypalCheckoutReady = function () {
            paypal.checkout.setup('Your merchant id', {
                container: 'myContainer', //{String|HTMLElement|Array} where you want the PayPal button to reside
                environment: 'sandbox' //or 'production' depending on your environment
    <script src="//" async></script>
  1. Place code on your server to create Express Checkout payments using the REST API. Review this demonstration and the source code in this project to get started (see