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:
-
Get the checkoutsettings JSON object by calling
nlapiGetWebContainer()
.getShoppingSession()
.getSiteSettings()
. -
Ensure that the checkout.paypalexpress.available field is set to T in the
checkoutsettings
object. -
Get the image URL for PayPal Express from the checkout.paypalexpress.imageurl field in the
checkoutsettings
object -
Add the Paypal Express Checkout button to your touch point .ssp file and provide a handler, in an .ss file, that calls the
proceedToCheckout()
method on the shopping session, to integrate with the PayPal Express checkout flow.Values for checkoutsettings fields should be passed as parameters for this method. You can set values for the following fields to customize the default PayPal Express checkout flow:
-
type – set to paypalexpress
-
cancelurl – the URL of redirect page when Cancel link is clicked at PayPal site
-
continueurl – URL for redirect page when Continue link is clicked at PayPal site
-
createorder – if value is set to T, Backend submits the current shopping order when Continue link is clicked; default is F
-
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:
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));
}
}