RaterNow Checkout Integration

Use this guide to integrate your online shopping checkout pages with RaterNow Rewards Platform.

Integration Steps

Please follow below steps to integrate your checkout pages with RaterNow.

Step A.1 for Earn Points

Fetch point details

After customer's payment is processed, fire a call to RaterNow to fetch a single-use QR code to display on order confirmation page.

Learn more

Step A.2 for Earn Points

Display Single-Use QR

Bring the QR code fetched from RaterNow server and display it on the confirmation screen.

Learn more

Step B.1 for Redeem Points

Display input for redemption code

Display an input on checkout page for customer to enter and apply the redemption codes.

Learn more

Step B.2 for Redeem Points

Process Redemption code

After customer has entered the redemption code, your server will send it to RaterNow server to validate and apply (mark-used) the code.

Learn more

STEP A. Display QR code on order confirmation page

Prerequisites: This integration requires jquery version 1.11 or above. In rewards setup page, the "Redeem Online" option must be set to "Yes".

When customer completes the order at your website and is displayed the order confirmation page, you can use the below code to display a unique Rewards QR code which customer can scan to earn points on REWO Rewards app. Customer will also be displayed a link which he/she can click (instead of scanning the QR) to earn the points.

Copy below code and paste it in your order confirmation page. This code will display the single use rewards QR for the customer for the amount he/she has spent.

<script src="https://www.raternow.com/rater/js/generateonlineqr.js"><script>

//paste this where you want to display the reward qr which customer will scan to earn points.
<div id="raterparent"><span id="raterparenttitle"></span><div class="qrimage" id="qrcontainer"></div><span id="applinkspan"></span><a href="" id="qrcodelink" target="_blank"></a></div>
				

In your javascript on order confirmation page where you receive the order confirmation details, call this function to generate qr.

//call getQRCode to generate image
getQRCode("REWARDS_QR_STRING_FROM_SERVER [response.scannableqrcode]","qrcontainer","RR","200");
				

In the above code, replace "REWARDS_QR_FROM_SERVER" with the rewards qr received from the server.

Server side code to get Rewards QR from RaterNow server

The below code will fetch single use Rewards QR code from RaterNow server (based on the rewards configuration in Dashboard). Copy below (PHP) code and paste the below code on your server side script which processes the final order between order details acceptance and order confirmation page.

  $ch = curl_init();
  $url="https://www.raternow.com/cgi-bin/rater/merchantsingleuseqr.php";
  $apikeys = array('privateapikey'=>'','srctype'=>'2','amount'=>'CUSTOMER_BILL_AMOUNT');
  curl_setopt($ch, CURLOPT_URL,$url );
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apikeys));    
  $result = curl_exec($ch);
  curl_close($ch);
  echo $result;
   //you need to send this value to the client side along with your order confirmation details. 
   
				

Request POST Params

privateapikey
The private api key generated/displayed above.
srctype
Must be set to value 2. Indicates request is coming for online redemption.
amount
The total amount that customer paid for current transaction.

Response

merchantsingleuseqr.php returns an json array containing below response elements.

status
Returns "success" or "error"
scannableqrcode
Returns the QR string. Send this string to client-side/browser.

STEP B.1 Display redemption code input box and apply discount.

Server side code to apply entered redemption code

Copy below (PHP) code and paste it in your server side where you will receive redemption code from customer. The code sends the received redemption code to RaterNow and returns the amount of discount customer will receive. You will minus this amount from customer's final bill.


  $ch = curl_init();
  $url="https://www.raternow.com/cgi-bin/rater/validateredemptioncode.php";
  $apikeys = array('privateapikey' => 'YOUR_PRIVATE_KEY','srctype'=>'2','amount'=>$_POST["billamount"],'redemptioncode'=>$_POST["redemptioncode"]);
  curl_setopt($ch, CURLOPT_URL,$url );
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apikeys));    
  $result = curl_exec($ch);
  curl_close($ch);
  			
  echo $result;
  //send the result to client side. This result contains discount amount which will be provided to customer on the checkout page.

				

STEP B.2 Mark redemption code as used once order is processed.

Once customer confirms the new price and submits the order, use below code to notify RaterNow that customer has fully used the redemption code. This will ensure that customer cannot reuse the same code again.

  $ch = curl_init();
  $url="https://www.raternow.com/cgi-bin/rater/validateredemptioncode.php";
  $apikeys = array('privateapikey' => 'YOUR_PRIVATE_KEY','srctype'=>'2','redemptioncode'=>$_POST["redemptioncode"],'codeused'=>1);
  curl_setopt($ch, CURLOPT_URL,$url );
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
  curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($apikeys));    
  $result = curl_exec($ch);
  curl_close($ch);
  
  echo $result;
  //this result contains discount amount and status whether redemption attempt was successful.
				

Request POST Params

privateapikey
The private api key generated/displayed above.
srctype
Must be set to value 2. Indicates request is coming for online redemption.
amount
The total amount that customer paid for current transaction.
redemptioncode
The redemption code entered by customer on checkout page.
codeused
Set this to 1 during the second call. This parameter lets RaterNow know that you have used this code already and must be marked as used (so it cant be used again).

Response

validateredemptioncode.php returns an json array containing below response elements.

status
Returns "success", "codeutlized" or "error".
redeemamount
Formated value of amount that customer redeemed. Example: SGD 5.00.
currencysymbol
The currency symbol of amount redeemed
amount value
The numeric value of amount redeemed. Example: 5.00 .
freegift
The free gift that customer receives if redemption gives customer a free gift instead of a discount.
redemptioncode
The redemption code entered by customer on checkout page.
companyid
Your company id.
emailaddress
Customer's email address which has been used to sign up to your rewards program.