1 <?php
2
3 namespace Mypos\IPC;
4
5 6 7 8
9 class MandateManagement extends Base
10 {
11
12 const MANDATE_MANAGEMENT_ACTION_REGISTER = 1;
13 const MANDATE_MANAGEMENT_ACTION_CANCEL = 2;
14
15
16 private $mandateReferece, $customerWalletNumber, $action, $mandateText;
17
18 19 20 21
22 public function __construct(Config $cnf)
23 {
24 $this->setCnf($cnf);
25 }
26
27 28 29 30
31 public function getMandateReferece()
32 {
33 return $this->mandateReferece;
34 }
35
36 37 38 39
40 public function setMandateReferece($mandateReferece)
41 {
42 $this->mandateReferece = $mandateReferece;
43 }
44
45 46 47 48
49 public function getCustomerWalletNumber()
50 {
51 return $this->customerWalletNumber;
52 }
53
54 55 56 57
58 public function setCustomerWalletNumber($customerWalletNumber)
59 {
60 $this->customerWalletNumber = $customerWalletNumber;
61 }
62
63 64 65 66 67
68 public function getAction()
69 {
70 return $this->action;
71 }
72
73 74 75 76
77 public function setAction($action)
78 {
79 $this->action = $action;
80 }
81
82 83 84 85
86 public function getMandateText()
87 {
88 return $this->mandateText;
89 }
90
91 92 93 94
95 public function setMandateText($mandateText)
96 {
97 $this->mandateText = $mandateText;
98 }
99
100 101 102 103
104 public function process()
105 {
106 $this->validate();
107 $this->_addPostParam('IPCmethod', 'IPCMandateManagement');
108 $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
109 $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
110 $this->_addPostParam('SID', $this->getCnf()->getSid());
111 $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
112 $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
113 $this->_addPostParam('Source', Defines::SOURCE_PARAM);
114 $this->_addPostParam('MandateReference', $this->getMandateReferece());
115 $this->_addPostParam('CustomerWalletNumber', $this->getCustomerWalletNumber());
116 $this->_addPostParam('Action', $this->getAction());
117 $this->_addPostParam('MandateText', $this->getMandateText());
118 $this->_addPostParam('OutputFormat', $this->getOutputFormat());
119 return $this->_processPost();
120 }
121
122 123 124 125 126
127 public function validate()
128 {
129 try {
130 $this->getCnf()->validate();
131 } catch (\Exception $ex) {
132 throw new IPC_Exception('Invalid Config details: ' . $ex->getMessage());
133 }
134
135 if ($this->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
136 throw new IPC_Exception('Invalid Output format');
137 }
138
139 return true;
140 }
141 }