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