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