1: <?php
2:
3: namespace Mypos\IPC;
4:
5: /**
6: * Process IPC method: IPCPreAuthorizationStatus.
7: * Collect, validate and send API params
8: */
9: class PreAuthorizationStatus extends Base
10: {
11: private $orderID;
12:
13: /**
14: * Return purchase object
15: *
16: * @param Config $cnf
17: */
18: public function __construct(Config $cnf)
19: {
20: $this->setCnf($cnf);
21: }
22:
23: /**
24: * Purchase identifier - must be unique
25: *
26: * @param string $orderID
27: *
28: * @return PreAuthorizationStatus
29: */
30: public function setOrderID($orderID)
31: {
32: $this->orderID = $orderID;
33:
34: return $this;
35: }
36:
37: /**
38: * Initiate API request
39: *
40: * @return Response
41: * @throws IPC_Exception
42: */
43: public function process()
44: {
45: $this->validate();
46:
47: $this->_addPostParam('IPCmethod', 'IPCPreAuthStatus');
48: $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
49: $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
50: $this->_addPostParam('SID', $this->getCnf()->getSid());
51: $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
52: $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
53: $this->_addPostParam('Source', $this->getCnf()->getSource());
54:
55: $this->_addPostParam('OrderID', $this->getOrderID());
56:
57: $this->_addPostParam('OutputFormat', $this->getOutputFormat());
58:
59: return $this->_processPost();
60: }
61:
62: /**
63: * Validate all set purchase details
64: *
65: * @return boolean
66: * @throws IPC_Exception
67: */
68: public function validate()
69: {
70: try {
71: $this->getCnf()->validate();
72: } catch (\Exception $ex) {
73: throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
74: }
75:
76: if (!Helper::versionCheck($this->getCnf()->getVersion(), '1.4')) {
77: throw new IPC_Exception('IPCVersion ' . $this->getCnf()->getVersion() . ' does not support IPCPreAuthorizationStatus method. Please use 1.4 or above.');
78: }
79:
80: return true;
81: }
82:
83: /**
84: * Purchase identifier
85: *
86: * @return string
87: */
88: public function getOrderID()
89: {
90: return $this->orderID;
91: }
92: }
93: