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