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