1: <?php
2:
3: namespace Mypos\IPC;
4:
5: abstract class CardStore extends Base
6: {
7: const CARD_VERIFICATION_NO = 1;
8: const CARD_VERIFICATION_YES = 2;
9: private $currency = 'EUR', $amount, $cardVerification;
10:
11: /**
12: * Amount of the transaction
13: * Used in the request if CardVerification = CARD_VERIFICATION_YES.
14: *
15: * @return float
16: */
17: public function getAmount()
18: {
19: return $this->amount;
20: }
21:
22: /**
23: * Amount of the transaction.
24: * Used in the request if CardVerification = CARD_VERIFICATION_YES.
25: *
26: * @param float $amount
27: */
28: public function setAmount($amount)
29: {
30: $this->amount = $amount;
31: }
32:
33: /**
34: * Specify whether the inputted card data to be verified or not before storing
35: *
36: * @param int $cardVerification
37: */
38: public function setCardVerification($cardVerification)
39: {
40: $this->cardVerification = $cardVerification;
41: }
42:
43: /**
44: * Validate all set purchase details
45: *
46: * @return boolean
47: * @throws IPC_Exception
48: */
49: public function validate()
50: {
51: if ($this->getCardVerification() == null || !in_array($this->getCardVerification(), [
52: self::CARD_VERIFICATION_NO,
53: self::CARD_VERIFICATION_YES,
54: ])) {
55: throw new IPC_Exception('Invalid card verification');
56: }
57:
58: if ($this->getCardVerification() == self::CARD_VERIFICATION_YES && $this->getCurrency() === null) {
59: throw new IPC_Exception('Invalid currency');
60: }
61:
62: return true;
63: }
64:
65: /**
66: * Specify whether the inputted card data to be verified or not before storing
67: *
68: * @return int
69: */
70: public function getCardVerification()
71: {
72: return $this->cardVerification;
73: }
74:
75: /**
76: * ISO-4217 Three letter currency code
77: * Used in the request if CardVerification = CARD_VERIFICATION_YES.
78: *
79: * @return string
80: */
81: public function getCurrency()
82: {
83: return $this->currency;
84: }
85:
86: /**
87: * ISO-4217 Three letter currency code
88: * Used in the request if CardVerification = CARD_VERIFICATION_YES.
89: *
90: * @param string $currency
91: *
92: * @return CardStore
93: */
94: public function setCurrency($currency)
95: {
96: $this->currency = $currency;
97:
98: return $this;
99: }
100: }