Guest User

Untitled

a guest
Oct 1st, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.56 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @package database
  5. * @author Lukafurlan
  6. * @version 1.0
  7. *
  8. */
  9. class database {
  10.  
  11. public function db()
  12. {
  13. $connection = new PDO("mysql:host=;port=3306;dbname=", "", "");
  14. $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  15. return $connection;
  16. }
  17.  
  18. //REGISTRATION//
  19.  
  20. public function register($username, $email, $password, $paypalEmail, $serverName, $serverWebsite, $claimCommand, $storeId)
  21. {
  22. try
  23. {
  24. $this->connection = $this->db();
  25. $stmt = $this->connection->prepare("INSERT INTO members (username, email, password, paypalEmail, serverName, serverWebsite, claimCommand, storeId) VALUES (:username, :email, :password, :paypalEmail, :serverName, :serverWebsite, :claimCommand, :storeId)");
  26. $stmt->bindParam(":username", $username);
  27. $stmt->bindParam(":email", $email);
  28. $stmt->bindParam(":password", $password);
  29. $stmt->bindParam(":paypalEmail", $paypalEmail);
  30. $stmt->bindParam(":serverName", $serverName);
  31. $stmt->bindParam(":serverWebsite", $serverWebsite);
  32. $stmt->bindParam(":claimCommand", $claimCommand);
  33. $stmt->bindParam(":storeId", $storeId);
  34. $stmt->execute();
  35. }
  36. catch (PDOException $exception)
  37. {
  38. echo $exception->getMessage();
  39. }
  40. }
  41.  
  42. public function usernameExists($username)
  43. {
  44. try
  45. {
  46. $this->connection = $this->db();
  47. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM members WHERE username = :username");
  48. $stmt->bindParam(':username', $username);
  49. $stmt->execute();
  50. $rows = $stmt->fetchColumn();
  51. return $rows;
  52. }
  53. catch (Exception $exception)
  54. {
  55. echo $exception->getMessage();
  56. }
  57. }
  58.  
  59. public function emailExists($email)
  60. {
  61. try
  62. {
  63. $this->connection = $this->db();
  64. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM members WHERE email = :email");
  65. $stmt->bindParam(':emailAdress', $email);
  66. $stmt->execute();
  67. $rows = $stmt->fetchColumn();
  68. return $rows;
  69. }
  70. catch (Exception $exception)
  71. {
  72. echo $exception->getMessage();
  73. }
  74. }
  75.  
  76. //LOGIN//
  77.  
  78. public function checkPassword($username)
  79. {
  80. try
  81. {
  82. $this->connection = $this->db();
  83. $stmt = $this->connection->prepare("SELECT password FROM members WHERE username = :username");
  84. $stmt->bindParam(':username', $username);
  85. $stmt->execute();
  86. $row = $stmt->fetch();
  87. return $row['password'];
  88. }
  89. catch (Exception $exception)
  90. {
  91. echo $exception->getMessage();
  92. }
  93. }
  94.  
  95. public function getEmail($username)
  96. {
  97. try
  98. {
  99. $this->connection = $this->db();
  100. $stmt = $this->connection->prepare("SELECT email FROM members WHERE username = :username");
  101. $stmt->bindParam(':username', $username);
  102. $stmt->execute();
  103. $row = $stmt->fetch();
  104. return $row['email'];
  105. }
  106. catch (Exception $exception)
  107. {
  108. echo $exception->getMessage();
  109. }
  110. }
  111.  
  112. //CHECK//
  113.  
  114. public function getUserData($username)
  115. {
  116. try
  117. {
  118. $this->connection = $this->db();
  119. $stmt = $this->connection->prepare("SELECT * FROM members WHERE username = :username");
  120. $stmt->bindParam(':username', $username);
  121. $stmt->execute();
  122. $row = $stmt->fetch();
  123. return $row;
  124. }
  125. catch (Exception $exception)
  126. {
  127. echo $exception->getMessage();
  128. }
  129. }
  130.  
  131. //SETTINGS//
  132.  
  133. public function changePassword($username, $password)
  134. {
  135. try
  136. {
  137. $this->connection = $this->db();
  138. $stmt = $this->connection->prepare("UPDATE members SET password = :password WHERE username = :username");
  139. $stmt->bindParam(':password', $password);
  140. $stmt->bindParam(':username', $username);
  141. $stmt->execute();
  142. }
  143. catch (Exception $exception)
  144. {
  145. echo $exception->getMessage();
  146. }
  147. }
  148.  
  149. //PRODUCTS//
  150.  
  151. public function addProduct($storeId, $productName, $productPrice, $productDescription, $productImage, $productCategoryId, $productCategoryName)
  152. {
  153. try
  154. {
  155. $this->connection = $this->db();
  156. $stmt = $this->connection->prepare("INSERT INTO products (storeId, productName, productPrice, productDescription, productImage, productCategoryId, productCategoryName) VALUES (:storeId, :productName, :productPrice, :productDescription, :productImage, :productCategoryId, :productCategoryName)");
  157. $stmt->bindParam(":storeId", $storeId);
  158. $stmt->bindParam(":productName", $productName);
  159. $stmt->bindParam(":productPrice", $productPrice);
  160. $stmt->bindParam(":productDescription", $productDescription);
  161. $stmt->bindParam(":productImage", $productImage);
  162. $stmt->bindParam(":productCategoryId", $productCategoryId);
  163. $stmt->bindParam(":productCategoryName", $productCategoryName);
  164. $stmt->execute();
  165. }
  166. catch (PDOException $exception)
  167. {
  168. echo $exception->getMessage();
  169. }
  170. }
  171.  
  172. public function editProduct($storeId, $productName, $productPrice, $productDescription, $productImage, $productId)
  173. {
  174. try
  175. {
  176. $this->connection = $this->db();
  177. $stmt = $this->connection->prepare("UPDATE products SET productName = :productName, productPrice = :productPrice, productDescription = :productDescription, productImage = :productImage WHERE storeId = :storeId AND id = :productId");
  178. $stmt->bindParam(":storeId", $storeId);
  179. $stmt->bindParam(":productId", $productId);
  180. $stmt->bindParam(":productName", $productName);
  181. $stmt->bindParam(":productPrice", $productPrice);
  182. $stmt->bindParam(":productDescription", $productDescription);
  183. $stmt->bindParam(":productImage", $productImage);
  184. $stmt->execute();
  185. }
  186. catch (PDOException $exception)
  187. {
  188. echo $exception->getMessage();
  189. }
  190. }
  191.  
  192. public function deleteProduct($productId, $storeId)
  193. {
  194. try
  195. {
  196. $this->connection = $this->db();
  197. $stmt = $this->connection->prepare("DELETE FROM products WHERE id = :id AND storeId = :storeId");
  198. $stmt->bindParam(":id", $productId);
  199. $stmt->bindParam(":storeId", $storeId);
  200. $stmt->execute();
  201. }
  202. catch (PDOException $exception)
  203. {
  204. echo $exception->getMessage();
  205. }
  206. }
  207.  
  208. public function promoteProduct($productId)
  209. {
  210. try
  211. {
  212. $this->connection = $this->db();
  213. $stmt = $this->connection->prepare("UPDATE products SET isPromoted=1 WHERE id = :id");
  214. $stmt->bindParam(":id", $productId);
  215. $stmt->execute();
  216. }
  217. catch (PDOException $exception)
  218. {
  219. echo $exception->getMessage();
  220. }
  221. }
  222. public function changeDescription($username, $desc)
  223. {
  224. try
  225. {
  226. $this->connection = $this->db();
  227. $stmt = $this->connection->prepare("UPDATE members SET description = :desc WHERE username = :username");
  228. $stmt->bindParam(":username", $username);
  229. $stmt->bindParam(":desc", $desc);
  230. $stmt->execute();
  231. }
  232. catch (PDOException $exception)
  233. {
  234. echo $exception->getMessage();
  235. }
  236. }
  237. public function demoteProduct($productId)
  238. {
  239. try
  240. {
  241. $this->connection = $this->db();
  242. $stmt = $this->connection->prepare("UPDATE products SET isPromoted=0 WHERE id = :id");
  243. $stmt->bindParam(":id", $productId);
  244. $stmt->execute();
  245. }
  246. catch (PDOException $exception)
  247. {
  248. echo $exception->getMessage();
  249. }
  250. }
  251.  
  252. public function deleteCategory($categoryId, $storeId)
  253. {
  254. try
  255. {
  256. $this->connection = $this->db();
  257. $stmt = $this->connection->prepare("DELETE FROM categories WHERE id = :id AND storeId = :storeId");
  258. $stmt->bindParam(":id", $categoryId);
  259. $stmt->bindParam(":storeId", $storeId);
  260. $stmt->execute();
  261. }
  262. catch (PDOException $exception)
  263. {
  264. echo $exception->getMessage();
  265. }
  266. }
  267.  
  268. public function addCategory($categoryName, $storeId)
  269. {
  270. try
  271. {
  272. $this->connection = $this->db();
  273. $stmt = $this->connection->prepare("INSERT INTO categories (storeId, categoryName) VALUES (:storeId, :categoryName)");
  274. $stmt->bindParam(":storeId", $storeId);
  275. $stmt->bindParam(":categoryName", $categoryName);
  276. $stmt->execute();
  277. }
  278. catch (PDOException $exception)
  279. {
  280. echo $exception->getMessage();
  281. }
  282. }
  283.  
  284. public function getCategoryCount($storeId)
  285. {
  286. try
  287. {
  288. $this->connection = $this->db();
  289. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM categories WHERE storeId = :storeId");
  290. $stmt->bindParam(':storeId', $storeId);
  291. $stmt->execute();
  292. $rows = $stmt->fetchColumn();
  293. return $rows;
  294. }
  295. catch (Exception $exception)
  296. {
  297. echo $exception->getMessage();
  298. }
  299. }
  300.  
  301. public function getCategories($storeId)
  302. {
  303. try
  304. {
  305. $this->connection = $this->db();
  306. $stmt = $this->connection->prepare("SELECT * FROM categories WHERE storeId = :storeId");
  307. $stmt->bindParam(':storeId', $storeId);
  308. $stmt->execute();
  309. $rows = $stmt->fetchAll();
  310. return $rows;
  311. }
  312. catch (Exception $exception)
  313. {
  314. echo $exception->getMessage();
  315. }
  316. }
  317.  
  318. public function getProducts($storeId)
  319. {
  320. try
  321. {
  322. $this->connection = $this->db();
  323. $stmt = $this->connection->prepare("SELECT * FROM products WHERE storeId = :storeId");
  324. $stmt->bindParam(':storeId', $storeId);
  325. $stmt->execute();
  326. $rows = $stmt->fetchAll();
  327. return $rows;
  328. }
  329. catch (Exception $exception)
  330. {
  331. echo $exception->getMessage();
  332. }
  333. }
  334.  
  335.  
  336. public function getCategoryNameForId($categoryId)
  337. {
  338. try
  339. {
  340. $this->connection = $this->db();
  341. $stmt = $this->connection->prepare("SELECT categoryName FROM categories WHERE id = :categoryId");
  342. $stmt->bindParam(':categoryId', $categoryId);
  343. $stmt->execute();
  344. $row = $stmt->fetch();
  345. return $row['categoryName'];
  346. }
  347. catch (Exception $exception)
  348. {
  349. echo $exception->getMessage();
  350. }
  351. }
  352.  
  353. //GATEWAYS//
  354.  
  355. public function changePaypal($email, $uid)
  356. {
  357. try
  358. {
  359. $this->connection = $this->db();
  360. $stmt = $this->connection->prepare("UPDATE members SET paypalEmail = :paypalEmail WHERE id = :uid");
  361. $stmt->bindParam(':paypalEmail', $email);
  362. $stmt->bindParam(':uid', $uid);
  363. $stmt->execute();
  364. }
  365. catch (Exception $exception)
  366. {
  367. echo $exception->getMessage();
  368. }
  369. }
  370.  
  371. //WEBSTORE//
  372.  
  373. public function webstore($storeId)
  374. {
  375. try
  376. {
  377. $this->connection = $this->db();
  378. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM members WHERE storeId = :storeId");
  379. $stmt->bindParam(':storeId', $storeId);
  380. $stmt->execute();
  381. $rows = $stmt->fetchColumn();
  382. return $rows;
  383. }
  384. catch (Exception $exception)
  385. {
  386. echo $exception->getMessage();
  387. }
  388. }
  389.  
  390. public function webstoreData($storeId)
  391. {
  392. try
  393. {
  394. $this->connection = $this->db();
  395. $stmt = $this->connection->prepare("SELECT id, claimCommand, description, storeId, serverName, serverWebsite, paypalEmail, isPremium FROM members WHERE storeId = :storeId");
  396. $stmt->bindParam(':storeId', $storeId);
  397. $stmt->execute();
  398. $rows = $stmt->fetchAll();
  399. return $rows;
  400. }
  401. catch (Exception $exception)
  402. {
  403. echo $exception->getMessage();
  404. }
  405. }
  406.  
  407. public function countPromotedProducts($storeId)
  408. {
  409. try
  410. {
  411. $this->connection = $this->db();
  412. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM products WHERE storeId = :storeId AND isPromoted = 1");
  413. $stmt->bindParam(':storeId', $storeId);
  414. $stmt->execute();
  415. $rows = $stmt->fetchColumn();
  416. return $rows;
  417. }
  418. catch (Exception $exception)
  419. {
  420. echo $exception->getMessage();
  421. }
  422. }
  423.  
  424. public function getPromotedProducts($storeId)
  425. {
  426. try
  427. {
  428. $this->connection = $this->db();
  429. $stmt = $this->connection->prepare("SELECT * FROM products WHERE storeId = :storeId AND isPromoted = 1");
  430. $stmt->bindParam(':storeId', $storeId);
  431. $stmt->execute();
  432. $rows = $stmt->fetchAll();
  433. return $rows;
  434. }
  435. catch (Exception $exception)
  436. {
  437. echo $exception->getMessage();
  438. }
  439. }
  440.  
  441. public function tabExists($tabId, $storeId)
  442. {
  443. try
  444. {
  445. $this->connection = $this->db();
  446. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM categories WHERE storeId = :storeId AND id = :tabId");
  447. $stmt->bindParam(':storeId', $storeId);
  448. $stmt->bindParam(':tabId', $tabId);
  449. $stmt->execute();
  450. $rows = $stmt->fetchColumn();
  451. return $rows;
  452. }
  453. catch (Exception $exception)
  454. {
  455. echo $exception->getMessage();
  456. }
  457. }
  458.  
  459. public function getProductsForCategory($tab, $storeId)
  460. {
  461. try
  462. {
  463. $this->connection = $this->db();
  464. $stmt = $this->connection->prepare("SELECT * FROM products WHERE storeId = :storeId AND productCategoryId = :tab");
  465. $stmt->bindParam(':storeId', $storeId);
  466. $stmt->bindParam(':tab', $tab);
  467. $stmt->execute();
  468. $rows = $stmt->fetchAll();
  469. return $rows;
  470. }
  471. catch (Exception $exception)
  472. {
  473. echo $exception->getMessage();
  474. }
  475. }
  476.  
  477. public function getProductsForId($productId, $storeId)
  478. {
  479. try
  480. {
  481. $this->connection = $this->db();
  482. $stmt = $this->connection->prepare("SELECT * FROM products WHERE storeId = :storeId AND id = :productId");
  483. $stmt->bindParam(':storeId', $storeId);
  484. $stmt->bindParam(':productId', $productId);
  485. $stmt->execute();
  486. $rows = $stmt->fetchAll();
  487. return $rows;
  488. }
  489. catch (Exception $exception)
  490. {
  491. echo $exception->getMessage();
  492. }
  493. }
  494.  
  495. public function productBelongsToStore($productId, $storeId)
  496. {
  497. try
  498. {
  499. $this->connection = $this->db();
  500. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM products WHERE storeId = :storeId AND id = :productId");
  501. $stmt->bindParam(':storeId', $storeId);
  502. $stmt->bindParam(':productId', $productId);
  503. $stmt->execute();
  504. $rows = $stmt->fetchColumn();
  505. return $rows;
  506. }
  507. catch (Exception $exception)
  508. {
  509. echo $exception->getMessage();
  510. }
  511. }
  512.  
  513. //IPN//
  514.  
  515. public function purchaseData($itemName, $itemNumber, $paymentStatus, $mcGross, $txnId, $payerEmail, $storeId, $purchaseId, $purchaseDate, $purchaseMonth)
  516. {
  517. try
  518. {
  519. $this->connection = $this->db();
  520. $stmt = $this->connection->prepare("INSERT INTO paymentData (payerEmail, itemNumber, paymentStatus, mcGros, txnId, storeId, purchaseId, purchaseDate, purchaseMonth) VALUES (:payerEmail, :itemNumber, :paymentStatus, :mcGros, :txnId, :storeId, :purchaseId, :purchaseDate, :purchaseMonth)");
  521. $stmt->bindParam(":payerEmail", $payerEmail);
  522. $stmt->bindParam(":itemNumber", $itemNumber);
  523. $stmt->bindParam(":paymentStatus", $paymentStatus);
  524. $stmt->bindParam(":mcGros", $mcGross);
  525. $stmt->bindParam(":txnId", $txnId);
  526. $stmt->bindParam(":storeId", $storeId);
  527. $stmt->bindParam(":purchaseId", $purchaseId);
  528. $stmt->bindParam(":purchaseDate", $purchaseDate);
  529. $stmt->bindParam(":purchaseMonth", $purchaseMonth);
  530. $stmt->execute();
  531. }
  532. catch (PDOException $exception)
  533. {
  534. echo $exception->getMessage();
  535. }
  536. }
  537.  
  538. public function updatePurchase($storeId, $purchaseId)
  539. {
  540. try
  541. {
  542. $this->connection = $this->db();
  543. $stmt = $this->connection->prepare("UPDATE checkout SET canClaim = 1 WHERE storeId = :storeId AND checkoutId = :purchaseId");
  544. $stmt->bindParam(':storeId', $storeId);
  545. $stmt->bindParam(':purchaseId', $purchaseId);
  546. $stmt->execute();
  547. $rows = $stmt->fetchColumn();
  548. return $rows;
  549. }
  550. catch (Exception $exception)
  551. {
  552. echo $exception->getMessage();
  553. }
  554. }
  555.  
  556. public function checkout($storeId, $productId, $purchaseId, $customEncryption, $playerName, $ip, $quantity)
  557. {
  558. try
  559. {
  560. $this->connection = $this->db();
  561. $stmt = $this->connection->prepare("INSERT INTO checkout (storeId, productId, checkoutId, customEncryption, playerName, ip, date, quantity) VALUES (:storeId, :productId, :purchaseId, :customEncryption, :playerName, :ip, :date, :quantity)");
  562. $stmt->bindParam(":storeId", $storeId);
  563. $stmt->bindParam(":productId", $productId);
  564. $stmt->bindParam(":purchaseId", $purchaseId);
  565. $stmt->bindParam(":customEncryption", $customEncryption);
  566. $stmt->bindParam(":playerName", $playerName);
  567. $stmt->bindParam(":ip", $ip);
  568. $stmt->bindParam(":quantity", $quantity);
  569. $stmt->bindParam(":date", date("D M j G:i:s T Y"));
  570. $stmt->execute();
  571. }
  572. catch (PDOException $exception)
  573. {
  574. echo $exception->getMessage();
  575. }
  576. }
  577.  
  578. public function getPurchaseData($storeId)
  579. {
  580. try
  581. {
  582. $this->connection = $this->db();
  583. $stmt = $this->connection->prepare("SELECT * FROM paymentData WHERE storeId = :storeId");
  584. $stmt->bindParam(':storeId', $storeId);
  585. $stmt->execute();
  586. $rows = $stmt->fetchAll();
  587. return $rows;
  588. }
  589. catch (Exception $exception)
  590. {
  591. echo $exception->getMessage();
  592. }
  593. }
  594.  
  595. public function paymentAlreadyRecieved($purchaseId)
  596. {
  597. try
  598. {
  599. $this->connection = $this->db();
  600. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM paymentData WHERE purchaseId = :purchaseId");
  601. $stmt->bindParam(':purchaseId', $purchaseId);
  602. $stmt->execute();
  603. $rows = $stmt->fetchColumn();
  604. return $rows;
  605. }
  606. catch (Exception $exception)
  607. {
  608. echo $exception->getMessage();
  609. }
  610. }
  611.  
  612. public function updatePayment($purchaseId, $paymentStatus, $txnId)
  613. {
  614. $chargeBackVar = 3;
  615. try
  616. {
  617. $this->connection = $this->db();
  618. $stmt = $this->connection->prepare("UPDATE paymentData SET paymentStatus = :paymentStatus WHERE purchaseId = :purchaseId");
  619. $stmt->bindParam(':purchaseId', $purchaseId);
  620. $stmt->bindParam(':paymentStatus', $paymentStatus);
  621. $stmt->execute();
  622. $stmt = $this->connection->prepare("UPDATE checkout SET canClaim = :paymentStatus, txnId = :txnId WHERE checkoutId = :purchaseId");
  623. $stmt->bindParam(':purchaseId', $purchaseId);
  624. $stmt->bindParam(':paymentStatus', 2);
  625. $stmt->bindParam(':txnId', $txnId);
  626. $stmt->execute();
  627. }
  628. catch (Exception $exception)
  629. {
  630. echo $exception->getMessage();
  631. }
  632. }
  633.  
  634. public function getCheckoutData($storeId)
  635. {
  636. try
  637. {
  638. $this->connection = $this->db();
  639. $stmt = $this->connection->prepare("SELECT * FROM checkout WHERE storeId = :storeId");
  640. $stmt->bindParam(':storeId', $storeId);
  641. $stmt->execute();
  642. $rows = $stmt->fetchAll();
  643. return $rows;
  644. }
  645. catch (Exception $exception)
  646. {
  647. echo $exception->getMessage();
  648. }
  649. }
  650.  
  651. public function getTransactionsPerMonth($storeId, $month)
  652. {
  653. try
  654. {
  655. $this->connection = $this->db();
  656. $stmt = $this->connection->prepare("SELECT COUNT(*) FROM paymentData WHERE storeId = :storeId AND purchaseMonth = :purchaseMonth");
  657. $stmt->bindParam(':storeId', $storeId);
  658. $stmt->bindParam(':purchaseMonth', $month);
  659. $stmt->execute();
  660. $rows = $stmt->fetchColumn();
  661. return $rows;
  662. }
  663. catch (Exception $exception)
  664. {
  665. echo $exception->getMessage();
  666. }
  667. }
  668.  
  669. public function totalProfit($storeId)
  670. {
  671. try
  672. {
  673. $this->connection = $this->db();
  674. $stmt = $this->connection->prepare("SELECT SUM(mcGros) FROM paymentData WHERE storeId = :storeId");
  675. $stmt->bindParam(':storeId', $storeId);
  676. $stmt->execute();
  677. $rows = $stmt->fetchColumn();
  678. return $rows;
  679. }
  680. catch (Exception $exception)
  681. {
  682. echo $exception->getMessage();
  683. }
  684. }
  685.  
  686. public function totalProfitThisMonth($storeId, $month)
  687. {
  688. try
  689. {
  690. $this->connection = $this->db();
  691. $stmt = $this->connection->prepare("SELECT SUM(mcGros) FROM paymentData WHERE storeId = :storeId AND purchaseMonth = :purchaseMonth");
  692. $stmt->bindParam(':storeId', $storeId);
  693. $stmt->bindParam(':purchaseMonth', $month);
  694. $stmt->execute();
  695. $rows = $stmt->fetchColumn();
  696. return $rows;
  697. }
  698. catch (Exception $exception)
  699. {
  700. echo $exception->getMessage();
  701. }
  702. }
  703.  
  704. public function upgradeToPremium($storeId)
  705. {
  706. try
  707. {
  708. $this->connection = $this->db();
  709. $stmt = $this->connection->prepare("UPDATE members SET isPremium = 1 WHERE storeId = :storeId");
  710. $stmt->bindParam(':storeId', $storeId);
  711. $stmt->execute();
  712. $rows = $stmt->fetchColumn();
  713. return $rows;
  714. }
  715. catch (Exception $exception)
  716. {
  717. echo $exception->getMessage();
  718. }
  719. }
  720.  
  721. public function paymentAuthenticity($totalPrice, $checkoutId, $storeId)
  722. {
  723. try
  724. {
  725. $this->connection = $this->db();
  726. $stmt = $this->connection->prepare("INSERT INTO paymentauthenticity (totalPrice, checkoutId, storeId) VALUES (:totalPrice, :checkoutId, :storeId)");
  727. $stmt->bindParam(':totalPrice', $totalPrice);
  728. $stmt->bindParam(':checkoutId', $checkoutId);
  729. $stmt->bindParam(':storeId', $storeId);
  730. $stmt->execute();
  731. }
  732. catch (Exception $exception)
  733. {
  734. echo $exception->getMessage();
  735. }
  736. }
  737.  
  738. public function checkAuthenticity($checkoutId, $storeId)
  739. {
  740. try
  741. {
  742. $this->connection = $this->db();
  743. $stmt = $this->connection->prepare("SELECT totalPrice FROM paymentauthenticity WHERE storeId = :storeId AND checkoutId = :checkoutId");
  744. $stmt->bindParam(':checkoutId', $checkoutId);
  745. $stmt->bindParam(':storeId', $storeId);
  746. $stmt->execute();
  747. $rows = $stmt->fetch(PDO::FETCH_OBJ);
  748. return $rows;
  749. }
  750. catch (Exception $exception)
  751. {
  752. echo $exception->getMessage();
  753. }
  754. }
  755.  
  756.  
  757. }
Add Comment
Please, Sign In to add comment