Checkout with PayPal Demo

REST API with Checkout.js v4

Server-side Integration

Sample Sandbox Buyer Credentials

Buyer Email Password
emily_doe@buyer.com qwer1234
bill_bong@buyer.com qwer1234
jack_potter@buyer.com 123456789
harry_doe@buyer.com 123456789
ron_brown@buyer.com qwer1234
bella_brown@buyer.com qwer1234

Pricing Details



Readme

  1. Enter REST API credentials in api/Config/Config.php. You can get your own REST app credentials by creating a REST app with the steps outlined here .
  2. Click on 'PayPal Checkout’ button and see the experience.
  3. If you get any Firewall warning, add rule to the Firewall to allow incoming connections for your application.
  4. Checkout with PayPal using a buyer sandbox account provided on this page. And you're done!

In-Context Checkout integration steps with Checkout.js v4

  1. Copy the files and folders in the package to the same location where you have your shopping cart page.
  2. Include the following Checkout.js v4 script on your shopping cart page:
    paypal.Button.render({
        env: 'sandbox', // sandbox | production
    
        // Show the buyer a 'Pay Now' button in the checkout flow
        commit: true,
    
        // payment() is called when the button is clicked
        payment: function() {
    
            // Set up a url on your server to create the payment
            var CREATE_URL = 'api/createPayment';
    
            // Make a call to your server to set up the payment
            return paypal.request.post(CREATE_URL)
                .then(function(res) {
                    return res.paymentID;
                });
        },
    
        // onAuthorize() is called when the buyer approves the payment
        onAuthorize: function(data, actions) {
    
            // Set up a url on your server to execute the payment
            var EXECUTE_URL = 'api/executePayment';
    
            // Set up the data you need to pass to your server
            var data = {
                paymentID: data.paymentID,
                payerID: data.payerID
            };
    
            // Make a call to your server to execute the payment
            return paypal.request.post(EXECUTE_URL, data)
                .then(function (res) {
                    window.alert('Payment Complete!');
                });
        }
    }, '#paypal-button-container');
                
  3. Open your browser and navigate to your Shopping cart page. Click on 'Checkout with PayPal' button and complete the flow.
  4. You can use the sample Buyer Sandbox credentials provided on index.php/home page.
  5. Read overview of REST API here and find the API reference here. You can also try the interactive demo here