Integrating with PayPal Express

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

Besides the .ss file, integration with PayPal Express requires client-side code to display PayPal Express information in the user interface. For code examples, 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

You can use the following code for PayPal Express integration. Note how the getAbsoluteURL(domain, path) method is used for the Shopping Session object. You'll need the absolute path to avoid errors with 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

General Notices