Rebillia v4 Code Update

What framework am I using?

In order to implement the correct code in the correct place, first you must know what theme framework you are using on your store.

From the back-end admin panel, click on “Advanced Settings” then click on “Checkout”.

BluePrint themes will have the following options showing under “Checkout type”:

Stencil themes will have the following options showing under “Checkout type”:

Follow the instuctions according to your theme:

From the back-end admin panel of your store, go to “Advanced Settings” -> “Web Analytics” -> “Google Analytics”. Find the bulk of code that starts with: “<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”>” and replace it (the whole bulk) with the following code:

<script type=”text/javascript”>var currentcustomeremail = ‘%%GLOBAL_CurrentCustomerEmail%%’;var shopPath = ‘%%GLOBAL_ShopPathSSL%%’;var domainName = ‘https://app.rebillia.com’;var domainURL = ‘https://app.rebillia.com/’;var appClientId = “ageychj33ynffm8otcbd88hxt9spicx”;var rebpostxmlhttpURL = ‘https://app.rebillia.com/login/customers’;var rebxmlhttpUrl = ‘https://app.rebillia.com/login/customers/’;var date = new Date();date.setTime(date.getTime()+(30*60*1000));var expires = “; expires=”+date.toGMTString();$(document).ready(function(){var matches=window.location.href.match(/[^\/]+$/);if (matches && matches.length) {var vec=(matches[0].split(‘.’));if (vec[0] == ‘account’ || vec[0] == ‘checkout’ || vec[0] == ‘finishorder’){$.getScript(domainName+”/js/embed-“+ vec[0] +”.js”);}if (vec[0] == ‘account’){customerJWT();}}});function customerJWT(bc_email) {var xmlhttp = new XMLHttpRequest();xmlhttp.onreadystatechange = function() {if (xmlhttp.readyState == 4 ) {if (xmlhttp.status == 200) {var rebxmlhttp = new XMLHttpRequest();rebxmlhttp.onreadystatechange = function() {if (rebxmlhttp.readyState == 4 ) {if (rebxmlhttp.status == 200) {console.log(‘Rebillia Message. Authentication Success’);var data = JSON.parse(rebxmlhttp.responseText);document.cookie =”rebillia_token=”+data.token+expires+”; path=/”;}else if (rebxmlhttp.status == 404) {console.log(‘Rebillia Message. Token Error’);}else {console.log(‘Rebillia Message. Authentication Failed’);}}};rebxmlhttp.open(“GET”, rebxmlhttpUrl+xmlhttp.responseText, true);rebxmlhttp.withCredentials = true;rebxmlhttp.send();} else if (xmlhttp.status == 404) {var rebpostxmlhttp = new XMLHttpRequest();rebpostxmlhttp.onreadystatechange = function() {if (rebpostxmlhttp.readyState == 4 ) {if (rebpostxmlhttp.status == 200) {console.log(‘Rebillia Message. Authentication Success. Customer login successfully.’);var data = JSON.parse(rebpostxmlhttp.responseText);document.cookie =”rebillia_token=”+data.token+expires+”; path=/”;}}};params=”bc_email=”+bc_email;rebpostxmlhttp.open(“POST”, rebpostxmlhttpURL, true);rebpostxmlhttp.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);rebpostxmlhttp.withCredentials = true;rebpostxmlhttp.send(params);} else {console.log(‘Rebillia Message. Something went wrong’);}}};xmlhttp.open(“GET”, “/customer/current.jwt?app_client_id=”+appClientId, true);xmlhttp.send();}</script>

Click the "Save" button on the bottom right and go to "Storefront Design" -> "Design Options" -> "Footer Scripts". Implement the following string of code (if you have it there, there is no need to replace the existing one):

<script type="text/javascript">var currentcustomeremailstencil='{{customer.email}}';</script>

If you have entered the code, click on the "Save" button on the bottom right corner.

YOU ARE DONE

From the back-end admin panel of your store, go to "Storefront" -> "Template Files". On the first file showing (normally it is the "403.html" file - but it doesn't matter which), click on the '...' action link and choose "Edit" from the dropdown menu. Search for the "Footer.html" file and click on it. In the right (main) panel, find the bulk of code that starts with: "<div id='rebillia_overlay' "... and replace THE WHOLE BULK with the following code:

<div id='rebillia_overlay' style="z-index:-1; display:none;"></div><script type="text/javascript">var currentcustomeremail = '%%GLOBAL_CurrentCustomerEmail%%';var shopPath = '%%GLOBAL_ShopPathSSL%%';var domainName = 'https://app.rebillia.com';var domainURL = 'https://app.rebillia.com/';var appClientId = "ageychj33ynffm8otcbd88hxt9spicx";var rebpostxmlhttpURL = 'https://app.rebillia.com/login/customers';var rebxmlhttpUrl = 'https://app.rebillia.com/login/customers/';var date = new Date();date.setTime(date.getTime()+(30*60*1000));var expires = "; expires="+date.toGMTString();$(document).ready(function(){var matches=window.location.href.match(/[^\/]+$/);if (matches && matches.length) {var vec=(matches[0].split('.'));if (vec[0] == 'account' || vec[0] == 'checkout' || vec[0] == 'finishorder'){$.getScript(domainName+"/js/embed-"+ vec[0] +".js");}if (vec[0] == 'account'){customerJWT();}}});function customerJWT(bc_email) {var xmlhttp = new XMLHttpRequest();xmlhttp.onreadystatechange = function() {if (xmlhttp.readyState == 4 ) {if (xmlhttp.status == 200) {var rebxmlhttp = new XMLHttpRequest();rebxmlhttp.onreadystatechange = function() {if (rebxmlhttp.readyState == 4 ) {if (rebxmlhttp.status == 200) {console.log('Rebillia Message. Authentication Success');var data = JSON.parse(rebxmlhttp.responseText);document.cookie ="rebillia_token="+data.token+expires+"; path=/";}else if (rebxmlhttp.status == 404) {console.log('Rebillia Message. Token Error');}else {console.log('Rebillia Message. Authentication Failed');}}};rebxmlhttp.open("GET", rebxmlhttpUrl+xmlhttp.responseText, true);rebxmlhttp.withCredentials = true;rebxmlhttp.send();} else if (xmlhttp.status == 404) {var rebpostxmlhttp = new XMLHttpRequest();rebpostxmlhttp.onreadystatechange = function() {if (rebpostxmlhttp.readyState == 4 ) {if (rebpostxmlhttp.status == 200) {console.log('Rebillia Message. Authentication Success. Customer login successfully.');var data = JSON.parse(rebpostxmlhttp.responseText);document.cookie ="rebillia_token="+data.token+expires+"; path=/";}}};params="bc_email="+bc_email;rebpostxmlhttp.open("POST", rebpostxmlhttpURL, true);rebpostxmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");rebpostxmlhttp.withCredentials = true;rebpostxmlhttp.send(params);} else {console.log('Rebillia Message. Something went wrong');}}};xmlhttp.open("GET", "/customer/current.jwt?app_client_id="+appClientId, true);xmlhttp.send();}</script>

Click the "Save" button on the top left corner.

YOU ARE DONE