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