This article documents how JavaScript Sale Integration can be used to send details of a customer's purchase automatically to Feefo. 

Feefo offers an automated method for sending sales data that is obtained from the merchant’s eCommerce website. By inserting a generated iFrame on the merchant’s sale confirmation web page, each sale from the website will be processed automatically and the necessary information sent directly to Feefo. By default, only sales from the domain registered in the Feefo settings as the Website Forwarding URL (e.g. www.yourwebsite.com) will be accepted. If you are wanting to have multiple subdomains (e.g. www.yourwebsite.com, m.yourwebsite.com and whitelabel.yourwebsite.com) sending JavaScript sales, please let us know and we will add the additional subdomains to your account. 

Each web page that will be using the iFrame must have the following code snippet added at the bottom of the section. Note that the order of this code is important with the Post Message Handler coming before the Initialisation.

<!-- Post message handler --> 
<script
  type="text/javascript"
  src="https://api.feefo.com/api/assets/js-sale-integration/javascript/feefo-js-post-message-handler.js">
</script>

<!-- Initialise the Post Message Handler -->
<script type="text/javascript">
  var FPMH = new Feefo.PostMessageHandler();
  FPMH.init();
</script>

The iFrame itself is then positioned below the code snippet but still within the section of each web page using the iFrame. An example of an iFrame for a single sale with two products is shown below:

<iframe
id="FSI_IFrame"
style="display: none; "
width="0" height="0"
src="https://api.feefo.com/api/sales/merchant?merchantidentifier=example-retail-merchant"
data-feefo-email="john.smith@emailaddress.com"
data-feefo-orderref="123456789"
data-feefo-name="John Smith"
data-feefo-customerref="123-456-789”
data-feefo-feedbackdate=”11/08/15"
data-feefo-products='[{"description":"PS4 500GB Black","productsearchcode":"PS4500GBBLACK","amount":"299.99","productlink":"http://www.merchant.com/products/ps4","currency":"GBP","tags":{"saleschannel":"Web","productline":"games"}},{"description":"Xbox One 500GB White","productsearchcode":"XBOXONE500GBWHITE","amount":"299.99","productlink":" http://www.merchant.com/products/xbox","currency":"GBP","tags":{"saleschannel":"Web","productline":"games"}}]>
</iframe>

The attributes used within the iFrame are similar to those used by the Entersaleremotely API. A summary of each attribute is shown below but for more details see Entersaleremotely API Parameter Summary:

An example of how to generate the iFrame using a server-side script is shown below. This example is written in PHP but in practice will be in the merchant’s server-side scripting language.

<?php
// API URL
$FeefoAPI = "http://api.feefo.com/api";
$FeefoMerchantIdentifier = "example-retail-merchant";
// Sale values
$FeefoEmail = "john.smith@emailaddress.com";
$FeefoName = "John Smith";
$FeefoOrderref = "123456789";
$FeefoCustomerref = "123-456-789";
$FeefoFeedbackDate = "2015-08-11T11:30:00+01:00";
$feefoProducts = '[{"description":"PS4 500GB Black","productsearchcode":"PS4500GBBLACK","amount":"299.99","productlink":"http://www.merchant.com/products/ps4","currency":"GBP","tags":{"saleschannel":"Web","productline":"games"}},{"description":"Xbox One 500GB White","productsearchcode":"XBOXONE500GBWHITE","amount":"299.99","productlink":" http://www.merchant.com/products/xbox","currency":"GBP","tags":{"saleschannel":"Web","productline":"games"}}]';
// Output the iframe
echo "".
"<iframe".
"  src='".$FeefoAPI."/sales/merchant?merchantidentifier=".$FeefoMerchantIdentifier."'".
"  width='0' height='0'".
"  data-feefo-email='".$FeefoEmail."'".
"  data-feefo-name='".$FeefoName."'".
"  data-feefo-orderref='".$FeefoOrderref."'".
"  data-feefo-customerref='".$FeefoCustomerref."'".
"  data-feefo-feedbackdate='".$FeefoFeedbackDate."'".
"  data-feefo-products='".$feefoProducts."'></iframe>";
?>

The above example uses the same data as shown in the previous JavaScript Plugin example - a single sale with two products. The script firstly lists the variables which contain the sales data and then it outputs these values to the iFrame in their correct positions. The iFrame will then be rendered invisibly (it has no graphical elements) onto the order confirmation page and once applied, the sale information is submitted to Feefo.

Various checks against the sale are carried out to ensure only valid data is uploaded prior to sending it to Feefo. These checks include validating the merchant identifier, comparing the merchant’s stored domain on Feefo (if multiple subdomains will be sending us sales, register them by contacting our Technical Team) with the information supplied with the sale, and a ‘One Time Key’ (also known as a UUID (Universally Unique Identifier)) stored in the session (on Feefo’s servers) which validates the sale. If any of these checks fail, the sale is then rejected from Feefo and a feedback request email is not sent.

Although Feefo are unable to provide detailed support for server-side scripts, if any issues arise when working with Feefo’s iFrame, please contact Feefo's Technical Support.

Feefo's GnuPG Public KeyEntersaleremotely API