Checkout with PayPal Demo

Using Orders v2 REST API with PayPal JavaScript SDK

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 PayPal JavaScript SDK

  1. Copy the files and folders in the package to the same location where you have your shopping cart page.
  2. Include this script tag-
    <script src="https://www.paypal.com/sdk/js?client-id=sb"></script>
  3. Include the following script on your shopping cart page:
    paypal.Buttons({
        env: 'sandbox', // sandbox | production
    
        // payment() is called when the button is clicked
        createOrder: function() {
    
            return fetch('/my-server/create-paypal-transaction')
                .then(function(res) {
                    return res.json();
                }).then(function(data) {
                    return data.orderID;
                });
        },
    
        // onAuthorize() is called when the buyer approves the payment
        onApprove: function(data, actions) {
    
            return fetch('/my-server/capture-paypal-transaction', {
                    body: JSON.stringify({
                    orderID: data.orderID
                    })
                }).then(function(res) {
                    return res.json();
                }).then(function(details) {
                    alert('Transaction funds captured from ' + details.payer_given_name);
                });
        }
    }).render('#paypal-button-container');
                
  4. Open your browser and navigate to your Shopping cart page. Click on 'Checkout with PayPal' button and complete the flow.
  5. You can use the sample Buyer Sandbox credentials provided on index.php/home page.
  6. Refer to PayPal Developer site for detailed guidelines.
  7. Click here for the API reference.