Vendexo_TrackerBeacon - Version 1.1.0

Version Notes

This release of the tracker beacon includes a controller which handles a referral. It sets a cookie to save the tracking reference ID and then redirects to the next specified URL.

It also includes a digital signature of the tracking signal.

Installation Instructions:
To install the tracker:
1. Login to the Magento admin control panel
2. Go to System->Magento Connect->Magento Connect Manager
3. Under the "Install New Extensions" section click the "Magento Connect" link to search for an extension
4. Search for "Vendexo Tracker Beacon", click on it in the search results.
5. Click the "Install Now" button. You need to get the Extension Key. You need to be logged into the Magentocommerce.com website to get this.
6. Go back to the browser tab for the magento shop admin control panel and paste in the extension key. Click the "Install" button.

After installation, using the magento admin control panel:
Flush the Magento cache System->Cache Management->Flush Magento Cache. Logout of the admin control panel and then log back in again (otherwise you may see a 404 error).

Configure the affiliate program settings using the admin control panel:
Navigate to System -> Configuration and in the Sales panel click "Affiliate Networks". In the Vendexo Affiliate Network group enter the affiliate program code, Vxt code and shop secret as provided to you by Vendexo. Then click the "Save" button.

Download this release

Release Info

Developer S. Brooks
Extension Vendexo_TrackerBeacon
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.1 to 1.1.0

