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: | $this->_addPostParam('ApplicationID', $this->getCnf()->getApplicationId());
|
61: | $this->_addPostParam('PartnerID', $this->getCnf()->getPartnerId());
|
62: |
|
63: | return $this->_processPost();
|
64: | }
|
65: |
|
66: | |
67: | |
68: | |
69: | |
70: | |
71: |
|
72: | public function validate()
|
73: | {
|
74: | parent::validate();
|
75: |
|
76: | try {
|
77: | $this->getCnf()->validate();
|
78: | } catch (\Exception $ex) {
|
79: | throw new IPC_Exception('Invalid Config details: '.$ex->getMessage());
|
80: | }
|
81: |
|
82: | if ($this->getCard() === null) {
|
83: | throw new IPC_Exception('Missing card details');
|
84: | }
|
85: |
|
86: | try {
|
87: | $this->getCard()->validate();
|
88: | } catch (\Exception $ex) {
|
89: | throw new IPC_Exception('Invalid Card details: '.$ex->getMessage());
|
90: | }
|
91: |
|
92: | if ($this->getCnf()->getVersion() === '1.4.1') {
|
93: | if ($this->getCnf()->getPartnerID() == null) {
|
94: | throw new IPC_Exception('Required parameter: Partner ID');
|
95: | }
|
96: |
|
97: | if ($this->getCnf()->getApplicationID() == null) {
|
98: | throw new IPC_Exception('Required parameter: Application ID');
|
99: | }
|
100: | }
|
101: |
|
102: | return true;
|
103: | }
|
104: |
|
105: | |
106: | |
107: | |
108: | |
109: |
|
110: | public function getCard()
|
111: | {
|
112: | return $this->card;
|
113: | }
|
114: |
|
115: | |
116: | |
117: | |
118: | |
119: |
|
120: | public function setCard($card)
|
121: | {
|
122: | $this->card = $card;
|
123: | }
|
124: |
|
125: | }
|
126: | |