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