View on GitHub

Paypal-incontext-unofficial

Bower package for paypal in context checkout

Download this project as a .zip file Download this project as a tar.gz file

Disclaimer

This is an unofficial repository for PayPal In-context Javascript. Use at your own risk

Bower Installation


  bower install paypal-incontext-unofficial

Script Include

Do not use the script include if you installed via Bower. When the PayPal JS is successfully loaded, it will call the window.paypalCheckoutReady function. You should do your in context initialization in this function


  <script>
  window.paypalCheckoutReady = function () { paypal.checkout.setup(…); };
  </script>
  <script src="http://www.paypalobjects.com/api/checkout.js" async></script>
  </body>

In-Context Object Model

Listed below is the data model for the in-context checkout object


paypal.checkout.setup(<Merchant-ID>, {
container: 'myContainer',       // {String|HTMLElement|Array} Optional but required for PayPal javascript button generation. HTMLElement/ID of container elements that PayPal javascript button will be generated in.
button: 'myButton',             // {String|HTMLElement|Array} Optional but required if merchants custom buttons are used. HTMLElement/ID of custom buttons.
locale: 'en_US',                // {String} Optional. Local code for localization. Defaults to 'en_US' if omitted.
environment: 'production',      // {String} Optional. Defaults to 'production' if omitted. The other option is 'sandbox'.
click: function() {},           // {Function} Optional. Overrides the behavior when the button is clicked. It is used for ajax call use cases.
condition: function() {}        // {Function} Optional. Boolean if the PayPal incontext experience should be invoked when button is clicked. Used for mark integration.
});

paypal.checkout.initXO(); //used for Async ajax call

paypal.checkout.startFlow(token || url);  //used for ajax call to open mini browser. input can be either EC-token or full paypal url.

paypal.checkout.closeFlow();    //used for ajax use case to gracefully close the mini browser in case of AJAX errors

        

Demos

Basic Demo