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