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