Sisow

The WooCommerce Sisow Mastercard Sisow class.

Defined (1)

The class is defined in the following location(s).

/sisow/sisow.cls5.php  
  1. class Sisow 
  2. protected static $issuers; 
  3. protected static $lastcheck; 
  4.  
  5. private $response; 
  6.  
  7. // Merchant data 
  8. private $merchantId; 
  9. private $merchantKey; 
  10. private $shopId; 
  11.  
  12. // Transaction data 
  13. public $payment; // empty=iDEAL; sofort=DIRECTebanking; mistercash=MisterCash; ... 
  14. public $issuerId; // mandatory; sisow bank code 
  15. public $purchaseId; // mandatory; max 16 alphanumeric 
  16. public $entranceCode; // max 40 strict alphanumeric (letters and numbers only) 
  17. public $description; // mandatory; max 32 alphanumeric 
  18. public $amount; // mandatory; min 0.45 
  19. public $notifyUrl; 
  20. public $returnUrl; // mandatory 
  21. public $cancelUrl; 
  22. public $callbackUrl; 
  23. private $locale; 
  24.  
  25. // Status data 
  26. public $status; 
  27. public $timeStamp; 
  28. public $consumerAccount; 
  29. public $consumerIban; 
  30. public $consumerBic; 
  31. public $consumerName; 
  32. public $consumerCity; 
  33.  
  34. // Invoice data 
  35. public $invoiceNo; 
  36. public $documentId; 
  37. public $documentUrl; 
  38.  
  39. // Klarna Factuur/Account 
  40. public $pendingKlarna; 
  41. public $monthly; 
  42. public $pclass; 
  43. public $intrestRate; 
  44. public $invoiceFee; 
  45. public $months; 
  46. public $startFee; 
  47.  
  48. // Result/check data 
  49. public $trxId; 
  50. public $issuerUrl; 
  51.  
  52. // Error data 
  53. public $errorCode; 
  54. public $errorMessage; 
  55.  
  56. // Status 
  57. const statusSuccess = "Success"; 
  58. const statusCancelled = "Cancelled"; 
  59. const statusExpired = "Expired"; 
  60. const statusFailure = "Failure"; 
  61. const statusOpen = "Open"; 
  62. const statusReversed = "Reversed"; 
  63. const statusRefunded = "Refunded"; 
  64.  
  65. public function __construct($merchantid, $merchantkey, $shopid = '') { 
  66. $this->merchantId = $merchantid; 
  67. $this->merchantKey = $merchantkey; 
  68. $this->shopId = $shopid; 
  69.  
  70. $this->locale = ''; 
  71.  
  72. private function error() { 
  73. $this->errorCode = $this->parse("errorcode"); 
  74. $this->errorMessage = urldecode($this->parse("errormessage")); 
  75.  
  76. private function parse($search, $xml = false) { 
  77. if ($xml === false) { 
  78. $xml = $this->response; 
  79. if (($start = strpos($xml, "<" . $search . ">")) === false) { 
  80. return false; 
  81. $start += strlen($search) + 2; 
  82. if (($end = strpos($xml, "</" . $search . ">", $start)) === false) { 
  83. return false; 
  84. return substr($xml, $start, $end - $start); 
  85.  
  86. public function send($method, array $keyvalue = NULL, $return = 1) { 
  87. $url = "https://www.sisow.nl/Sisow/iDeal/RestHandler.ashx/" . $method; 
  88. $options = array( 
  89. CURLOPT_POST => 1,  
  90. CURLOPT_HEADER => 0,  
  91. CURLOPT_URL => $url,  
  92. CURLOPT_FRESH_CONNECT => 1,  
  93. CURLOPT_RETURNTRANSFER => $return,  
  94. CURLOPT_FORBID_REUSE => 1,  
  95. CURLOPT_TIMEOUT => 120,  
  96. CURLOPT_SSL_VERIFYPEER => 0,  
  97. CURLOPT_POSTFIELDS => $keyvalue == NULL ? "" : http_build_query($keyvalue, '', '&')); 
  98. $ch = curl_init(); 
  99. curl_setopt_array($ch, $options); 
  100. $this->response = curl_exec($ch); 
  101. if (!$this->response) { 
  102. $this->errorMessage = curl_error($ch); 
  103. curl_close($ch);  
  104. if (!$this->response) { 
  105. return false; 
  106. return true; 
  107.  
  108. private function getDirectory() { 
  109. $diff = 24 * 60 *60; 
  110. if (self::$lastcheck) 
  111. $diff = time() - self::$lastcheck; 
  112. if ($diff < 24 *60 *60) 
  113. return 0; 
  114. if (!$this->send("DirectoryRequest")) 
  115. return -1; 
  116. $search = $this->parse("directory"); 
  117. if (!$search) { 
  118. $this->error(); 
  119. return -2; 
  120. self::$issuers = array(); 
  121. $iss = explode("<issuer>", str_replace("</issuer>", "", $search)); 
  122. foreach ($iss as $k => $v) { 
  123. $issuerid = $this->parse("issuerid", $v); 
  124. $issuername = $this->parse("issuername", $v); 
  125. if ($issuerid && $issuername) { 
  126. self::$issuers[$issuerid] = $issuername; 
  127. self::$lastcheck = time(); 
  128. return 0; 
  129.  
  130. // DirectoryRequest 
  131. public function DirectoryRequest(&$output, $select = false, $test = false) { 
  132. if ($test === true) { 
  133. // kan ook via de gateway aangevraagd worden, maar is altijd hetzelfde 
  134. if ($select === true) { 
  135. $output = "<select id=\"sisowbank\" name=\"issuerid\">"; 
  136. $output .= "<option value=\"99\">Sisow Bank (test)</option>"; 
  137. $output .= "</select>"; 
  138. else { 
  139. $output = array("99" => "Sisow Bank (test)"); 
  140. return 0; 
  141. $output = false; 
  142. $ex = $this->getDirectory(); 
  143. if ($ex < 0) { 
  144. return $ex; 
  145. if ($select === true) { 
  146. $output = "<select id=\"sisowbank\" name=\"issuerid\">"; 
  147. else { 
  148. $output = array(); 
  149. foreach (self::$issuers as $k => $v) { 
  150. if ($select === true) { 
  151. $output .= "<option value=\"" . $k . "\">" . $v . "</option>"; 
  152. else { 
  153. $output[$k] = $v; 
  154. if ($select === true) { 
  155. $output .= "</select>"; 
  156. return 0; 
  157.  
  158. // TransactionRequest 
  159. public function TransactionRequest($keyvalue = NULL) { 
  160. $this->trxId = $this->issuerUrl = ""; 
  161. if (!$this->merchantId) { 
  162. $this->errorMessage = "No merchantid"; 
  163. return -1; 
  164. if (!$this->merchantKey) { 
  165. $this->errorMessage = "No merchantkey"; 
  166. return -2; 
  167. if (!$this->purchaseId) { 
  168. $this->errorMessage = "No purchaseid"; 
  169. return -3; 
  170. if ($this->amount < 0.45) { 
  171. $this->errorMessage = "Amount < 0.45"; 
  172. return -4; 
  173. if (!$this->description) { 
  174. $this->errorMessage = "No description"; 
  175. return -5; 
  176. if (!$this->returnUrl) { 
  177. $this->errorMessage = "No returnurl"; 
  178. return -6; 
  179. if (!$this->issuerId && !$this->payment) { 
  180. $this->errorMessage = "No issuer or payment"; 
  181. return -7; 
  182. if (!$this->entranceCode) 
  183. $this->entranceCode = $this->purchaseId; 
  184. $pars = array(); 
  185. $pars["merchantid"] = $this->merchantId; 
  186. $pars["shopid"] = $this->shopId; 
  187. $pars["payment"] = $this->payment; 
  188. $pars["issuerid"] = $this->issuerId; 
  189. $pars["purchaseid"] = $this->purchaseId;  
  190. $pars["amount"] = round($this->amount * 100); 
  191. $pars["description"] = $this->description; 
  192. $pars["entrancecode"] = $this->entranceCode; 
  193. $pars["returnurl"] = $this->returnUrl; 
  194. $pars["cancelurl"] = $this->cancelUrl; 
  195. $pars["callbackurl"] = $this->callbackUrl; 
  196. $pars["notifyurl"] = $this->notifyUrl; 
  197.  
  198. if($this->payment == "focum" || $this->payment == "klarna" || $this->payment == "klarnaacc") 
  199. if(!$this->validateFocum($keyvalue)) 
  200. return -10; 
  201.  
  202. if(strlen($keyvalue['billing_countrycode']) == 2) 
  203. $pars["locale"] = $this->setLocale($keyvalue['billing_countrycode']); 
  204. else 
  205. $pars["locale"] = $this->setLocale(""); 
  206.  
  207. if($this->locale != '') 
  208. $pars["locale"] = $this->locale; 
  209.  
  210. $pars["sha1"] = sha1($this->purchaseId . $this->entranceCode . round($this->amount * 100) . $this->shopId . $this->merchantId . $this->merchantKey); 
  211. if ($keyvalue) { 
  212. foreach ($keyvalue as $k => $v) { 
  213. $pars[$k] = $v; 
  214. if (!$this->send("TransactionRequest", $pars)) { 
  215. if (!$this->errorMessage) { 
  216. $this->errorMessage = "No transaction"; 
  217. return -8; 
  218. $this->trxId = $this->parse("trxid"); 
  219. $url = $this->parse("issuerurl"); 
  220. $this->issuerUrl = urldecode($url); 
  221.  
  222. $this->documentId = $this->parse("documentid"); 
  223. /** 
  224. if($this->payment == 'klarna' || $this->payment == 'klarnaacc') 
  225. $sha = sha1($this->trxId . $this->merchantId . $this->merchantKey); 
  226. else 
  227. $sha = sha1($this->trxId . $url . $this->merchantId . $this->merchantKey); 
  228.  
  229. if($this->parse("sha1") != $sha) 
  230. $this->errorMessage = 'Invalid SHA returned'; 
  231. return -9; 
  232. */ 
  233. $this->pendingKlarna = $this->parse("pendingklarna") == "true"; 
  234. if (!$this->issuerUrl) { 
  235. $this->error(); 
  236. return -9; 
  237. return 0; 
  238.  
  239. // StatusRequest 
  240. public function StatusRequest($trxid = false) { 
  241. if ($trxid === false) 
  242. $trxid = $this->trxId; 
  243. if (!$this->merchantId) 
  244. return -1; 
  245. if (!$this->merchantKey) 
  246. return -2; 
  247. if (!$trxid) 
  248. return -3; 
  249. $this->trxId = $trxid; 
  250. $pars = array(); 
  251. $pars["merchantid"] = $this->merchantId; 
  252. $pars["shopid"] = $this->shopId; 
  253. $pars["trxid"] = $this->trxId; 
  254. $pars["sha1"] = sha1($this->trxId . $this->shopId . $this->merchantId . $this->merchantKey); 
  255. if (!$this->send("StatusRequest", $pars)) 
  256. return -4; 
  257. $this->status = $this->parse("status"); 
  258. if (!$this->status) { 
  259. $this->error(); 
  260. return -5; 
  261. $this->timeStamp = $this->parse("timestamp"); 
  262. $this->amount = $this->parse("amount") / 100.0; 
  263. $this->consumerAccount = $this->parse("consumeraccount"); 
  264. $this->consumerIban = $this->parse("consumeriban"); 
  265. $this->consumerBic = $this->parse("consumerbic"); 
  266. $this->consumerName = $this->parse("consumername"); 
  267. $this->consumerCity = $this->parse("consumercity"); 
  268. $this->purchaseId = $this->parse("purchaseid"); 
  269. $this->description = $this->parse("description"); 
  270. $this->entranceCode = $this->parse("entrancecode"); 
  271.  
  272. if( $this->parse("sha1") != sha1($this->trxId . $this->status . $this->amount * 100.0 . $this->purchaseId . $this->entranceCode . $this->consumerAccount . $this->merchantId . $this->merchantKey) ) 
  273. $this->errorMessage = "Invalid SHA returned"; 
  274. return -6; 
  275.  
  276. return 0; 
  277.  
  278. // FetchMonthlyRequest 
  279. public function FetchMonthlyRequest($amt = false) { 
  280. if (!$amt) $amt = round($this->amount * 100); 
  281. else $amt = round($amt * 100); 
  282. $pars = array(); 
  283. $pars["merchantid"] = $this->merchantId; 
  284. $pars["amount"] = $amt; 
  285. $pars["sha1"] = sha1($amt . $this->merchantId . $this->merchantKey); 
  286. if (!$this->send("FetchMonthlyRequest", $pars)) 
  287. return -1; 
  288. $this->monthly = $this->parse("monthly"); 
  289. $this->pclass = $this->parse("pclass"); 
  290. $this->intrestRate = $this->parse("intrestRate"); 
  291. $this->invoiceFee = $this->parse("invoiceFee"); 
  292. $this->months = $this->parse("months"); 
  293. $this->startFee = $this->parse("startFee"); 
  294. return $this->monthly; 
  295.  
  296. // RefundRequest 
  297. public function RefundRequest($trxid) { 
  298. $pars = array(); 
  299. $pars["merchantid"] = $this->merchantId; 
  300. $pars["trxid"] = $trxid; 
  301. $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey); 
  302. if (!$this->send("RefundRequest", $pars)) 
  303. return -1; 
  304. $id = $this->parse("id"); 
  305. if (!$id) { 
  306. $this->error(); 
  307. return -2; 
  308. if( $this->parse("sha1") != sha1($id . $this->merchantId . $this->merchantKey) ) 
  309. $this->errorMessage = "Invalid SHA returned"; 
  310. return -6; 
  311.  
  312. return $id; 
  313.  
  314. // InvoiceRequest 
  315. public function InvoiceRequest($trxid, $keyvalue = NULL) { 
  316. $pars = array(); 
  317. $pars["merchantid"] = $this->merchantId; 
  318. $pars["trxid"] = $trxid; 
  319. $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey); 
  320. if ($keyvalue) { 
  321. foreach ($keyvalue as $k => $v) { 
  322. $pars[$k] = $v; 
  323. if (!$this->send("InvoiceRequest", $pars)) 
  324. return -1; 
  325. $this->invoiceNo = $this->parse("invoiceno"); 
  326. if (!$this->invoiceNo) { 
  327. $this->error(); 
  328. return -2; 
  329. $this->documentId = $this->parse("documentid"); 
  330. $this->documentUrl = $this->parse("documenturl"); 
  331.  
  332. if( $this->parse("sha1") != sha1($this->invoiceNo . $this->documentId . $this->merchantId . $this->merchantKey) ) 
  333. $this->errorMessage = "Invalid SHA returned"; 
  334. return -6; 
  335.  
  336. return 0; 
  337.  
  338. // CreditInvoiceRequest 
  339. public function CreditInvoiceRequest($trxid) { 
  340. $pars = array(); 
  341. $pars["merchantid"] = $this->merchantId; 
  342. $pars["trxid"] = $trxid; 
  343. $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey); 
  344. if (!$this->send("CreditInvoiceRequest", $pars)) 
  345. return -1; 
  346. $this->invoiceNo = $this->parse("invoiceno"); 
  347. if (!$this->invoiceNo) { 
  348. $this->error(); 
  349. return -2; 
  350. $this->documentId = $this->parse("documentid"); 
  351. $this->documentUrl = $this->parse("documenturl"); 
  352.  
  353. if( $this->parse("sha1") != sha1($this->invoiceNo . $this->documentId . $this->merchantId . $this->merchantKey) ) 
  354. $this->errorMessage = "Invalid SHA returned"; 
  355. return -6; 
  356.  
  357. return 0; 
  358.  
  359. // CancelReservationRequest 
  360. public function CancelReservationRequest($trxid) { 
  361. $pars = array(); 
  362. $pars["merchantid"] = $this->merchantId; 
  363. $pars["trxid"] = $trxid; 
  364. $pars["sha1"] = sha1($trxid . $this->merchantId . $this->merchantKey); 
  365. if (!$this->send("CancelReservationRequest", $pars)) 
  366. return -1; 
  367.  
  368. if( $this->parse("sha1") != sha1($trxid . $this->merchantId . $this->merchantKey) ) 
  369. $this->errorMessage = "Invalid SHA returned"; 
  370. return -6; 
  371. return 0; 
  372.  
  373. public function setLocale($countryIso) 
  374. $supported = array("US"); 
  375.  
  376. switch($this->payment) 
  377. case "paypalec": 
  378. $supported = array('AU', 'AT', 'BE', 'BR', 'CA', 'CH', 'CN', 'DE', 'ES', 'GB', 'FR', 'IT', 'NL', 'PL', 'PT', 'RU', 'US'); 
  379. break; 
  380. case "mistercash": 
  381. $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR'); 
  382. break; 
  383. case "creditcard": 
  384. $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR'); 
  385. break; 
  386. case "maestro": 
  387. $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR'); 
  388. break; 
  389. case "mastercard": 
  390. $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR'); 
  391. break; 
  392. case "visa": 
  393. $supported = array('NL', 'BE', 'DE', 'IT', 'ES', 'PT', 'BR', 'SE', 'FR'); 
  394. break; 
  395. default: 
  396. return "NL"; 
  397. break; 
  398.  
  399. $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); 
  400. $lang = strtoupper($lang); 
  401.  
  402. $lang = (!isset($lang) || $lang == "") ? $countryIso : $lang; 
  403.  
  404. if($lang == "") 
  405. return "US"; 
  406. if(in_array($lang, $supported)) 
  407. return $lang; 
  408. else 
  409. return 'US'; 
  410. }  
  411.  
  412. private function validateFocum($pars) 
  413. if(!is_array($pars)) 
  414. $this->errorCode = "emptyarray"; 
  415. $this->errorMessage = "No values"; 
  416. return false; 
  417. else if(!array_key_exists('billing_firstname', $pars) || empty($pars['billing_firstname'])) 
  418. $this->errorCode = "billing_firstname"; 
  419. $this->errorMessage = "billing_firstname empty"; 
  420. return false; 
  421. else if(!array_key_exists('billing_lastname', $pars) || empty($pars['billing_lastname'])) 
  422. $this->errorCode = "billing_lastname"; 
  423. $this->errorMessage = "billing_lastname empty"; 
  424. return false; 
  425. else if(!array_key_exists('billing_mail', $pars) || empty($pars['billing_mail'])) 
  426. $this->errorCode = "billing_mail"; 
  427. $this->errorMessage = "billing_mail empty"; 
  428. return false; 
  429. else if(!array_key_exists('billing_address1', $pars) || empty($pars['billing_address1'])) 
  430. $this->errorCode = "billing_address1"; 
  431. $this->errorMessage = "billing_address1 empty"; 
  432. return false; 
  433. else if(!array_key_exists('billing_zip', $pars) || empty($pars['billing_zip'])) 
  434. $this->errorCode = "billing_zip"; 
  435. $this->errorMessage = "billing_zip empty"; 
  436. return false; 
  437. else if(!array_key_exists('billing_city', $pars) || empty($pars['billing_city'])) 
  438. $this->errorCode = "billing_city"; 
  439. $this->errorMessage = "billing_city empty"; 
  440. return false; 
  441. else if(!array_key_exists('billing_phone', $pars) || empty($pars['billing_phone'])) 
  442. $this->errorCode = "billing_phone"; 
  443. $this->errorMessage = "billing_phone empty"; 
  444. return false; 
  445. else if(!array_key_exists('billing_countrycode', $pars) || empty($pars['billing_countrycode'])) 
  446. $this->errorCode = "billing_countrycode"; 
  447. $this->errorMessage = "billing_countrycode empty"; 
  448. return false; 
  449. else if(!array_key_exists('shipping_firstname', $pars) || empty($pars['shipping_firstname'])) 
  450. $this->errorCode = "shipping_firstname"; 
  451. $this->errorMessage = "shipping_firstname empty"; 
  452. return false; 
  453. else if(!array_key_exists('shipping_lastname', $pars) || empty($pars['shipping_lastname'])) 
  454. $this->errorCode = "shipping_lastname"; 
  455. $this->errorMessage = "shipping_lastname empty"; 
  456. return false; 
  457. else if(!array_key_exists('shipping_address1', $pars) || empty($pars['shipping_address1'])) 
  458. $this->errorCode = "shipping_address1"; 
  459. $this->errorMessage = "shipping_address1 empty"; 
  460. return false; 
  461. else if(!array_key_exists('shipping_zip', $pars) || empty($pars['shipping_zip'])) 
  462. $this->errorCode = "shipping_zip"; 
  463. $this->errorMessage = "shipping_zip empty"; 
  464. return false; 
  465. else if(!array_key_exists('shipping_city', $pars) || empty($pars['shipping_city'])) 
  466. $this->errorCode = "shipping_city"; 
  467. $this->errorMessage = "shipping_city empty"; 
  468. return false; 
  469. else if(!array_key_exists('shipping_phone', $pars) || empty($pars['shipping_phone'])) 
  470. $this->errorCode = "shipping_phone"; 
  471. $this->errorMessage = "shipping_phone empty"; 
  472. return false; 
  473. else if(!array_key_exists('shipping_countrycode', $pars) || empty($pars['shipping_countrycode'])) 
  474. $this->errorCode = "shipping_countrycode"; 
  475. $this->errorMessage = "shipping_countrycode empty"; 
  476. return false; 
  477. else if(!array_key_exists('birthdate', $pars) || empty($pars['birthdate'])) 
  478. $this->errorCode = "birthdate"; 
  479. $this->errorMessage = "birthdate empty"; 
  480. return false; 
  481. else if(!array_key_exists('iban', $pars) || empty($pars['iban'])) 
  482. $this->errorCode = "iban"; 
  483. $this->errorMessage = "iban empty"; 
  484. return false; 
  485. else if(($this->amount * 100.0) < 100) 
  486. $this->errorCode = "amount"; 
  487. $this->errorMessage = "incorrect amount"; 
  488. return false; 
  489.  
  490. if(!$this->checkIBAN($pars['iban'])) 
  491. $this->errorCode = "IBAN"; 
  492. $this->errorMessage = "Invalid IBAN"; 
  493. return false; 
  494.  
  495. $productexists = true; 
  496. $productid = 1; 
  497. $producttotal = 0; 
  498.  
  499. while($productexists) 
  500. if(!array_key_exists('product_id_' . $productid, $pars)) 
  501. $productexists = false; 
  502. continue; 
  503. else if(empty($pars['product_id_' . $productid])) 
  504. $pars['product_id_' . $productid] = "artikel" . $productid; 
  505.  
  506. if(!array_key_exists('product_description_' . $productid, $pars) || empty($pars['product_description_' . $productid])) 
  507. $this->errorCode = "product_description_" . $productid; 
  508. $this->errorMessage = "product_description_" . $productid . " is missing"; 
  509. return false; 
  510.  
  511. if(!array_key_exists('product_quantity_' . $productid, $pars) || empty($pars['product_quantity_' . $productid])) 
  512. $this->errorCode = "product_quantity_" . $productid; 
  513. $this->errorMessage = "product_quantity_" . $productid . " is missing"; 
  514. return false; 
  515. else if($pars['product_quantity_' . $productid] < 1) 
  516. $this->errorCode = "low product_quantity_" . $productid; 
  517. $this->errorMessage = "product_quantity_" . $productid . " is lower than 1"; 
  518. return false; 
  519.  
  520. if(!array_key_exists('product_netprice_' . $productid, $pars) || empty($pars['product_netprice_' . $productid])) 
  521. $this->errorCode = "product_netprice_". $productid; 
  522. $this->errorMessage = "product_netprice_" . $productid . " is missing"; 
  523. return false; 
  524. else if($pars['product_netprice_' . $productid] < 1) 
  525. $this->errorCode = "low product_netprice_". $productid; 
  526. $this->errorMessage = "product_netprice_" . $productid . " is lower than 1"; 
  527. return false; 
  528.  
  529. if(!array_key_exists('product_total_' . $productid, $pars) || empty($pars['product_total_' . $productid])) 
  530. $this->errorCode = "product_total_". $productid; 
  531. $this->errorMessage = "product_total_" . $productid . " is missing"; 
  532. return false; 
  533. else if($pars['product_total_' . $productid] < 1) 
  534. $this->errorCode = "low product_total_". $productid; 
  535. $this->errorMessage = "product_total_" . $productid . " is lower than 1"; 
  536. return false; 
  537. else  
  538. $producttotal += $pars['product_total_' . $productid]; 
  539.  
  540. if(!array_key_exists('product_nettotal_' . $productid, $pars) || empty($pars['product_nettotal_' . $productid])) 
  541. $this->errorCode = "product_nettotal_" . $productid; 
  542. $this->errorMessage = "product_nettotal_" . $productid . " is missing"; 
  543. return false; 
  544. else if($pars['product_nettotal_' . $productid] < 1) 
  545. $this->errorCode = "low product_nettotal_". $productid; 
  546. $this->errorMessage = "product_nettotal_" . $productid . " is lower than 1"; 
  547. return false; 
  548.  
  549. if(!array_key_exists('product_tax_' . $productid, $pars) || empty($pars['product_tax_' . $productid])) 
  550. $this->errorCode = "product_tax_" . $productid; 
  551. $this->errorMessage = "product_tax_" . $productid . " is missing"; 
  552. return false; 
  553. else if($pars['product_tax_' . $productid] < 1) 
  554. $this->errorCode = "low product_tax_" . $productid; 
  555. $this->errorMessage = "product_tax_" . $productid . " is lower than 1"; 
  556. return false; 
  557.  
  558. if(!array_key_exists('product_taxrate_' . $productid, $pars) || empty($pars['product_taxrate_' . $productid])) 
  559. $this->errorCode = "product_taxrate_" . $productid; 
  560. $this->errorMessage = "product_taxrate_" . $productid . " is missing"; 
  561. return false; 
  562.  
  563. $productid++; 
  564.  
  565. $different = $producttotal - round($this->amount * 100.0); 
  566. if($different != -1 && $different != 0 && $different != 1) 
  567. $this->errorCode = "cartamount"; 
  568. $this->errorMessage = "Cart total don't match amount"; 
  569. return false; 
  570.  
  571. return true; 
  572.  
  573. private function checkIBAN($iban) 
  574. $iban = strtolower($iban); 
  575. $Countries = array( 
  576. 'al'=>28, 'ad'=>24, 'at'=>20, 'az'=>28, 'bh'=>22, 'be'=>16, 'ba'=>20, 'br'=>29, 'bg'=>22, 'cr'=>21, 'hr'=>21, 'cy'=>28, 'cz'=>24,  
  577. 'dk'=>18, 'do'=>28, 'ee'=>20, 'fo'=>18, 'fi'=>18, 'fr'=>27, 'ge'=>22, 'de'=>22, 'gi'=>23, 'gr'=>27, 'gl'=>18, 'gt'=>28, 'hu'=>28,  
  578. 'is'=>26, 'ie'=>22, 'il'=>23, 'it'=>27, 'jo'=>30, 'kz'=>20, 'kw'=>30, 'lv'=>21, 'lb'=>28, 'li'=>21, 'lt'=>20, 'lu'=>20, 'mk'=>19,  
  579. 'mt'=>31, 'mr'=>27, 'mu'=>30, 'mc'=>27, 'md'=>24, 'me'=>22, 'nl'=>18, 'no'=>15, 'pk'=>24, 'ps'=>29, 'pl'=>28, 'pt'=>25, 'qa'=>29,  
  580. 'ro'=>24, 'sm'=>27, 'sa'=>24, 'rs'=>22, 'sk'=>24, 'si'=>19, 'es'=>24, 'se'=>24, 'ch'=>21, 'tn'=>24, 'tr'=>26, 'ae'=>23, 'gb'=>22, 'vg'=>24 
  581. ); 
  582. $Chars = array( 
  583. 'a'=>10, 'b'=>11, 'c'=>12, 'd'=>13, 'e'=>14, 'f'=>15, 'g'=>16, 'h'=>17, 'i'=>18, 'j'=>19, 'k'=>20, 'l'=>21, 'm'=>22,  
  584. 'n'=>23, 'o'=>24, 'p'=>25, 'q'=>26, 'r'=>27, 's'=>28, 't'=>29, 'u'=>30, 'v'=>31, 'w'=>32, 'x'=>33, 'y'=>34, 'z'=>35 
  585. ); 
  586.  
  587. if (strlen($iban) != $Countries[ substr($iban, 0, 2) ]) { return false; } 
  588.  
  589. $MovedChar = substr($iban, 4) . substr($iban, 0, 4); 
  590. $MovedCharArray = str_split($MovedChar); 
  591. $NewString = ""; 
  592.  
  593. foreach ($MovedCharArray as $k => $v) { 
  594.  
  595. if ( !is_numeric($MovedCharArray[$k]) ) { 
  596. $MovedCharArray[$k] = $Chars[$MovedCharArray[$k]]; 
  597. $NewString .= $MovedCharArray[$k]; 
  598. if (function_exists("bcmod")) { return bcmod($NewString, '97') == 1; } 
  599.  
  600. $x = $NewString; $y = "97"; 
  601. $take = 5; $mod = ""; 
  602.  
  603. do { 
  604. $a = (int)$mod . substr($x, 0, $take); 
  605. $x = substr($x, $take); 
  606. $mod = $a % $y; 
  607. while (strlen($x)); 
  608.  
  609. return (int)$mod == 1;