1: | <?php
|
2: |
|
3: | namespace Mypos\IPC;
|
4: |
|
5: | |
6: | |
7: | |
8: |
|
9: | class SendMoney extends Base
|
10: | {
|
11: | private $currency = 'EUR', $amount, $orderID, $customerWalletNumber, $reason;
|
12: |
|
13: | |
14: | |
15: | |
16: | |
17: |
|
18: | public function __construct(Config $cnf)
|
19: | {
|
20: | $this->setCnf($cnf);
|
21: | }
|
22: |
|
23: | |
24: | |
25: | |
26: | |
27: |
|
28: | public function setAmount($amount)
|
29: | {
|
30: | $this->amount = $amount;
|
31: | }
|
32: |
|
33: | |
34: | |
35: | |
36: | |
37: | |
38: | |
39: |
|
40: | public function setOrderID($orderID)
|
41: | {
|
42: | $this->orderID = $orderID;
|
43: |
|
44: | return $this;
|
45: | }
|
46: |
|
47: | |
48: | |
49: | |
50: | |
51: |
|
52: | public function setCustomerWalletNumber($customerWalletNumber)
|
53: | {
|
54: | $this->customerWalletNumber = $customerWalletNumber;
|
55: | }
|
56: |
|
57: | |
58: | |
59: | |
60: | |
61: |
|
62: | public function setReason($reason)
|
63: | {
|
64: | $this->reason = $reason;
|
65: | }
|
66: |
|
67: | |
68: | |
69: | |
70: | |
71: | |
72: |
|
73: | public function process()
|
74: | {
|
75: | $this->validate();
|
76: |
|
77: | $this->_addPostParam('IPCmethod', 'IPCSendMoney');
|
78: | $this->_addPostParam('IPCVersion', $this->getCnf()->getVersion());
|
79: | $this->_addPostParam('IPCLanguage', $this->getCnf()->getLang());
|
80: | $this->_addPostParam('SID', $this->getCnf()->getSid());
|
81: | $this->_addPostParam('WalletNumber', $this->getCnf()->getWallet());
|
82: | $this->_addPostParam('KeyIndex', $this->getCnf()->getKeyIndex());
|
83: | $this->_addPostParam('Source', $this->getCnf()->getSource());
|
84: |
|
85: | $this->_addPostParam('Currency', $this->getCurrency());
|
86: | $this->_addPostParam('Amount', $this->getAmount());
|
87: |
|
88: | $this->_addPostParam('OrderID', $this->getOrderID());
|
89: |
|
90: | $this->_addPostParam('CustomerWalletNumber', $this->getCustomerWalletNumber());
|
91: | $this->_addPostParam('Reason', $this->getReason());
|
92: | $this->_addPostParam('OutputFormat', $this->getOutputFormat());
|
93: |
|
94: | $this->_addPostParam('ApplicationID', $this->getCnf()->getApplicationID());
|
95: | $this->_addPostParam('PartnerID', $this->getCnf()->getPartnerID());
|
96: |
|
97: | return $this->_processPost();
|
98: | }
|
99: |
|
100: | |
101: | |
102: | |
103: | |
104: | |
105: |
|
106: | public function validate()
|
107: | {
|
108: | try {
|
109: | $this->getCnf()->validate();
|
110: | } catch (\Exception $ex) {
|
111: | throw new IPC_Exception('Invalid Config details: '.$ex->getMessage());
|
112: | }
|
113: |
|
114: | if ($this->getAmount() == null || !Helper::isValidAmount($this->getAmount())) {
|
115: | throw new IPC_Exception('Invalid Amount');
|
116: | }
|
117: |
|
118: | if ($this->getCurrency() == null) {
|
119: | throw new IPC_Exception('Invalid Currency');
|
120: | }
|
121: |
|
122: | if ($this->getOrderID() == null || !Helper::isValidOrderId($this->getOrderID())) {
|
123: | throw new IPC_Exception('Invalid OrderId');
|
124: | }
|
125: |
|
126: | if ($this->getOutputFormat() == null || !Helper::isValidOutputFormat($this->getOutputFormat())) {
|
127: | throw new IPC_Exception('Invalid Output format');
|
128: | }
|
129: |
|
130: | if ($this->getCnf()->getVersion() === '1.4.1') {
|
131: | if ($this->getCnf()->getPartnerID() == null) {
|
132: | throw new IPC_Exception('Required parameter: Partner ID');
|
133: | }
|
134: |
|
135: | if ($this->getCnf()->getApplicationID() == null) {
|
136: | throw new IPC_Exception('Required parameter: Application ID');
|
137: | }
|
138: | }
|
139: |
|
140: | return true;
|
141: | }
|
142: |
|
143: | |
144: | |
145: | |
146: | |
147: |
|
148: | public function getAmount()
|
149: | {
|
150: | return $this->amount;
|
151: | }
|
152: |
|
153: | |
154: | |
155: | |
156: | |
157: |
|
158: | public function getCurrency()
|
159: | {
|
160: | return $this->currency;
|
161: | }
|
162: |
|
163: | |
164: | |
165: | |
166: | |
167: | |
168: | |
169: |
|
170: | public function setCurrency($currency)
|
171: | {
|
172: | $this->currency = $currency;
|
173: |
|
174: | return $this;
|
175: | }
|
176: |
|
177: | |
178: | |
179: | |
180: | |
181: |
|
182: | public function getOrderID()
|
183: | {
|
184: | return $this->orderID;
|
185: | }
|
186: |
|
187: | |
188: | |
189: | |
190: | |
191: |
|
192: | public function getCustomerWalletNumber()
|
193: | {
|
194: | return $this->customerWalletNumber;
|
195: | }
|
196: |
|
197: | |
198: | |
199: | |
200: | |
201: |
|
202: | public function getReason()
|
203: | {
|
204: | return $this->reason;
|
205: | }
|
206: |
|
207: | } |