Integrating with PayPal Express

To integrate SSP application checkout with PayPal Express, you must do the following for the View Cart and Proceed to Checkout touch points:

In addition to an .ss file, integration with PayPal Express requires client-side code to display PayPal Express information in the user interface. For examples of this code, see the following:

Note:

Integration with third-party checkout providers is not available for SSP applications written in Suitescript 2.0. For more information about SuiteScript 1.0, see SuiteScript 1.0 Guide.

Sample .ss File for PayPal Express Integration

The following code is in a samplePaypalCheckout.ss file:

          function service(request,response)
{
    var returnval = null;
 
    try
    {
 
        var shoppingSession = nlapiGetWebContainer().getShoppingSession();
        var siteSetting = shoppingSession.getSiteSettings(['touchpoints']);
 
        var viewcart = siteSetting.touchpoints.viewcart;
        var homeurl = siteSetting.touchpoints.home;
 
        var checkoutSetting = {type: 'paypalexpress', continueurl: homeurl, cancelurl : viewcart};
 
        nlapiGetWebContainer().getShoppingSession().proceedToCheckout(checkoutSetting);
    }
    catch (e)
    {
        var nle = nlapiCreateError(e);
        returnval = {status : 'error', reasoncode : nle.getCode(), message : nle.getDetails()};
 
        response.writeLine(JSON.stringify(returnval));
    }
} 

        

Sample for Displaying PayPal Express Information

The following code can be used for PayPal Express integration. Note the use of the getAbsoluteURL(domain, path) method for the Shopping Session object. The absolute path is required to avoid errors for cross-domain links (links that go between shopping and checkout domains).

          <table border=0>
<% var checkoutSettings = nlapiGetWebContainer().getShoppingSession().getSiteSettings(['checkout']);
var paypalUrl = nlapiGetWebContainer().getShoppingSession().getAbsoluteUrl("checkout", "samplePaypalCheckout.ss");
var proceedToCheckoutUrl = nlapiGetWebContainer().getShoppingSession().getAbsoluteUrl("checkout", "sampleCheckout.ss");
<tr>
  <td>
    <form name='checkoutform' action='<%=proceedToCheckoutUrl%>' method='post'>
      <input type="submit" name="placeorder" id="placeorder" value="Proceed To Checkout" class="nlbutton"/>
    </form>
  </td>
  <td> </td>
  <td >
    <form name='paypalform' action='<%=paypalUrl%>' method='post'>
      <input type='image' src='<%=checkoutSettings.checkout.paypalexpress.imageurl%>' class="nlbutton"/>
    </form>
  </td>
  </tr>
</table> 

        
          function service(request,response)
{
   var returnval = null;
 
   try
   {
 
      var shoppingSession = nlapiGetWebContainer().getShoppingSession();
      var siteSetting = shoppingSession.getSiteSettings(['touchpoints']);
 
      var viewcart = siteSetting.touchpoints.viewcart;
      var homeurl = siteSetting.touchpoints.home;
 
      var checkoutSetting = {type: 'paypalexpress', continueurl: homeurl, cancelurl : viewcart};
 
      nlapiGetWebContainer().getShoppingSession().proceedToCheckout(checkoutSetting);
   }
   catch (e)
   {
      var nle = nlapiCreateError(e);
      returnval = {status : 'error', reasoncode : nle.getCode(), message : nle.getDetails()};
 
      response.writeLine(JSON.stringify(returnval));
   }
} 

        

Related Topics

Integrating with 3D Secure (SCA Elbrus and Earlier)
Integration with Third-Party Checkout Providers

General Notices