1 | ## $Id: browser.py 17969 2024-11-30 13:46:27Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann |
---|
4 | ## This program is free software; you can redistribute it and/or modify |
---|
5 | ## it under the terms of the GNU General Public License as published by |
---|
6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
7 | ## (at your option) any later version. |
---|
8 | ## |
---|
9 | ## This program is distributed in the hope that it will be useful, |
---|
10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | ## GNU General Public License for more details. |
---|
13 | ## |
---|
14 | ## You should have received a copy of the GNU General Public License |
---|
15 | ## along with this program; if not, write to the Free Software |
---|
16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
17 | ## |
---|
18 | |
---|
19 | from kofacustom.nigeria.remita.studentsbrowser import ( |
---|
20 | module_activated, |
---|
21 | RemitaRequestPaymentStatusPageStudent, |
---|
22 | RemitaVerifyPaymentStatusPageStudent, |
---|
23 | RemitaPageStudent) |
---|
24 | from kofacustom.nigeria.remita.applicantsbrowser import ( |
---|
25 | RemitaRequestPaymentStatusPageApplicant, |
---|
26 | RemitaVerifyPaymentStatusPageApplicant, |
---|
27 | RemitaPageApplicant) |
---|
28 | |
---|
29 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
30 | MERCHANTID = '2067163382' |
---|
31 | HOST = 'login.remita.net' |
---|
32 | HTTPS = True |
---|
33 | API_KEY = '309418' |
---|
34 | SERVICETYPEID = '4430731' |
---|
35 | |
---|
36 | class CustomRemitaRequestPaymentStatusPageStudent( |
---|
37 | RemitaRequestPaymentStatusPageStudent): |
---|
38 | """ Request webservice view for the Remita gateway. |
---|
39 | """ |
---|
40 | |
---|
41 | merchantId = MERCHANTID |
---|
42 | host = HOST |
---|
43 | https = HTTPS |
---|
44 | api_key = API_KEY |
---|
45 | |
---|
46 | def render(self): |
---|
47 | if self.context.p_category == 'plag_test'\ |
---|
48 | and self.context.p_state == 'paid': |
---|
49 | self.redirect(self.url(self.context, 'plagtestinfo')) |
---|
50 | else: |
---|
51 | self.redirect(self.url(self.context, '@@index')) |
---|
52 | return |
---|
53 | |
---|
54 | class CustomRemitaVerifyPaymentStatusPageStudent( |
---|
55 | RemitaVerifyPaymentStatusPageStudent): |
---|
56 | """ Request webservice view for the Remita gateway. |
---|
57 | """ |
---|
58 | |
---|
59 | merchantId = MERCHANTID |
---|
60 | host = HOST |
---|
61 | https = HTTPS |
---|
62 | api_key = API_KEY |
---|
63 | |
---|
64 | def update(self): |
---|
65 | super(CustomRemitaVerifyPaymentStatusPageStudent, self).update() |
---|
66 | # Repair: Uniben allows also previous session students to book a bed |
---|
67 | if self.context.p_category == 'bed_allocation' and self.context.p_state == 'paid' and self.context.ac == None: |
---|
68 | flashtype, msg, log = self.context.doAfterStudentPayment() |
---|
69 | if log is not None: |
---|
70 | self.context.student.writeLogMessage(self, log) |
---|
71 | self.flash(msg, type=flashtype) |
---|
72 | return |
---|
73 | |
---|
74 | class CustomRemitaPageStudent(RemitaPageStudent): |
---|
75 | """ View which sends a POST request to the Remita payment gateway. |
---|
76 | """ |
---|
77 | |
---|
78 | merchantId = MERCHANTID |
---|
79 | host = HOST |
---|
80 | https = HTTPS |
---|
81 | api_key = API_KEY |
---|
82 | |
---|
83 | init_url = '/remita/ecomm/split/init.reg' |
---|
84 | |
---|
85 | @property |
---|
86 | def serviceTypeId(self): |
---|
87 | student = self.context.student |
---|
88 | if self.context.p_category == 'schoolfee': |
---|
89 | if student.current_mode.startswith('dp_'): |
---|
90 | return '2067090482' |
---|
91 | if student.current_mode in ('pg_ft', 'pgd_ft'): |
---|
92 | return '2067090691' |
---|
93 | if student.current_mode in ('pg_pt', 'pgd_pt', 'special_pg_pt'): |
---|
94 | return '2067091011' |
---|
95 | if student.current_mode == 'ug_sw': |
---|
96 | return '2066967204' |
---|
97 | if student.current_mode.endswith('ug_ft'): |
---|
98 | return '2067091395' |
---|
99 | if student.current_mode == 'ug_pt': |
---|
100 | return '2067091679' |
---|
101 | if student.current_mode == 'special_ft': |
---|
102 | return '2750318564' # Module 2 |
---|
103 | if student.is_jupeb: |
---|
104 | return '1946888188' |
---|
105 | if student.current_mode == 'cdl': |
---|
106 | return '9541632464' |
---|
107 | if self.context.p_category == 'bed_allocation': |
---|
108 | if student.is_postgrad: |
---|
109 | return '2067086599' |
---|
110 | return '2067089893' |
---|
111 | if self.context.p_category == 'hostel_maintenance': |
---|
112 | if student.is_postgrad: |
---|
113 | return '2067089226' |
---|
114 | return '2066966390' |
---|
115 | if self.context.p_category == 'clearance': |
---|
116 | if student.current_mode.startswith('dp_'): |
---|
117 | return '2067080314' |
---|
118 | if student.is_jupeb: |
---|
119 | return '1947201668' |
---|
120 | if student.is_postgrad: |
---|
121 | return '2067086157' |
---|
122 | if student.current_mode == 'ug_pt': |
---|
123 | return '2072765946' |
---|
124 | if student.current_mode == 'cdl': |
---|
125 | return '8242101527' |
---|
126 | return '2067089446' |
---|
127 | if self.context.p_category == 'jupeb': |
---|
128 | return '1947198586' |
---|
129 | if self.context.p_category == 'plag_test': |
---|
130 | return '2051987298' |
---|
131 | #if self.context.p_category == 'pharmd_1': |
---|
132 | # return '2750314820' # Clerkship |
---|
133 | if self.context.p_category == 'pharmd_2': |
---|
134 | return '2750174184' # Module 1 |
---|
135 | if self.context.p_category == 'medical_quest': |
---|
136 | return '512570052' |
---|
137 | if self.context.p_category == 'flc_modules': |
---|
138 | return '757257557' |
---|
139 | return '' |
---|
140 | |
---|
141 | def dynamic_provider_amt(self, student): |
---|
142 | if student.entry_session >= 2024: |
---|
143 | return 5000.0 |
---|
144 | return 2000.0 |
---|
145 | |
---|
146 | @property |
---|
147 | def lineitems(self): |
---|
148 | inst_bankcode = "000" |
---|
149 | inst_acct = "0040217361011" |
---|
150 | provider_amt = 0.0 |
---|
151 | student_union = 0.0 |
---|
152 | jupeb_amt = 0.0 |
---|
153 | reduced_inst_amt = 0.0 |
---|
154 | lab_amt = 0.0 |
---|
155 | if self.context.p_category in ('schoolfee', 'schoolfee_1') and \ |
---|
156 | not self.context.p_item == 'Balance': |
---|
157 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
158 | if self.context.student.current_mode == 'ug_ft': |
---|
159 | student_union = 2500.0 |
---|
160 | elif self.context.p_category == 'clearance': |
---|
161 | provider_amt = 5000.0 |
---|
162 | elif self.context.p_category == 'bed_allocation': |
---|
163 | provider_amt = 1000.0 |
---|
164 | |
---|
165 | inst_amt = self.context.amount_auth - provider_amt - student_union |
---|
166 | |
---|
167 | lineitems = ( |
---|
168 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
169 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
170 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
171 | ) |
---|
172 | if provider_amt: |
---|
173 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
174 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
175 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
176 | if student_union: |
---|
177 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union", |
---|
178 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
179 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
180 | |
---|
181 | # We overwrite linetems in case of postgrad student school fee payments |
---|
182 | if self.context.student.is_postgrad and self.context.p_category == 'schoolfee': |
---|
183 | microfinance_amt = 0.1 * inst_amt |
---|
184 | inst_amt -= microfinance_amt |
---|
185 | lineitems = ( |
---|
186 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
187 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
188 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
189 | ) |
---|
190 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"SPGS Scheme", |
---|
191 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
192 | "beneficiaryAmount":microfinance_amt,"deductFeeFrom":"0"}, |
---|
193 | {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
194 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
195 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
196 | |
---|
197 | ## Disabled on 24/02/21 |
---|
198 | ## Reenabled on 19/09/23 (ticket #1327) |
---|
199 | ## We overwrite linetems in case of JUPEB students |
---|
200 | if self.context.student.is_jupeb: |
---|
201 | if self.context.p_category == 'clearance': |
---|
202 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
203 | reduced_inst_amt = 0.7 * inst_amt |
---|
204 | jupeb_amt = 0.3 * inst_amt |
---|
205 | elif self.context.p_category == 'schoolfee' and \ |
---|
206 | not self.context.p_item == 'Balance': |
---|
207 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
208 | #if self.context.student.depcode in ('AGR_JUP','EDU_JUP','ENG_JUP', |
---|
209 | # 'LSC_JUP','MED_JUP','PSC_JUP'): |
---|
210 | # lab_amt = 10000 |
---|
211 | reduced_inst_amt = 0.7 * (inst_amt - lab_amt) |
---|
212 | jupeb_amt = 0.3 * (inst_amt - lab_amt) + lab_amt |
---|
213 | lineitems = ( |
---|
214 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
215 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
216 | "beneficiaryAmount":reduced_inst_amt,"deductFeeFrom":"1"}, |
---|
217 | ) |
---|
218 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"JUPEB", |
---|
219 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
220 | "beneficiaryAmount":jupeb_amt,"deductFeeFrom":"0"},) |
---|
221 | if provider_amt: |
---|
222 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
223 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
224 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
225 | if student_union: |
---|
226 | lineitems += ({"lineItemsId":"itemid4","beneficiaryName":"Student Union", |
---|
227 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
228 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
229 | |
---|
230 | |
---|
231 | # Split pharmd school fee payments into 3 parts if students decide to pay the |
---|
232 | # entire school fee at once. If the amount is less than N240000, the student |
---|
233 | # has obviously paid the first installment of N80000 (pharmd_1) |
---|
234 | # (disabled on 16/03/18) |
---|
235 | #if self.context.p_category == 'schoolfee' \ |
---|
236 | # and self.context.student.current_mode == 'special_ft' \ |
---|
237 | # and self.context.amount_auth >= 240000: |
---|
238 | # pcn_amt = 80000.0 |
---|
239 | # inst_amt -= pcn_amt |
---|
240 | # lineitems = ( |
---|
241 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
242 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
243 | # "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
244 | # {"lineItemsId":"itemid2","beneficiaryName":"PCN", |
---|
245 | # "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode, |
---|
246 | # "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"}, |
---|
247 | # {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
248 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
249 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
250 | # ) |
---|
251 | self.context.provider_amt = provider_amt |
---|
252 | self.context.net_amt = inst_amt |
---|
253 | return lineitems |
---|
254 | |
---|
255 | def update(self): |
---|
256 | if not module_activated( |
---|
257 | self.context.student.current_session, self.context): |
---|
258 | return |
---|
259 | self.orderId = self.context.p_id |
---|
260 | self.amount = str(self.context.amount_auth) |
---|
261 | error = self.init_update() |
---|
262 | if error: |
---|
263 | self.flash(error, type='danger') |
---|
264 | self.redirect(self.url(self.context, '@@index')) |
---|
265 | return |
---|
266 | self.context.r_company = u'remita' |
---|
267 | return |
---|
268 | |
---|
269 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
270 | RemitaRequestPaymentStatusPageApplicant): |
---|
271 | """ Request webservice view for the Remita gateway. |
---|
272 | """ |
---|
273 | |
---|
274 | merchantId = MERCHANTID |
---|
275 | host = HOST |
---|
276 | https = HTTPS |
---|
277 | api_key = API_KEY |
---|
278 | |
---|
279 | |
---|
280 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
281 | RemitaVerifyPaymentStatusPageApplicant): |
---|
282 | """ Request webservice view for the Remita gateway. |
---|
283 | """ |
---|
284 | |
---|
285 | merchantId = MERCHANTID |
---|
286 | host = HOST |
---|
287 | https = HTTPS |
---|
288 | api_key = API_KEY |
---|
289 | |
---|
290 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
291 | """ View which sends a POST request to the Remita payment gateway. |
---|
292 | """ |
---|
293 | |
---|
294 | merchantId = MERCHANTID |
---|
295 | host = HOST |
---|
296 | https = HTTPS |
---|
297 | api_key = API_KEY |
---|
298 | |
---|
299 | init_url = '/remita/ecomm/split/init.reg' |
---|
300 | |
---|
301 | @property |
---|
302 | def serviceTypeId(self): |
---|
303 | applicant = self.context.__parent__ |
---|
304 | if applicant.__parent__.prefix.startswith('dp'): |
---|
305 | return '2066963437' |
---|
306 | if applicant.__parent__.prefix in ('spft', ): |
---|
307 | return '2067086388' |
---|
308 | if applicant.__parent__.prefix == 'pre': |
---|
309 | return '1946882248' |
---|
310 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
311 | 'ab','ak','akj','ase', |
---|
312 | 'afrimal'): |
---|
313 | return '2066965951' |
---|
314 | if applicant.__parent__.prefix in ('tscs', 'tscf'): |
---|
315 | return '698984179' |
---|
316 | if applicant.__parent__.prefix == 'flc': |
---|
317 | return '757257557' |
---|
318 | if applicant.__parent__.prefix in ('pt', 'ptext'): |
---|
319 | return '2072815846' |
---|
320 | if applicant.__parent__.prefix.startswith('pg'): |
---|
321 | return '2067086388' |
---|
322 | if applicant.__parent__.prefix in ('sandwich'): |
---|
323 | return '2072760654' |
---|
324 | if applicant.__parent__.prefix == 'cdl': |
---|
325 | return '8197875656' |
---|
326 | return '' |
---|
327 | |
---|
328 | @property |
---|
329 | def demo_lineitems(self): |
---|
330 | lineitems = ( |
---|
331 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
332 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
333 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
334 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
335 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
336 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
337 | ) |
---|
338 | return lineitems |
---|
339 | |
---|
340 | @property |
---|
341 | def lineitems(self): |
---|
342 | applicant = self.context.__parent__ |
---|
343 | if applicant.applicant_id.startswith('dp'): |
---|
344 | inst_acct = "0040217361038" |
---|
345 | else: |
---|
346 | inst_acct = "0040217361011" |
---|
347 | provider_amt = 1000.0 |
---|
348 | if applicant.__parent__.prefix == 'pre': |
---|
349 | provider_amt = 2000.0 |
---|
350 | if applicant.__parent__.prefix.startswith('tsc'): |
---|
351 | provider_amt = 2500.0 |
---|
352 | if applicant.order == 'c': |
---|
353 | provider_amt = 2500.0 |
---|
354 | if applicant.__parent__.prefix.startswith('ase'): |
---|
355 | provider_amt = 1000.0 |
---|
356 | if applicant.__parent__.prefix == 'pude': |
---|
357 | provider_amt = 2000.0 |
---|
358 | if applicant.__parent__.prefix == 'cdl': |
---|
359 | provider_amt = 0.0 |
---|
360 | if applicant.__parent__.prefix == 'cbt': |
---|
361 | provider_amt = 300.0 |
---|
362 | if applicant.__parent__.prefix in ('pt', 'ptext', 'sandwich'): |
---|
363 | provider_amt = 2000.0 |
---|
364 | if applicant.__parent__.prefix.startswith('pg'): |
---|
365 | provider_amt = 2000.0 |
---|
366 | if self.context.p_item == 'Balance': |
---|
367 | provider_amt = 0.0 |
---|
368 | inst_amt = self.context.amount_auth - provider_amt |
---|
369 | lineitems = ( |
---|
370 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
371 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
372 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
373 | ) |
---|
374 | if provider_amt: |
---|
375 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
376 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
377 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
378 | self.context.provider_amt = provider_amt |
---|
379 | self.context.net_amt = inst_amt |
---|
380 | return lineitems |
---|
381 | |
---|
382 | def update(self): |
---|
383 | if not module_activated( |
---|
384 | self.context.__parent__.__parent__.year, self.context): |
---|
385 | return |
---|
386 | self.orderId = self.context.p_id |
---|
387 | self.amount = str(self.context.amount_auth) |
---|
388 | error = self.init_update() |
---|
389 | if error: |
---|
390 | self.flash(error, type='danger') |
---|
391 | self.redirect(self.url(self.context, '@@index')) |
---|
392 | return |
---|
393 | self.context.r_company = u'remita' |
---|
394 | return |
---|