1 | ## $Id: browser.py 16785 2022-02-08 18:16:08Z 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 | class CustomRemitaPageStudent(RemitaPageStudent): |
---|
65 | """ View which sends a POST request to the Remita payment gateway. |
---|
66 | """ |
---|
67 | |
---|
68 | merchantId = MERCHANTID |
---|
69 | host = HOST |
---|
70 | https = HTTPS |
---|
71 | api_key = API_KEY |
---|
72 | |
---|
73 | init_url = '/remita/ecomm/split/init.reg' |
---|
74 | |
---|
75 | @property |
---|
76 | def serviceTypeId(self): |
---|
77 | student = self.context.student |
---|
78 | if self.context.p_category == 'schoolfee': |
---|
79 | if student.current_mode.startswith('dp_'): |
---|
80 | return '2067090482' |
---|
81 | if student.current_mode == 'pg_ft': |
---|
82 | return '2067090691' |
---|
83 | if student.current_mode.endswith('pg_pt'): |
---|
84 | return '2067091011' |
---|
85 | if student.current_mode == 'ug_sw': |
---|
86 | return '2066967204' |
---|
87 | if student.current_mode.endswith('ug_ft'): |
---|
88 | return '2067091395' |
---|
89 | if student.current_mode == 'ug_pt': |
---|
90 | return '2067091679' |
---|
91 | if student.current_mode == 'special_ft': |
---|
92 | return '2750318564' # Module 2 |
---|
93 | if student.is_jupeb: |
---|
94 | return '1946888188' |
---|
95 | if self.context.p_category == 'bed_allocation': |
---|
96 | if student.is_postgrad: |
---|
97 | return '2067086599' |
---|
98 | return '2067089893' |
---|
99 | if self.context.p_category == 'hostel_maintenance': |
---|
100 | if student.is_postgrad: |
---|
101 | return '2067089226' |
---|
102 | return '2066966390' |
---|
103 | if self.context.p_category == 'clearance': |
---|
104 | if student.current_mode.startswith('dp_'): |
---|
105 | return '2067080314' |
---|
106 | if student.is_jupeb: |
---|
107 | return '1947201668' |
---|
108 | if student.is_postgrad: |
---|
109 | return '2067086157' |
---|
110 | return '2067089446' |
---|
111 | if self.context.p_category == 'jupeb': |
---|
112 | return '1947198586' |
---|
113 | if self.context.p_category == 'plag_test': |
---|
114 | return '2051987298' |
---|
115 | #if self.context.p_category == 'pharmd_1': |
---|
116 | # return '2750314820' # Clerkship |
---|
117 | if self.context.p_category == 'pharmd_2': |
---|
118 | return '2750174184' # Module 1 |
---|
119 | if self.context.p_category == 'medical_quest': |
---|
120 | return '' |
---|
121 | return '' |
---|
122 | |
---|
123 | def dynamic_provider_amt(self, student): |
---|
124 | if student.entry_session >= 2016: |
---|
125 | return 2500.0 |
---|
126 | return 1500.0 |
---|
127 | |
---|
128 | @property |
---|
129 | def lineitems(self): |
---|
130 | inst_bankcode = "000" |
---|
131 | inst_acct = "0040217361011" |
---|
132 | provider_amt = 0.0 |
---|
133 | student_union = 0.0 |
---|
134 | jupeb_amt = 0.0 |
---|
135 | reduced_inst_amt = 0.0 |
---|
136 | lab_amt = 0.0 |
---|
137 | if self.context.p_category == 'schoolfee' and \ |
---|
138 | not self.context.p_item == 'Balance': |
---|
139 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
140 | if self.context.student.current_mode == 'ug_ft': |
---|
141 | student_union = 1000.0 |
---|
142 | elif self.context.p_category == 'clearance': |
---|
143 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
144 | |
---|
145 | inst_amt = self.context.amount_auth - provider_amt - student_union |
---|
146 | |
---|
147 | lineitems = ( |
---|
148 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
149 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
150 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
151 | ) |
---|
152 | if provider_amt: |
---|
153 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
154 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
155 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
156 | if student_union: |
---|
157 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union", |
---|
158 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
159 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
160 | |
---|
161 | ## Disabled on 24/02/21 |
---|
162 | ## We overwrite linetems in case of JUPEB students |
---|
163 | #if self.context.student.is_jupeb: |
---|
164 | # if self.context.p_category == 'clearance': |
---|
165 | # provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
166 | # reduced_inst_amt = 0.7 * inst_amt |
---|
167 | # jupeb_amt = 0.3 * inst_amt |
---|
168 | # elif self.context.p_category == 'schoolfee' and \ |
---|
169 | # not self.context.p_item == 'Balance': |
---|
170 | # provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
171 | # if self.context.student.depcode in ('AGR_JUP','EDU_JUP','ENG_JUP', |
---|
172 | # 'LSC_JUP','MED_JUP','PSC_JUP'): |
---|
173 | # lab_amt = 10000 |
---|
174 | # reduced_inst_amt = 0.7 * (inst_amt - lab_amt) |
---|
175 | # jupeb_amt = 0.3 * (inst_amt - lab_amt) + lab_amt |
---|
176 | # lineitems = ( |
---|
177 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
178 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
179 | # "beneficiaryAmount":reduced_inst_amt,"deductFeeFrom":"1"}, |
---|
180 | # ) |
---|
181 | # lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"JUPEB", |
---|
182 | # "beneficiaryAccount":"1100020192","bankCode":"039", |
---|
183 | # "beneficiaryAmount":jupeb_amt,"deductFeeFrom":"0"},) |
---|
184 | # if provider_amt: |
---|
185 | # lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
186 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
187 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
188 | # if student_union: |
---|
189 | # lineitems += ({"lineItemsId":"itemid4","beneficiaryName":"Student Union", |
---|
190 | # "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
191 | # "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
192 | |
---|
193 | |
---|
194 | # Split pharmd school fee payments into 3 parts if students decide to pay the |
---|
195 | # entire school fee at once. If the amount is less than N240000, the student |
---|
196 | # has obviously paid the first installment of N80000 (pharmd_1) |
---|
197 | # (disabled on 16/03/18) |
---|
198 | #if self.context.p_category == 'schoolfee' \ |
---|
199 | # and self.context.student.current_mode == 'special_ft' \ |
---|
200 | # and self.context.amount_auth >= 240000: |
---|
201 | # pcn_amt = 80000.0 |
---|
202 | # inst_amt -= pcn_amt |
---|
203 | # lineitems = ( |
---|
204 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
205 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
206 | # "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
207 | # {"lineItemsId":"itemid2","beneficiaryName":"PCN", |
---|
208 | # "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode, |
---|
209 | # "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"}, |
---|
210 | # {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
211 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
212 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
213 | # ) |
---|
214 | self.context.provider_amt = provider_amt |
---|
215 | self.context.net_amt = inst_amt |
---|
216 | return lineitems |
---|
217 | |
---|
218 | def update(self): |
---|
219 | if not module_activated( |
---|
220 | self.context.student.current_session, self.context): |
---|
221 | return |
---|
222 | self.orderId = self.context.p_id |
---|
223 | self.amount = str(self.context.amount_auth) |
---|
224 | error = self.init_update() |
---|
225 | if error: |
---|
226 | self.flash(error, type='danger') |
---|
227 | self.redirect(self.url(self.context, '@@index')) |
---|
228 | return |
---|
229 | self.context.r_company = u'remita' |
---|
230 | return |
---|
231 | |
---|
232 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
233 | RemitaRequestPaymentStatusPageApplicant): |
---|
234 | """ Request webservice view for the Remita gateway. |
---|
235 | """ |
---|
236 | |
---|
237 | merchantId = MERCHANTID |
---|
238 | host = HOST |
---|
239 | https = HTTPS |
---|
240 | api_key = API_KEY |
---|
241 | |
---|
242 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
243 | RemitaVerifyPaymentStatusPageApplicant): |
---|
244 | """ Request webservice view for the Remita gateway. |
---|
245 | """ |
---|
246 | |
---|
247 | merchantId = MERCHANTID |
---|
248 | host = HOST |
---|
249 | https = HTTPS |
---|
250 | api_key = API_KEY |
---|
251 | |
---|
252 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
253 | """ View which sends a POST request to the Remita payment gateway. |
---|
254 | """ |
---|
255 | |
---|
256 | merchantId = MERCHANTID |
---|
257 | host = HOST |
---|
258 | https = HTTPS |
---|
259 | api_key = API_KEY |
---|
260 | |
---|
261 | init_url = '/remita/ecomm/split/init.reg' |
---|
262 | |
---|
263 | @property |
---|
264 | def serviceTypeId(self): |
---|
265 | applicant = self.context.__parent__ |
---|
266 | if applicant.__parent__.prefix.startswith('dp'): |
---|
267 | return '2066963437' |
---|
268 | if applicant.__parent__.prefix in ('spft', ): |
---|
269 | return '2067086388' |
---|
270 | if applicant.__parent__.prefix == 'pre': |
---|
271 | return '1946882248' |
---|
272 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
273 | 'ab','ak','akj','ase'): |
---|
274 | return '2066965951' |
---|
275 | if applicant.__parent__.prefix in ('tscs', 'tscf'): |
---|
276 | return '698984179' |
---|
277 | return '' |
---|
278 | |
---|
279 | @property |
---|
280 | def demo_lineitems(self): |
---|
281 | lineitems = ( |
---|
282 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
283 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
284 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
285 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
286 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
287 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
288 | ) |
---|
289 | return lineitems |
---|
290 | |
---|
291 | @property |
---|
292 | def lineitems(self): |
---|
293 | provider_amt = 1000.0 |
---|
294 | if self.context.__parent__.applicant_id.startswith('pre'): |
---|
295 | provider_amt = 2000.0 |
---|
296 | if self.context.__parent__.applicant_id.startswith('tsc'): |
---|
297 | provider_amt = 1200.0 |
---|
298 | if self.context.__parent__.order == 'c': |
---|
299 | provider_amt = 1000.0 |
---|
300 | if self.context.__parent__.applicant_id.startswith('ase'): |
---|
301 | provider_amt = 500.0 |
---|
302 | if self.context.__parent__.applicant_id.startswith('pude'): |
---|
303 | provider_amt = 500.0 |
---|
304 | if self.context.__parent__.applicant_id.startswith('dp'): |
---|
305 | inst_acct = "0040217361038" |
---|
306 | else: |
---|
307 | inst_acct = "0040217361011" |
---|
308 | if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
309 | provider_amt = 300.0 |
---|
310 | if self.context.p_item == 'Balance': |
---|
311 | provider_amt = 0.0 |
---|
312 | inst_amt = self.context.amount_auth - provider_amt |
---|
313 | lineitems = ( |
---|
314 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
315 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
316 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
317 | ) |
---|
318 | if provider_amt: |
---|
319 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
320 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
321 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
322 | |
---|
323 | self.context.provider_amt = provider_amt |
---|
324 | self.context.net_amt = inst_amt |
---|
325 | return lineitems |
---|
326 | |
---|
327 | def update(self): |
---|
328 | if not module_activated( |
---|
329 | self.context.__parent__.__parent__.year, self.context): |
---|
330 | return |
---|
331 | self.orderId = self.context.p_id |
---|
332 | self.amount = str(self.context.amount_auth) |
---|
333 | error = self.init_update() |
---|
334 | if error: |
---|
335 | self.flash(error, type='danger') |
---|
336 | self.redirect(self.url(self.context, '@@index')) |
---|
337 | return |
---|
338 | self.context.r_company = u'remita' |
---|
339 | return |
---|