1 <?php
2
3 namespace Mypos\IPC;
4
5
6 abstract class CardStore extends Base
7 {
8 const CARD_VERIFICATION_NO = 1;
9 const CARD_VERIFICATION_YES = 2;
10
11 private $currency = 'EUR', $amount, $cardVerification;
12
13 14 15 16 17
18 public function getAmount()
19 {
20 return $this->amount;
21 }
22
23 24 25 26 27
28 public function setAmount($amount)
29 {
30 $this->amount = $amount;
31 }
32
33 34 35 36 37 38
39 public function setCurrency($currency)
40 {
41 $this->currency = $currency;
42 return $this;
43 }
44
45 46 47 48 49
50 public function getCurrency()
51 {
52 return $this->currency;
53 }
54
55 56 57 58
59 public function getCardVerification()
60 {
61 return $this->cardVerification;
62 }
63
64 65 66 67
68 public function setCardVerification($cardVerification)
69 {
70 $this->cardVerification = $cardVerification;
71 }
72
73
74 75 76 77 78
79 public function validate()
80 {
81 if ($this->getCardVerification() == null || !in_array($this->getCardVerification(), [self::CARD_VERIFICATION_NO, self::CARD_VERIFICATION_YES])) {
82 throw new IPC_Exception('Invalid card verification');
83 }
84
85 if ($this->getCardVerification() == self::CARD_VERIFICATION_YES) {
86 if ($this->getCurrency() === null || strpos(Defines::AVL_CURRENCIES, $this->getCurrency()) === false) {
87 throw new IPC_Exception('Invalid currency');
88 }
89 }
90 return true;
91 }
92
93
94 }