Version Notes
- paypal integration fix
- HTTP to HTTPS redirection in case of API communication fixed
- API tracking fixed based on new HTTP/HTTPS approach
Download this release
Release Info
| Developer | Quality Unit, LLC |
| Extension | Qualityunit_Pap |
| Version | 1.0.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.6 to 1.0.7
app/code/local/Qualityunit/Pap/Model/Config.php
CHANGED
|
@@ -48,13 +48,17 @@ class Qualityunit_Pap_Model_Config extends Mage_Core_Model_Config_Base {
|
|
| 48 |
}
|
| 49 |
|
| 50 |
// sanitize the URL
|
| 51 |
-
$server = str_replace('https', 'http', $server);
|
| 52 |
$server = str_replace('http://', '', $server);
|
| 53 |
if (substr($server,-1) == '/') $server = substr($server,0,-1);
|
| 54 |
|
| 55 |
return $server;
|
| 56 |
}
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
public function getTrackingMethod() {
|
| 59 |
return Mage::getStoreConfig('pap_config/tracking/trackingmethod');
|
| 60 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
// sanitize the URL
|
| 51 |
+
$server = str_replace('https://', 'http://', $server);
|
| 52 |
$server = str_replace('http://', '', $server);
|
| 53 |
if (substr($server,-1) == '/') $server = substr($server,0,-1);
|
| 54 |
|
| 55 |
return $server;
|
| 56 |
}
|
| 57 |
|
| 58 |
+
public function getAPIPath() {
|
| 59 |
+
return 'http://'.$this->getInstallationPath().'/scripts/server.php';
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
public function getTrackingMethod() {
|
| 63 |
return Mage::getStoreConfig('pap_config/tracking/trackingmethod');
|
| 64 |
}
|
app/code/local/Qualityunit/Pap/Model/Pap.php
CHANGED
|
@@ -1,320 +1,323 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
class Qualityunit_Pap_Model_Pap extends Mage_Core_Model_Abstract {
|
| 3 |
-
protected $papSession;
|
| 4 |
-
public $declined = 'D';
|
| 5 |
-
public $pending = 'P';
|
| 6 |
-
public $approved = 'A';
|
| 7 |
-
|
| 8 |
-
public function getSession() {
|
| 9 |
-
if (($this->papSession != '') && ($this->papSession != null)) {
|
| 10 |
-
|
| 11 |
-
}
|
| 12 |
-
|
| 13 |
-
Mage::getSingleton('pap/config')->includePapAPI();
|
| 14 |
-
$config = Mage::getSingleton('pap/config');
|
| 15 |
-
$url = $config->
|
| 16 |
-
$username = $config->getAPICredential('username');
|
| 17 |
-
$password = $config->getAPICredential('pass');
|
| 18 |
-
|
| 19 |
-
$session = new Gpf_Api_Session($url);
|
| 20 |
-
if (!$session->login($username, $password)) {
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
$
|
| 47 |
-
$
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
$
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
$
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
$
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
$request->
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
if ($state === Mage_Sales_Model_Order::
|
| 129 |
-
return $this->
|
| 130 |
-
}
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
$
|
| 139 |
-
|
| 140 |
-
$
|
| 141 |
-
$
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
$
|
| 151 |
-
$
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
$
|
| 155 |
-
$
|
| 156 |
-
|
| 157 |
-
$sales[$i]['
|
| 158 |
-
$sales[$i]['
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
$
|
| 172 |
-
|
| 173 |
-
$
|
| 174 |
-
$
|
| 175 |
-
|
| 176 |
-
$sales[0]['
|
| 177 |
-
$sales[0]['
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
$order->
|
| 196 |
-
}
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
$
|
| 220 |
-
$
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
$sale->
|
| 232 |
-
$sale->
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
if ($item['
|
| 237 |
-
if ($item['
|
| 238 |
-
if ($item['
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
case '
|
| 250 |
-
return
|
| 251 |
-
break;
|
| 252 |
-
case '
|
| 253 |
-
return (!empty($item)) ? $item->
|
| 254 |
-
break;
|
| 255 |
-
case '
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
return
|
| 267 |
-
break;
|
| 268 |
-
case '
|
| 269 |
-
return (!empty($item)) ? $item->
|
| 270 |
-
break;
|
| 271 |
-
case '
|
| 272 |
-
return (!empty($item)) ? $item->
|
| 273 |
-
break;
|
| 274 |
-
case '
|
| 275 |
-
return (!empty($item)) ? $item->
|
| 276 |
-
break;
|
| 277 |
-
case '
|
| 278 |
-
return (!empty($item)) ?
|
| 279 |
-
break;
|
| 280 |
-
case '
|
| 281 |
-
return (!empty($item)) ? $item->
|
| 282 |
-
break;
|
| 283 |
-
case '
|
| 284 |
-
return (!empty($item)) ? $item->
|
| 285 |
-
break;
|
| 286 |
-
case '
|
| 287 |
-
return (!empty($item)) ? $item->
|
| 288 |
-
break;
|
| 289 |
-
case '
|
| 290 |
-
return (!empty($
|
| 291 |
-
break;
|
| 292 |
-
case '
|
| 293 |
-
return (!empty($product)) ? $product->
|
| 294 |
-
break;
|
| 295 |
-
case '
|
| 296 |
-
return (!empty($
|
| 297 |
-
break;
|
| 298 |
-
case '
|
| 299 |
-
return (!empty($order)) ? $order->
|
| 300 |
-
break;
|
| 301 |
-
case '
|
| 302 |
-
return (!empty($order)
|
| 303 |
-
break;
|
| 304 |
-
case '
|
| 305 |
-
return (!empty($order) && $order->
|
| 306 |
-
break;
|
| 307 |
-
case '
|
| 308 |
-
$
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
return (!empty($
|
| 316 |
-
break;
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Qualityunit_Pap_Model_Pap extends Mage_Core_Model_Abstract {
|
| 3 |
+
protected $papSession;
|
| 4 |
+
public $declined = 'D';
|
| 5 |
+
public $pending = 'P';
|
| 6 |
+
public $approved = 'A';
|
| 7 |
+
|
| 8 |
+
public function getSession() {
|
| 9 |
+
if (($this->papSession != '') && ($this->papSession != null)) {
|
| 10 |
+
return $this->papSession;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
Mage::getSingleton('pap/config')->includePapAPI();
|
| 14 |
+
$config = Mage::getSingleton('pap/config');
|
| 15 |
+
$url = $config->getAPIPath();
|
| 16 |
+
$username = $config->getAPICredential('username');
|
| 17 |
+
$password = $config->getAPICredential('pass');
|
| 18 |
+
|
| 19 |
+
$session = new Gpf_Api_Session($url);
|
| 20 |
+
if (!$session->login($username, $password)) {
|
| 21 |
+
$session = new Gpf_Api_Session(str_replace('http://','https://',$url));
|
| 22 |
+
if (!$session->login($username, $password)) {
|
| 23 |
+
Mage::log('Postaffiliatepro: Could not initiate API session: '.$session->getMessage());
|
| 24 |
+
return null;
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
$this->papSession = $session;
|
| 29 |
+
return $this->papSession;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
public function setOrderStatus($order, $status, $refunded = array()) {
|
| 33 |
+
Mage::log('Postaffiliatepro: Changing status of order '.$order->getIncrementId()." to '$status'");
|
| 34 |
+
$session = $this->getSession();
|
| 35 |
+
|
| 36 |
+
if (empty($session)) {
|
| 37 |
+
Mage::log('Postaffiliatepro: The module is still not configured!');
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
$request = new Pap_Api_TransactionsGrid($session);
|
| 42 |
+
$request->addFilter('orderid', Gpf_Data_Filter::LIKE, $order->getIncrementId().'(%');
|
| 43 |
+
$request->setLimit(0, 900);
|
| 44 |
+
try {
|
| 45 |
+
$request->sendNow();
|
| 46 |
+
$grid = $request->getGrid();
|
| 47 |
+
$recordset = $grid->getRecordset();
|
| 48 |
+
|
| 49 |
+
$ids = array();
|
| 50 |
+
$refundIDs = array();
|
| 51 |
+
$approveIDs = array();
|
| 52 |
+
foreach($recordset as $record) {
|
| 53 |
+
if (count($refunded)) {
|
| 54 |
+
if ($status == 'A') {
|
| 55 |
+
if (in_array($record->get('productid'), $refunded)) {
|
| 56 |
+
$refundIDs[] = $record->get('id');
|
| 57 |
+
}
|
| 58 |
+
else {
|
| 59 |
+
$approveIDs[] = $record->get('id');
|
| 60 |
+
}
|
| 61 |
+
continue;
|
| 62 |
+
}
|
| 63 |
+
elseif ($status == 'D') {
|
| 64 |
+
if (in_array($record->get('productid'), $refunded)) {
|
| 65 |
+
$refundIDs[] = $record->get('id');
|
| 66 |
+
}
|
| 67 |
+
continue;
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
$ids[] = $record->get('id');
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
catch (Exception $e) {
|
| 74 |
+
Mage::log('An API error while searching for the order with postfix: '.$e->getMessage());
|
| 75 |
+
return false;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
$transaction = new Pap_Api_Transaction($session);
|
| 79 |
+
if (count($refundIDs) == 0 && count($approveIDs) == 0 && count($ids) == 0) {
|
| 80 |
+
$items = $order->getAllVisibleItems();
|
| 81 |
+
foreach ($items as $i => $item) {
|
| 82 |
+
$productid = $item->getProductId();
|
| 83 |
+
$product = Mage::getModel('catalog/product')->load($productid);
|
| 84 |
+
|
| 85 |
+
$transaction->setOrderID($order->getIncrementId()."($i)");
|
| 86 |
+
if ($status == $this->approved) {
|
| 87 |
+
if (count($refunded) && in_array($product->getSku(), $refunded)) { // if we are refunding only specific order items
|
| 88 |
+
$transaction->declineByOrderId('');
|
| 89 |
+
continue;
|
| 90 |
+
}
|
| 91 |
+
$transaction->approveByOrderId('');
|
| 92 |
+
}
|
| 93 |
+
if ($status == $this->declined) {
|
| 94 |
+
if (count($refunded) && !in_array($product->getSku(), $refunded)) { // if we are refunding only specific order items
|
| 95 |
+
continue;
|
| 96 |
+
}
|
| 97 |
+
$transaction->declineByOrderId('');
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
return;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
try {
|
| 104 |
+
Mage::log('We will be changing status of IDs: '.print_r($ids,true));
|
| 105 |
+
$request = new Gpf_Rpc_FormRequest('Pap_Merchants_Transaction_TransactionsForm', 'changeStatus', $session);
|
| 106 |
+
if (!empty($refundIDs)) {
|
| 107 |
+
$request->addParam('ids',new Gpf_Rpc_Array($refundIDs));
|
| 108 |
+
$request->addParam('status','D');
|
| 109 |
+
$request->sendNow();
|
| 110 |
+
}
|
| 111 |
+
if (!empty($approveIDs)) {
|
| 112 |
+
$request->addParam('ids',new Gpf_Rpc_Array($approveIDs));
|
| 113 |
+
$request->addParam('status','A');
|
| 114 |
+
$request->sendNow();
|
| 115 |
+
}
|
| 116 |
+
$request->addParam('ids',new Gpf_Rpc_Array($ids));
|
| 117 |
+
$request->addParam('status',$status);
|
| 118 |
+
$request->sendNow();
|
| 119 |
+
return true;
|
| 120 |
+
}
|
| 121 |
+
catch (Exception $e) {
|
| 122 |
+
Mage::log('API error while status changing: '.$e->getMessage());
|
| 123 |
+
return false;
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
private function getStatus($state) {
|
| 128 |
+
if ($state === Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $state === Mage_Sales_Model_Order::STATE_NEW || $state === Mage_Sales_Model_Order::STATE_PROCESSING) {
|
| 129 |
+
return $this->pending;
|
| 130 |
+
}
|
| 131 |
+
if ($state === Mage_Sales_Model_Order::STATE_COMPLETE) {
|
| 132 |
+
return $this->approved;
|
| 133 |
+
}
|
| 134 |
+
return $this->declined;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
public function getOrderSaleDetails($order) {
|
| 138 |
+
$config = Mage::getSingleton('pap/config');
|
| 139 |
+
|
| 140 |
+
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
| 141 |
+
$couponcode = $quote->getCouponCode();
|
| 142 |
+
|
| 143 |
+
$sales = array();
|
| 144 |
+
$status = $this->getStatus($order->getState());
|
| 145 |
+
|
| 146 |
+
if ($config->getPerProduct()) { // per product tracking
|
| 147 |
+
$items = $order->getAllVisibleItems();
|
| 148 |
+
|
| 149 |
+
foreach($items as $i=>$item) {
|
| 150 |
+
$productid = $item->getProductId();
|
| 151 |
+
$product = Mage::getModel('catalog/product')->load($productid);
|
| 152 |
+
|
| 153 |
+
$sales[$i] = array();
|
| 154 |
+
$subtotal = ($item->getBaseRowTotal() == '') ? $item->getBasePrice() : $item->getBaseRowTotal();
|
| 155 |
+
$discount = abs($item->getBaseDiscountAmount());
|
| 156 |
+
|
| 157 |
+
$sales[$i]['totalcost'] = $subtotal - $discount;
|
| 158 |
+
$sales[$i]['orderid'] = $order->getIncrementId();
|
| 159 |
+
$sales[$i]['productid'] = $product->getSku();
|
| 160 |
+
$sales[$i]['couponcode'] = $couponcode;
|
| 161 |
+
$sales[$i]['status'] = $status;
|
| 162 |
+
|
| 163 |
+
for ($n = 1; $n < 6; $n++) {
|
| 164 |
+
if ($config->getData($n)) {
|
| 165 |
+
$sales[$i]['data'.$n] = $this->changeExtraData($config->getData($n), $order, $item, $product);
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
else { // per order tracking
|
| 171 |
+
$sales[0] = array();
|
| 172 |
+
|
| 173 |
+
$subtotal = $order->getBaseSubtotal();
|
| 174 |
+
$discount = abs($order->getBaseDiscountAmount());
|
| 175 |
+
|
| 176 |
+
$sales[0]['totalcost'] = $subtotal - $discount;
|
| 177 |
+
$sales[0]['orderid'] = $order->getIncrementId();
|
| 178 |
+
$sales[0]['productid'] = null;
|
| 179 |
+
$sales[0]['couponcode'] = $couponcode;
|
| 180 |
+
$sales[0]['status'] = $status;
|
| 181 |
+
|
| 182 |
+
for ($n = 1; $n < 6; $n++) {
|
| 183 |
+
if ($config->getData($n)) {
|
| 184 |
+
$sales[0]['data'.$n] = $this->changeExtraData($config->getData($n), $order, $item, $product);
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
return $sales;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
public function registerOrderByID($orderid, $realid = true) { // called from the checkout observer
|
| 193 |
+
$order = Mage::getModel('sales/order')->load($orderid);
|
| 194 |
+
if ($realid) {
|
| 195 |
+
$order->load($orderid);
|
| 196 |
+
}
|
| 197 |
+
else {
|
| 198 |
+
$order->loadByIncrementId($orderid);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
$this->registerOrder($order);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
public function registerOrder($order, $visitorID = '') {
|
| 205 |
+
if ($order) {
|
| 206 |
+
$orderid = $order->getId();
|
| 207 |
+
}
|
| 208 |
+
else {
|
| 209 |
+
Mage::log('Postaffiliatepro: Order empty');
|
| 210 |
+
return false;
|
| 211 |
+
}
|
| 212 |
+
Mage::log("Postaffiliatepro: Loading details of order $orderid");
|
| 213 |
+
|
| 214 |
+
$items = $this->getOrderSaleDetails($order);
|
| 215 |
+
$this->registerSaleDetails($items, $visitorID);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
public function registerSaleDetails($items, $visitorID = '') {
|
| 219 |
+
$config = Mage::getSingleton('pap/config');
|
| 220 |
+
$config->includePapAPI();
|
| 221 |
+
|
| 222 |
+
$saleTracker = new Pap_Api_SaleTracker($config->getInstallationPath().'/scripts/sale.php');
|
| 223 |
+
$saleTracker->setAccountId($config->getAPICredential('account'));
|
| 224 |
+
if (!empty($visitorID)) {
|
| 225 |
+
$saleTracker->setVisitorId($visitorID);
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
foreach ($items as $i => $item) {
|
| 229 |
+
Mage::log('Postaffiliatepro: Registering sale '.$item['orderid']."($i)");
|
| 230 |
+
|
| 231 |
+
$sale = $saleTracker->createSale();
|
| 232 |
+
$sale->setTotalCost($item['totalcost']);
|
| 233 |
+
$sale->setOrderID($item['orderid']."($i)");
|
| 234 |
+
$sale->setProductID($item['productid']);
|
| 235 |
+
$sale->setStatus($item['status']);
|
| 236 |
+
if ($item['couponcode']) $sale->setCouponCode($item['couponcode']);
|
| 237 |
+
if ($item['data1']) $sale->setData1($item['data1']);
|
| 238 |
+
if ($item['data2']) $sale->setData2($item['data2']);
|
| 239 |
+
if ($item['data3']) $sale->setData3($item['data3']);
|
| 240 |
+
if ($item['data4']) $sale->setData4($item['data4']);
|
| 241 |
+
if ($item['data5']) $sale->setData5($item['data5']);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
$saleTracker->register();
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
public function changeExtraData($data, $order, $item, $product) {
|
| 248 |
+
switch ($data) {
|
| 249 |
+
case 'empty':
|
| 250 |
+
return null;
|
| 251 |
+
break;
|
| 252 |
+
case 'itemName':
|
| 253 |
+
return (!empty($item)) ? $item->getName() : null;
|
| 254 |
+
break;
|
| 255 |
+
case 'itemQuantity':
|
| 256 |
+
return (!empty($item)) ? $item->getQtyOrdered() : null;
|
| 257 |
+
break;
|
| 258 |
+
case 'itemPrice':
|
| 259 |
+
if (!empty($item)) {
|
| 260 |
+
$rowtotal = $item->getBaseRowTotal();
|
| 261 |
+
if (empty($rowtotal)) {
|
| 262 |
+
return $item->getBasePrice();
|
| 263 |
+
}
|
| 264 |
+
return $rowtotal;
|
| 265 |
+
}
|
| 266 |
+
return null;
|
| 267 |
+
break;
|
| 268 |
+
case 'itemSKU':
|
| 269 |
+
return (!empty($item)) ? $item->getSku() : null;
|
| 270 |
+
break;
|
| 271 |
+
case 'itemWeight':
|
| 272 |
+
return (!empty($item)) ? $item->getWeight() : null;
|
| 273 |
+
break;
|
| 274 |
+
case 'itemWeightAll':
|
| 275 |
+
return (!empty($item)) ? $item->getRowWeight() : null;
|
| 276 |
+
break;
|
| 277 |
+
case 'itemCost':
|
| 278 |
+
return (!empty($item)) ? $item->getCost() : null;
|
| 279 |
+
break;
|
| 280 |
+
case 'itemDiscount':
|
| 281 |
+
return (!empty($item)) ? abs($item->getBaseDiscountAmount()) : null;
|
| 282 |
+
break;
|
| 283 |
+
case 'itemDiscountPercent':
|
| 284 |
+
return (!empty($item)) ? $item->getDiscountPercent() : null;
|
| 285 |
+
break;
|
| 286 |
+
case 'itemTax':
|
| 287 |
+
return (!empty($item)) ? $item->getTaxAmount() : null;
|
| 288 |
+
break;
|
| 289 |
+
case 'itemTaxPercent':
|
| 290 |
+
return (!empty($item)) ? $item->getTaxPercent() : null;
|
| 291 |
+
break;
|
| 292 |
+
case 'productCategoryID':
|
| 293 |
+
return (!empty($product)) ? $product->getCategoryId() : null;
|
| 294 |
+
break;
|
| 295 |
+
case 'productURL':
|
| 296 |
+
return (!empty($product)) ? $product->getProductUrl(false) : null;
|
| 297 |
+
break;
|
| 298 |
+
case 'storeID':
|
| 299 |
+
return (!empty($order)) ? $order->getStoreId() : null;
|
| 300 |
+
break;
|
| 301 |
+
case 'internalOrderID':
|
| 302 |
+
return (!empty($order)) ? $order->getId() : null;
|
| 303 |
+
break;
|
| 304 |
+
case 'customerID':
|
| 305 |
+
return (!empty($order) && $order->getCustomerId()) ? $order->getCustomerId() : null;
|
| 306 |
+
break;
|
| 307 |
+
case 'customerEmail':
|
| 308 |
+
return (!empty($order) && $order->getCustomerEmail()) ? $order->getCustomerEmail() : null;
|
| 309 |
+
break;
|
| 310 |
+
case 'customerName':
|
| 311 |
+
$name = '';
|
| 312 |
+
if (!empty($order)) {
|
| 313 |
+
$name = $order->getCustomerFirstname().' '.$order->getCustomerMiddlename().' '.$order->getCustomerLastname();
|
| 314 |
+
}
|
| 315 |
+
return (!empty($name)) ? $name : null;
|
| 316 |
+
break;
|
| 317 |
+
case 'couponCode':
|
| 318 |
+
return (!empty($order) && $order->getQuoteId()) ? Mage::getModel('sales/quote')->load($order->getQuoteId())->getCouponCode() : null;
|
| 319 |
+
break;
|
| 320 |
+
default: return $data;
|
| 321 |
+
}
|
| 322 |
+
}
|
| 323 |
+
}
|
app/code/local/Qualityunit/Pap/Model/{Ipn.php → PaypalIpn.php}
RENAMED
|
File without changes
|
app/code/local/Qualityunit/Pap/Model/Validateapi.php
CHANGED
|
@@ -22,9 +22,16 @@ class Qualityunit_Pap_Model_Validateapi extends Mage_Core_Model_Config_Data {
|
|
| 22 |
$password = $_POST['groups']['api']['fields']['password']['value'];
|
| 23 |
|
| 24 |
$session = new Gpf_Api_Session($url);
|
|
|
|
| 25 |
if (!@$session->login($username, $password)) {
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
} else {
|
| 29 |
Mage::getSingleton('core/session')->addSuccess('API Connection tested successfully!');
|
| 30 |
}
|
| 22 |
$password = $_POST['groups']['api']['fields']['password']['value'];
|
| 23 |
|
| 24 |
$session = new Gpf_Api_Session($url);
|
| 25 |
+
// check HTTP
|
| 26 |
if (!@$session->login($username, $password)) {
|
| 27 |
+
// check HTTPS
|
| 28 |
+
$session = new Gpf_Api_Session(str_replace('http://','https://',$url));
|
| 29 |
+
if (!@$session->login($username, $password)) {
|
| 30 |
+
Mage::getSingleton('adminhtml/session')->addError('Credentials are probably not correct: '.$session->getMessage());
|
| 31 |
+
return null;
|
| 32 |
+
} else {
|
| 33 |
+
Mage::getSingleton('core/session')->addSuccess('API Connection tested successfully!');
|
| 34 |
+
}
|
| 35 |
} else {
|
| 36 |
Mage::getSingleton('core/session')->addSuccess('API Connection tested successfully!');
|
| 37 |
}
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Qualityunit_Pap</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -9,11 +9,13 @@
|
|
| 9 |
<summary>The module makes an integration with Post Affiliate Pro or Post Affiliate Network an easy thing. A simple configuration with all the needed options helps you to make it working in seconds.</summary>
|
| 10 |
<description>The module makes an integration with Post Affiliate Pro or Post Affiliate Network an easy thing. A simple configuration with all the needed options helps you to make it working in seconds.
|
| 11 |
The module integrates sales, supports per product tracking, Coupon tracking and Lifetime Commission tracking. It also automatically approves and declines commissions when transaction status is changed.</description>
|
| 12 |
-
<notes>-
|
|
|
|
|
|
|
| 13 |
<authors><author><name>Quality Unit, LLC</name><user>support</user><email>support@qualityunit.com</email></author></authors>
|
| 14 |
-
<date>2016-02-
|
| 15 |
-
<time>
|
| 16 |
-
<contents><target name="magelocal"><dir name="Qualityunit"><dir name="Pap"><dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="a1a70e021c623040796d925afbf52324"/></dir></dir></dir></dir><file name="Clicktracking.php" hash="8ee426151206030457e080ef23ce953b"/><dir name="Paypal"><file name="Redirect.php" hash="6c48219eb2e6f37ef50570e90c904639"/></dir><file name="Saletracking.php" hash="b7e5c50972b856a87c2d24903235e502"/></dir><dir name="Helper"><file name="Data.php" hash="6418f45f1484fd4f676933a8af96cef5"/></dir><dir name="Model"><dir name="Checkout"><file name="Observer.php" hash="eeeb25d90b801c6352568c25e3154942"/></dir><dir name="Config"><dir name="Source"><file name="CustomVariables.php" hash="1419c44e2e174e368f69ac9c12701b63"/><file name="TrackSales.php" hash="1af0c801457e4b31f55fde6ad12e7b67"/></dir></dir><file name="Config.php" hash="
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.2.0</min><max>7.5.0</max></php></required></dependencies>
|
| 19 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Qualityunit_Pap</name>
|
| 4 |
+
<version>1.0.7</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
|
| 7 |
<channel>community</channel>
|
| 9 |
<summary>The module makes an integration with Post Affiliate Pro or Post Affiliate Network an easy thing. A simple configuration with all the needed options helps you to make it working in seconds.</summary>
|
| 10 |
<description>The module makes an integration with Post Affiliate Pro or Post Affiliate Network an easy thing. A simple configuration with all the needed options helps you to make it working in seconds.
|
| 11 |
The module integrates sales, supports per product tracking, Coupon tracking and Lifetime Commission tracking. It also automatically approves and declines commissions when transaction status is changed.</description>
|
| 12 |
+
<notes>- paypal integration fix
|
| 13 |
+
- HTTP to HTTPS redirection in case of API communication fixed
|
| 14 |
+
- API tracking fixed based on new HTTP/HTTPS approach</notes>
|
| 15 |
<authors><author><name>Quality Unit, LLC</name><user>support</user><email>support@qualityunit.com</email></author></authors>
|
| 16 |
+
<date>2016-02-23</date>
|
| 17 |
+
<time>08:22:23</time>
|
| 18 |
+
<contents><target name="magelocal"><dir name="Qualityunit"><dir name="Pap"><dir><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="a1a70e021c623040796d925afbf52324"/></dir></dir></dir></dir><file name="Clicktracking.php" hash="8ee426151206030457e080ef23ce953b"/><dir name="Paypal"><file name="Redirect.php" hash="6c48219eb2e6f37ef50570e90c904639"/></dir><file name="Saletracking.php" hash="b7e5c50972b856a87c2d24903235e502"/></dir><dir name="Helper"><file name="Data.php" hash="6418f45f1484fd4f676933a8af96cef5"/></dir><dir name="Model"><dir name="Checkout"><file name="Observer.php" hash="eeeb25d90b801c6352568c25e3154942"/></dir><dir name="Config"><dir name="Source"><file name="CustomVariables.php" hash="1419c44e2e174e368f69ac9c12701b63"/><file name="TrackSales.php" hash="1af0c801457e4b31f55fde6ad12e7b67"/></dir></dir><file name="Config.php" hash="75852918132ca6300c3a381574c5404d"/><file name="Observer.php" hash="82e1daf72693410bc4619151d03554e7"/><file name="Pap.php" hash="1010ab29b52c34277397a5b5aeadd7eb"/><file name="Paypal.php" hash="39cbba74d089c1460f2404d8128cfb0b"/><file name="PaypalIpn.php" hash="410b6493a4f3fd451698d56bc0eced94"/><file name="Validateapi.php" hash="2a90e74dc6a137a8960df465f17711ca"/></dir><dir name="etc"><file name="config.xml" hash="fc1d64d6b62a1823e98ee8c327d6bffd"/><file name="system.xml" hash="737444ec24bd0a18af630327f025b03c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="pap.xml" hash="600ebb26e9af1c78ac0a5d22717d2cd2"/></dir><dir name="template"><dir name="pap"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="cebb98c5c843a2921debea7cf98fdfe2"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="pap.xml" hash="167eddd9fa705fba71f8d3d2992a43cc"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="pap.xml" hash="167eddd9fa705fba71f8d3d2992a43cc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Qualityunit_Pap.xml" hash="78a58f4a3a637e027e42b74838b56607"/></dir></target><target name="magelib"><dir name="PAP"><file name="PapApi.class.php" hash="f1bae43744873b540b98e448caf7e205"/></dir></target><target name="mage"><dir name="lib"><dir name="PAP"><file name="README.txt" hash="2a279f64825e116dfd29c73fee9dabc8"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="pap"><file name="pap.css" hash="ff8a88a99075753b4a0ea9004d579a42"/><file name="pap-tab.png" hash="eef09c5b3777189e05b1702c463a9a33"/><file name="pap-logo.png" hash="e9053c44287a8d84801451ed69ef2f09"/></dir></dir></dir></dir></target></contents>
|
| 19 |
<compatible/>
|
| 20 |
<dependencies><required><php><min>5.2.0</min><max>7.5.0</max></php></required></dependencies>
|
| 21 |
</package>
|
