1 <?php
2
3 namespace Mypos\IPC;
4
5 6 7 8
9 class IAStoreCard extends CardStore
10 {
11 const CARD_VERIFICATION_NO = 1;
12 const CARD_VERIFICATION_YES = 2;
13 14 15
16 private $card;
17
18 19 20 21 22
23 public function __construct(Config $cnf)
24 {
25 $this->setCnf($cnf);
26 }
27
28 29 30 31 32
33 public function process()
34 {
35 $this->validate();
36
37 $this->_addPostParam('IPCmethod', 'IPCIAStoreCard');
38 $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
39 $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
40 $this->_addPostParam('SID', $this->getCnf()->getSid());
41 $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
42 $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
43 $this->_addPostParam('Source', $this->getCnf()->getSource());
44
45 $this->_addPostParam('CardVerification', $this->getCardVerification());
46 if ($this->getCardVerification() == self::CARD_VERIFICATION_YES) {
47 $this->_addPostParam('Amount', $this->getAmount());
48 $this->_addPostParam('Currency', $this->getCurrency());
49 }
50
51 $this->_addPostParam('CardType', $this->getCard()->getCardType());
52 $this->_addPostParam('PAN', $this->getCard()->getCardNumber(), true);
53 $this->_addPostParam('CardholderName', $this->getCard()->getCardHolder());
54 $this->_addPostParam('ExpDate', $this->getCard()->getExpDate(), true);
55 $this->_addPostParam('CVC', $this->getCard()->getCvc(), true);
56 $this->_addPostParam('ECI', $this->getCard()->getEci());
57 $this->_addPostParam('AVV', $this->getCard()->getAvv());
58 $this->_addPostParam('XID', $this->getCard()->getXid());
59
60 $this->_addPostParam('OutputFormat', $this->getOutputFormat());
61
62 return $this->_processPost();
63 }
64
65 66 67 68 69 70
71 public function validate()
72 {
73 parent::validate();
74 try {
75 $this->getCnf()->validate();
76 } catch (\Exception $ex) {
77 throw new IPC_Exception('Invalid Config details: '.$ex->getMessage());
78 }
79
80 if ($this->getCard() === null) {
81 throw new IPC_Exception('Missing card details');
82 }
83
84 try {
85 $this->getCard()->validate();
86 } catch (\Exception $ex) {
87 throw new IPC_Exception('Invalid Card details: '.$ex->getMessage());
88 }
89
90 return true;
91 }
92
93 94 95 96 97
98 public function getCard()
99 {
100 return $this->card;
101 }
102
103 104 105 106 107
108 public function setCard($card)
109 {
110 $this->card = $card;
111 }
112 }
113