app/code/community/Vendexo/TrackerBeacon/Block/Beacon.php CHANGED
@@ -1,9 +1,104 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
2
  class Vendexo_TrackerBeacon_Block_Beacon extends Mage_Core_Block_Template {
3
  // This is a backing object referenced in the tracking beacon
4
  // template (.phtml) file to obtain dynamic content such
5
  // as the shop code, vxt code, order id and order amount.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  private function getLastOrder() {
8
  $order = null;
9
  $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
@@ -21,6 +116,11 @@ class Vendexo_TrackerBeacon_Block_Beacon extends Mage_Core_Block_Template {
21
  return Mage::getStoreConfig('sales_affiliate_networks/vendexo/vxt_code');
22
  }
23
 
 
 
 
 
 
24
  public function getOrderId() {
25
  $order = $this->getLastOrder();
26
  if ($order) {
@@ -47,6 +147,7 @@ class Vendexo_TrackerBeacon_Block_Beacon extends Mage_Core_Block_Template {
47
  return null;
48
  }
49
  }
 
50
 
51
 
52
  }
1
  <?php
2
+ /* Class containing Magento-specific functionality to integrate
3
+ with the VendexoTracker class, with the aim of
4
+ notifying Vendexo of a sale so that the appropriate
5
+ referral commission for affiliates can be calculated.
6
+
7
+ Copyright (C) 2016 Vendexo
8
+ */
9
+
10
+ require_once(dirname(__DIR__) . '/lib/vendexotracker.php');
11
+
12
  class Vendexo_TrackerBeacon_Block_Beacon extends Mage_Core_Block_Template {
13
  // This is a backing object referenced in the tracking beacon
14
  // template (.phtml) file to obtain dynamic content such
15
  // as the shop code, vxt code, order id and order amount.
16
 
17
+ /* renderLastOrderTracker
18
+ Renders a sale tracker for the just-completed order.
19
+ */
20
+ public function renderLastOrderTracker()
21
+ {
22
+ $order = $this->getLastOrder();
23
+ if ($order) {
24
+ return $this->renderTrackerSale($order);
25
+ } else {
26
+ return '';
27
+ }
28
+ }
29
+
30
+
31
+ /* renderTrackerSale:
32
+ Method to return a string containing the rendered HTML markup
33
+ for the tracker.
34
+ Parameters:
35
+ - $order: The order object.
36
+ Returns:
37
+ A string containing the tracker markup. This can,
38
+ for example, be added to a context array for passing
39
+ into an order confirmation template.
40
+ */
41
+ public function renderTrackerSale($order) {
42
+ $shop_code = $this->getShopCode();
43
+ $vxt_code = $this->getVxtCode();
44
+ $secret = $this->getShopSecret();
45
+ $ctr_id = '';
46
+
47
+ // Get CTR ID from Magento's session, if available:
48
+ $session = Mage::getSingleton('core/session');
49
+ if ($session->hasVxafCtr()) {
50
+ $ctr_id = $session->getVxafCtr();
51
+ // Mage::log("Vendexo_TrackerBeacon_Block_Beacon.render_tracker_sale ctr_id from session: " . $ctr_id);
52
+ }
53
+ // Use the regular cookie value, if available
54
+ if (!empty($_COOKIE['vxaf_ctr'])) {
55
+ $ctr_id = $_COOKIE['vxaf_ctr'];
56
+ // Mage::log("Vendexo_TrackerBeacon_Block_Beacon.render_tracker_sale ctr_id from cookie: " . $ctr_id);
57
+ }
58
+ $client_ip_address = $_SERVER['REMOTE_ADDR'];
59
+ $order_ref = $order->getIncrementId();
60
+ $subtotal = $order->getBaseSubtotal();
61
+ $discount = $order->getBaseDiscountAmount();
62
+ $amount = $subtotal + $discount;
63
+ $currency_code = $order->getBaseCurrencyCode();
64
+ $buyer_email = $order->getCustomerEmail();
65
+
66
+ $coupon_codes = array();
67
+ $coupon_code = $order->getCouponCode();
68
+ if ($coupon_code) {
69
+ $coupon_codes[] = $coupon_code;
70
+ }
71
+ $basket_items = $this->getBasketItems($order);
72
+ $tracker_version = (string)Mage::helper('vendexo_trackerbeacon')->getExtensionVersion();
73
+
74
+ $vendexo_tracker = new VendexoTracker();
75
+ $vendexo_tracker_rendered = $vendexo_tracker->render_tracker(
76
+ $shop_code, $vxt_code, $ctr_id, $client_ip_address,
77
+ $amount, $currency_code, $buyer_email,
78
+ $order_ref, '', '',
79
+ $coupon_codes, $basket_items, $secret, $tracker_version);
80
+ return $vendexo_tracker_rendered;
81
+ }
82
+
83
+ /* getBasketItems:
84
+ Return details of the ordered products in the form required
85
+ for the tracker.
86
+ */
87
+ private function getBasketItems($order) {
88
+ $order_items = $order->getAllVisibleItems();
89
+ $basket_items = array();
90
+ foreach($order_items as $item) {
91
+ $basket_items[] = array(
92
+ 'id' => $item->productId,
93
+ 'name' => $item->name,
94
+ 'product_group_id' => 0, //TODO: Find suitable field, if any
95
+ 'qty' => (int)$item->qtyOrdered,
96
+ 'price' => $item->basePrice,
97
+ );
98
+ }
99
+ return $basket_items;
100
+ }
101
+
102
  private function getLastOrder() {
103
  $order = null;
104
  $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
116
  return Mage::getStoreConfig('sales_affiliate_networks/vendexo/vxt_code');
117
  }
118
 
119
+ public function getShopSecret() {
120
+ return Mage::getStoreConfig('sales_affiliate_networks/vendexo/shop_secret');
121
+ }
122
+
123
+ /*
124
  public function getOrderId() {
125
  $order = $this->getLastOrder();
126
  if ($order) {
147
  return null;
148
  }
149
  }
150
+ */
151
 
152
 
153
  }
app/code/community/Vendexo/TrackerBeacon/Helper/Data.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Class containing Magento-specific functionality to integrate
3
+ with the VendexoTracker class, with the aim of
4
+ notifying Vendexo of a sale so that the appropriate
5
+ referral commission for affiliates can be calculated.
6
+
7
+ Copyright (C) 2016 Vendexo
8
+ */
9
+
10
+
11
+ class Vendexo_TrackerBeacon_Helper_Data extends Mage_Core_helper_Abstract
12
+ {
13
+ public function getExtensionVersion()
14
+ {
15
+ return (string)Mage::getConfig()->getNode()->modules->Vendexo_TrackerBeacon->version;
16
+ }
17
+ }
18
+
19
+ ?>
20
+
app/code/community/Vendexo/TrackerBeacon/controllers/ReferralController.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Vendexo_TrackerBeacon_ReferralController extends Mage_Core_Controller_Front_Action {
3
+ public function indexAction() {
4
+ $vxaf_ctr = isset($_REQUEST['vxaf-ctr'])? $_REQUEST['vxaf-ctr'] : '';
5
+
6
+ if (!empty($vxaf_ctr)) {
7
+ // Remember it in the "session" cookie:
8
+ $session = Mage::getSingleton('core/session');
9
+ $session->setVxafCtr($vxaf_ctr);
10
+
11
+ // Also set a regular cookie:
12
+ $expires = time() + 365 * 24 * 3600;
13
+ $domain = strtolower($_SERVER['HTTP_HOST']);
14
+ if (substr_compare($domain, 'www.', 0, 4) == 0) {
15
+ $domain = substr($domain, 3);
16
+ }
17
+ setcookie('vxaf_ctr', $vxaf_ctr, $expires, '/', $domain);
18
+ }
19
+ $next = isset($_REQUEST['next'])? $_REQUEST['next'] : '';
20
+ if (!$next) {
21
+ $next = isset($_REQUEST['url'])? $_REQUEST['url'] : '';
22
+ }
23
+ if (!$next) {
24
+ $next = Mage::getBaseUrl();
25
+ }
26
+ $this->_redirectUrl($next);
27
+ }
28
+ }
29
+ ?>
app/code/community/Vendexo/TrackerBeacon/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Vendexo_TrackerBeacon>
5
- <version>1.0.1</version>
6
  </Vendexo_TrackerBeacon>
7
  </modules>
8
  <global>
@@ -11,8 +11,22 @@
11
  <class>Vendexo_TrackerBeacon_Block</class>
12
  </vendexo_trackerbeacon>
13
  </blocks>
 
 
 
 
 
14
  </global>
15
  <frontend>
 
 
 
 
 
 
 
 
 
16
  <layout>
17
  <updates>
18
  <vendexo_trackerbeacon module="Vendexo_TrackerBeacon">
2
  <config>
3
  <modules>
4
  <Vendexo_TrackerBeacon>
5
+ <version>1.1.0</version>
6
  </Vendexo_TrackerBeacon>
7
  </modules>
8
  <global>
11
  <class>Vendexo_TrackerBeacon_Block</class>
12
  </vendexo_trackerbeacon>
13
  </blocks>
14
+ <helpers>
15
+ <vendexo_trackerbeacon>
16
+ <class>Vendexo_TrackerBeacon_Helper</class>
17
+ </vendexo_trackerbeacon>
18
+ </helpers>
19
  </global>
20
  <frontend>
21
+ <routers>
22
+ <trackerbeacon>
23
+ <use>standard</use>
24
+ <args>
25
+ <module>Vendexo_TrackerBeacon</module>
26
+ <frontName>vendexoaffiliates</frontName>
27
+ </args>
28
+ </trackerbeacon>
29
+ </routers>
30
  <layout>
31
  <updates>
32
  <vendexo_trackerbeacon module="Vendexo_TrackerBeacon">
app/code/community/Vendexo/TrackerBeacon/etc/system.xml CHANGED
@@ -34,6 +34,14 @@
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>0</show_in_store>
36
  </vxt_code>
 
 
 
 
 
 
 
 
37
  </fields>
38
  </vendexo>
39
  </groups>
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>0</show_in_store>
36
  </vxt_code>
37
+ <shop_secret translate="label">
38
+ <label>Shop Secret</label>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>70</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </shop_secret>
45
  </fields>
46
  </vendexo>
47
  </groups>
app/code/community/Vendexo/TrackerBeacon/lib/vendexotracker.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* Class to generate the code to notify Vendexo of a sale
3
+ so that the appropriate referral commission for affiliates
4
+ can be calculated.
5
+
6
+ Copyright (C) 2016 Vendexo
7
+ */
8
+
9
+
10
+ class VendexoTracker {
11
+ const MAX_NAME_LENGTH = 20;
12
+ const TRACK_URL_DOMAIN = 'track.vendexo.com';
13
+ const TRACK_URL_PATH = '/aff/track/';
14
+
15
+ public function get_track_url_domain() {
16
+ return self::TRACK_URL_DOMAIN;
17
+ }
18
+
19
+ public function get_track_url_path() {
20
+ return self::TRACK_URL_PATH;
21
+ }
22
+
23
+ /* get_tracking_params:
24
+ Returns an array of two-element arrays. The two-element arrays
25
+ consist of a name and value. Using this format enables
26
+ the parameters to contain multiple entries where the parameter
27
+ name is the same (e.g. "couponCode").
28
+ Parameters:
29
+ $shop_code: The ID code of the shop/affiliate program.
30
+ $ctr_id: The tracking ID, if known, otherwise null or ''.
31
+ $client_ip_address: The user's IP address.
32
+ $order_amount: The value of the order (ideally excluding shipping
33
+ and tax).
34
+ Set to null or '' for notifying goals.
35
+ $currency_code: The three-letter code of the order currency.
36
+ $buyer_email: The e-mail address of the customer/user who placed
37
+ the order or achieved the goal.
38
+ $order_id: The ID of the order (as you would identify it on your
39
+ control panel).
40
+ Set to null or '' for notifying goals.
41
+ $goal_code: For goals, this is the ID code identifying the goal type.
42
+ Set to '' for sales.
43
+ $goal_id: For goals, this is the unique ID identifying the goal
44
+ achievment by the user. Set to '' for sales.
45
+ $coupon_codes: An array of the coupon codes (promo codes) used with
46
+ the order.
47
+ $basket_items: An array containing details of the items purchased.
48
+ Each element to be an associative array in the following format:
49
+ 'id': The id of the product
50
+ 'name': The name of the product
51
+ 'product_group_id': The ID of the product group (to identify
52
+ commission payable) or else '' if using the default.
53
+ 'qty': The quantity purchased
54
+ 'price': The product's unit price (in the currency specified
55
+ above)
56
+ $secret: A secret code, provided by Vendexo, used to generate a
57
+ digital signature for security purposes.
58
+ $tracker_version: The version of the Vendexo tracker plugin/extension.
59
+ */
60
+ public function get_tracking_params($shop_code, $ctr_id,
61
+ $client_ip_address, $order_amount, $currency_code,
62
+ $buyer_email, $order_id, $goal_code, $goal_id,
63
+ $coupon_codes, $basket_items, $secret, $tracker_version) {
64
+
65
+ $ctr_id = ($ctr_id)? $ctr_id : '';
66
+ $client_ip_address = ($client_ip_address)? $client_ip_address : ((isset($_SERVER['REMOTE_ADDR']))? $_SERVER['REMOTE_ADDR'] : '');
67
+ $amount = ($order_amount)? $order_amount : '0.00';
68
+ $currency_code = strtoupper($currency_code);
69
+ $email_hash = hash('sha256', strval($buyer_email));
70
+ $coupon_codes = ($coupon_codes)? $coupon_codes : array();
71
+ $basket_items = ($basket_items)? $basket_items : array();
72
+ if ($order_id) { // Sale
73
+ $action = 'sale';
74
+ } else { // Goal
75
+ $action = 'goal';
76
+ }
77
+
78
+ $params = array( // Element order is important (used in signing)
79
+ array('tv', $tracker_version),
80
+ array('action', $action),
81
+ array('shopCode', $shop_code),
82
+ array('ctr', $ctr_id),
83
+ array('clientIPAddress', $client_ip_address),
84
+ array('amount', $amount),
85
+ array('currency', $currency_code),
86
+ array('emailHash', $email_hash)
87
+ );
88
+ if ($order_id) { // Sale
89
+ $params[] = array('orderRef', $order_id);
90
+ } else { // Goal
91
+ $params[] = array('gc', $goal_code);
92
+ $params[] = array('gr', $goal_id);
93
+ }
94
+ // Coupon codes:
95
+ foreach($coupon_codes as $cc) {
96
+ $params[] = array('couponCode', $cc);
97
+ }
98
+ // Basket items:
99
+ $i = 0;
100
+ foreach($basket_items as $item) {
101
+ $item_id = (isset($item['id']))? $item['id'] : '';
102
+ $item_name = (isset($item['name']))? mb_substr($item['name'], 0, self::MAX_NAME_LENGTH) : '';
103
+ $item_product_group_id = (isset($item['product_group_id']))? $item['product_group_id'] : '';
104
+ $item_qty = (isset($item['qty']))? $item['qty'] : 1;
105
+ $item_price = (isset($item['price']))? $item['price'] : '0.00';
106
+
107
+ $index = strval($i);
108
+ $params[] = array('itmId' . $index, $item_id);
109
+ $params[] = array('itmName' . $index, $item_name);
110
+ $params[] = array('itmPGId' . $index, $item_product_group_id);
111
+ $params[] = array('itmQty' . $index, $item_qty);
112
+ $params[] = array('itmPrice' . $index, $item_price);
113
+ $i++;
114
+ }
115
+
116
+ // Sign it:
117
+ $sig_items = array();
118
+ foreach($params as $tuple) {
119
+ $sig_items[] = $tuple[1]; // The parameter value
120
+ }
121
+ $params[] = array('sig', $this->make_list_signature($sig_items, $secret));
122
+ return $params;
123
+ }
124
+
125
+
126
+ /*
127
+ get_tracking_params_str:
128
+ Returns a string consisting of the urlencoded tracking parameters.
129
+ For parameter descriptions see the descriptions for
130
+ the get_tracking_params method above.
131
+ */
132
+ public function get_tracking_params_str($shop_code, $ctr_id,
133
+ $client_ip_address, $order_amount, $currency_code,
134
+ $buyer_email, $order_id, $goal_code, $goal_id,
135
+ $coupon_codes, $basket_items, $secret, $tracker_version) {
136
+
137
+ return $this->urlencode_params($this->get_tracking_params(
138
+ $shop_code, $ctr_id, $client_ip_address, $order_amount,
139
+ $currency_code, $buyer_email, $order_id, $goal_code, $goal_id,
140
+ $coupon_codes, $basket_items, $secret, $tracker_version));
141
+ }
142
+
143
+
144
+ /*
145
+ render_tracker:
146
+ Render the tracker and return it as a string .
147
+ For parameter descriptions see the descriptions for
148
+ the get_tracking_params method above.
149
+ The $vxt_code parameter is a code provided by Vendexo.
150
+ */
151
+ public function render_tracker($shop_code, $vxt_code, $ctr_id,
152
+ $client_ip_address, $order_amount, $currency_code,
153
+ $buyer_email, $order_id, $goal_code, $goal_id,
154
+ $coupon_codes, $basket_items, $secret, $tracker_version) {
155
+
156
+ $param_str = $this->get_tracking_params_str($shop_code, $ctr_id,
157
+ $client_ip_address, $order_amount, $currency_code,
158
+ $buyer_email, $order_id, $goal_code, $goal_id,
159
+ $coupon_codes, $basket_items, $secret, $tracker_version);
160
+
161
+ $tracker_lines = array(
162
+ '<script type="text/javascript">',
163
+ '(function() {',
164
+ 'var lProtocol;',
165
+ "if (window.location.protocol.toLowerCase() == 'https:') {",
166
+ "lProtocol = 'https:';",
167
+ "} else {",
168
+ "lProtocol = 'http:';",
169
+ "}",
170
+ 'var lUrl = lProtocol + "//' . $this->get_track_url_domain() . $this->get_track_url_path() . 'sale/v1/js/' . $shop_code . '/' . $vxt_code . '/?' . $param_str . '";',
171
+ "var s = document.createElement('script');",
172
+ "s.type = 'text/javascript';",
173
+ "s.async = 1;",
174
+ "s.src = lUrl;",
175
+ "var s0 = document.getElementsByTagName('script')[0];",
176
+ "s0.parentNode.insertBefore(s, s0);",
177
+ '}());',
178
+ '</script>',
179
+ '<noscript><img src="https://' . $this->get_track_url_domain() . $this->get_track_url_path() . 'sale/v1/img/' . $shop_code . '/' . $vxt_code . '/?' . $param_str . '" alt="." width="1" height="1" style="border: 0 none;" /></noscript>'
180
+ );
181
+ return implode("\n", $tracker_lines);
182
+ }
183
+
184
+ protected function urlencode_params($obj) {
185
+ if (is_array($obj)) {
186
+ if (!count($obj)) {
187
+ return '';
188
+ }
189
+ if (isset($obj[0])) {
190
+ if (is_array($obj[0])) { // $obj is a list of tuples: (key, value) pairs
191
+ $vals = array();
192
+ foreach($obj as $tuple) {
193
+ if (is_array($tuple[1])) { // Value is a list of values
194
+ foreach($tuple[1] as $val) {
195
+ $vals[] = urlencode($tuple[0]) . '=' . urlencode($val);
196
+ }
197
+ } else {
198
+ $vals[] = urlencode($tuple[0]) . '=' . urlencode($tuple[1]);
199
+ }
200
+ }
201
+ return implode('&', $vals);
202
+ } else {
203
+ throw new Exception("obj has an unsupported structure.");
204
+ }
205
+ } else { // An associative array, keys = param names
206
+ $vals = array();
207
+ foreach($obj as $key => $value) {
208
+ if (is_array($value)) { // Value is a list of values
209
+ foreach($value as $val) {
210
+ $vals[] = urlencode($key) . '=' . urlencode($val);
211
+ }
212
+ } else {
213
+ $vals[] = urlencode($key) . '=' . urlencode($value);
214
+ }
215
+ }
216
+ return implode('&', $vals);
217
+ }
218
+ } else {
219
+ return urlencode(strval($obj));
220
+ }
221
+ }
222
+
223
+ protected function make_list_signature($sig_items, $secret) {
224
+ $salt = $this->get_random_string(16);
225
+ return $this->build_list_signature($sig_items, $secret, $salt);
226
+ }
227
+
228
+ protected function build_list_signature($sig_items, $secret, $salt) {
229
+ $terms = array();
230
+ foreach($sig_items as $value) {
231
+ $terms[] = strval($value);
232
+ }
233
+ $plain = implode('', $terms);
234
+ $signature = $this->base64_hmac($salt . 'signer', $plain, $secret);
235
+ return $salt . '$' . $signature;
236
+ }
237
+
238
+ protected function get_random_string($len) {
239
+ $buf = array();
240
+ $chars = array_merge(range('A', 'Z'), range('a', 'z'), range('0', '9'));
241
+ $max = count($chars) - 1;
242
+ for ($i = 0; $i < $len; $i++) {
243
+ $buf[] = $chars[mt_rand(0, $max)];
244
+ }
245
+ return implode('', $buf);
246
+ }
247
+
248
+ protected function base64_hmac($salt, $value, $secret) {
249
+ return $this->urlsafe_b64encode_nopad($this->salted_hmac($salt, $value, $secret));
250
+ }
251
+
252
+ protected function urlsafe_b64encode_nopad($s) {
253
+ return str_replace('=', '', strtr(base64_encode($s), "+/", "-_"));
254
+ }
255
+
256
+ protected function salted_hmac($salt, $value, $secret) {
257
+ $key = sha1($salt . $secret, true);
258
+ return hash_hmac('sha1', $value, $key, true);
259
+ }
260
+ }
261
+
262
+ ?>
app/design/frontend/base/default/template/vendexo_trackerbeacon/beacon.phtml CHANGED
@@ -1,29 +1,4 @@
1
  <!-- begin Vendexo Affiliate Network tracking -->
2
- <script type="text/javascript">
3
- /* <![CDATA[ */
4
- (function() {
5
- var lOrderRef = encodeURIComponent("<?php echo($this->getOrderId()); ?>");
6
- var lAmount = "<?php echo($this->getOrderAmount()); ?>";
7
- // If this contains a currency symbol or thousands separator add code to remove them.
8
- lAmount = lAmount.replace(/,/g, '');
9
- var lCurrency = "<?php echo($this->getCurrencyCode()); ?>"; // Or specify an empty string to use shop's native currency.
10
- var lVersion = "v1";
11
- var lShopCode = "<?php echo($this->getShopCode()); ?>";
12
- var lVxTCode = "<?php echo($this->getVxtCode()); ?>";
13
- var lProtocol;
14
- if (window.location.protocol.toLowerCase() == 'https:') {
15
- lProtocol = 'https:';
16
- } else {
17
- lProtocol = 'http:';
18
- }
19
- var lUrl = lProtocol + "//track.vendexo.com/aff/track/sale/" + lVersion + "/js/" + lShopCode + "/" + lVxTCode + "/?orderRef=" + lOrderRef + "&amp;amount=" + lAmount;
20
- if (lCurrency) {
21
- lUrl += '&amp;currency=' + lCurrency;
22
- }
23
- document.write('<scr' + 'ipt type="text/javascript" src="' + lUrl + '"></scr' + 'ipt>');
24
- })();
25
- /* ]]> */
26
- </script>
27
- <noscript><img src="http://track.vendexo.com/aff/track/sale/v1/img/<?php echo($this->getShopCode()); ?>/<?php echo($this->getVxtCode()); ?>/?orderRef=<?php echo($this->getOrderId()); ?>&amp;amount=<?php echo($this->getOrderAmount()); ?>&amp;currency=<?php echo($this->getCurrencyCode()); ?>" alt="." /></noscript>
28
  <!-- end Vendexo Affiliate Network tracking -->
29
 
1
  <!-- begin Vendexo Affiliate Network tracking -->
2
+ <?php echo $this->renderLastOrderTracker(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  <!-- end Vendexo Affiliate Network tracking -->
4
 
package.xml CHANGED
@@ -1,18 +1,39 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Vendexo_TrackerBeacon</name>
4
- <version>1.0.1</version>
5
  <stability>stable</stability>
6
- <license uri="https://gnu.org/licenses/gpl.html">GNU GPL version 3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This enables merchants to have an affiliate program with Vendexo to help get extra visitors to their shop.</summary>
10
  <description>This places a beacon-type tracker on the page shown after successful payment at the end of the checkout. If the buyer was referred via the Vendexo Affiliate Network, this enables the vendexo.com software to pay a sales commission to the affiliate who referred the customer to the merchant's shop. After installation it is necessary to clear the Magento cache via the admin control panel System-&gt;Cache Management-&gt;Flush Magento Cache. You will also have to log out of the admin control panel and log back in again in order to configure the tracker settings.</description>
11
- <notes>This release fixes a problem seen on Linux hosts with the previous version (1.0.0) whereby an exception is raised due to a block being invalid. This is because the file name for the block "beacon.php" should have been named "Beacon.php" in the directory app/code/community/Vendexo/TrackerBeacon/Block.</notes>
12
- <authors><author><name>Stephen Brooks</name><user>smbrooks</user><email>s.brooks@vendexo.com</email></author></authors>
13
- <date>2015-10-14</date>
14
- <time>17:26:21</time>
15
- <contents><target name="magecommunity"><dir name="Vendexo"><dir name="TrackerBeacon"><dir name="Block"><file name="Beacon.php" hash="dd5676ffb84dbc41fcbb7037df8b8111"/></dir><dir name="etc"><file name="adminhtml.xml" hash="fd4480d9a9919fef7ab8614929a5f78f"/><file name="config.xml" hash="99659c2543e4790c145411d0e1d7790b"/><file name="system.xml" hash="f29b13d986934819890b83e2fe0275df"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vendexo_trackerbeacon.xml" hash="151393bf702771fa556984c93c80fa47"/></dir><dir name="template"><dir name="vendexo_trackerbeacon"><file name="beacon.phtml" hash="b415a9135a9a86ffcdfd7f6af5ea9167"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vendexo_TrackerBeacon.xml" hash="87e366ba6dc4f83e9486e3ce1f37e820"/></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Vendexo_TrackerBeacon</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This enables merchants to have an affiliate program with Vendexo to help get extra visitors to their shop.</summary>
10
  <description>This places a beacon-type tracker on the page shown after successful payment at the end of the checkout. If the buyer was referred via the Vendexo Affiliate Network, this enables the vendexo.com software to pay a sales commission to the affiliate who referred the customer to the merchant's shop. After installation it is necessary to clear the Magento cache via the admin control panel System-&gt;Cache Management-&gt;Flush Magento Cache. You will also have to log out of the admin control panel and log back in again in order to configure the tracker settings.</description>
11
+ <notes>This release of the tracker beacon includes a controller which handles a referral. It sets a cookie to save the tracking reference ID and then redirects to the next specified URL.&#xD;
12
+ &#xD;
13
+ It also includes a digital signature of the tracking signal.&#xD;
14
+ &#xD;
15
+ &#xD;
16
+ Installation Instructions:&#xD;
17
+ To install the tracker:&#xD;
18
+ 1. Login to the Magento admin control panel&#xD;
19
+ 2. Go to System-&gt;Magento Connect-&gt;Magento Connect Manager&#xD;
20
+ 3. Under the "Install New Extensions" section click the "Magento Connect" link to search for an extension&#xD;
21
+ 4. Search for "Vendexo Tracker Beacon", click on it in the search results.&#xD;
22
+ 5. Click the "Install Now" button. You need to get the Extension Key. You need to be logged into the Magentocommerce.com website to get this.&#xD;
23
+ 6. Go back to the browser tab for the magento shop admin control panel and paste in the extension key. Click the "Install" button.&#xD;
24
+ &#xD;
25
+ &#xD;
26
+ After installation, using the magento admin control panel:&#xD;
27
+ Flush the Magento cache System-&gt;Cache Management-&gt;Flush Magento Cache. Logout of the admin control panel and then log back in again (otherwise you may see a 404 error).&#xD;
28
+ &#xD;
29
+ &#xD;
30
+ Configure the affiliate program settings using the admin control panel:&#xD;
31
+ Navigate to System -&gt; Configuration and in the Sales panel click "Affiliate Networks". In the Vendexo Affiliate Network group enter the affiliate program code, Vxt code and shop secret as provided to you by Vendexo. Then click the "Save" button.&#xD;
32
+ </notes>
33
+ <authors><author><name>S. Brooks</name><user>smbrooks</user><email>s.brooks@vendexo.com</email></author></authors>
34
+ <date>2016-10-19</date>
35
+ <time>14:59:53</time>
36
+ <contents><target name="magecommunity"><dir name="Vendexo"><dir name="TrackerBeacon"><dir name="Block"><file name="Beacon.php" hash="7f3f4f637acd629c85c565d9eee0550f"/></dir><dir name="Helper"><file name="Data.php" hash="ac1a278f1c92147f8f50b72f50c4d822"/></dir><dir name="controllers"><file name="ReferralController.php" hash="3b0712c2cc8b9fcc1ccc7f0dbc720a5e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="fd4480d9a9919fef7ab8614929a5f78f"/><file name="config.xml" hash="8081dbfd38ee92c3d99af31844087728"/><file name="system.xml" hash="229313e9561047e387d964af6e51e89b"/></dir><dir name="lib"><file name="vendexotracker.php" hash="2907c37033d5d49d63dc8e0451b3b949"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vendexo_trackerbeacon.xml" hash="151393bf702771fa556984c93c80fa47"/></dir><dir name="template"><dir name="vendexo_trackerbeacon"><file name="beacon.phtml" hash="8a22aa2a113634ef9481b8c0929b2976"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vendexo_TrackerBeacon.xml" hash="87e366ba6dc4f83e9486e3ce1f37e820"/></dir></target></contents>
37
  <compatible/>
38
+ <dependencies><required><php><min>5.3.0</min><max>7.0.11</max></php></required></dependencies>
39
  </package>