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