1 | ## $Id: browser.py 16089 2020-05-11 14:21:06Z 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 | |
---|
31 | from kofacustom.nigeria.remita.tests import ( |
---|
32 | MERCHANTID, |
---|
33 | HOST, |
---|
34 | HTTPS, |
---|
35 | API_KEY, |
---|
36 | SERVICETYPEID |
---|
37 | ) |
---|
38 | |
---|
39 | #MERCHANTID = '2067163382' |
---|
40 | #HOST = 'login.remita.net' |
---|
41 | #HTTPS = True |
---|
42 | #API_KEY = '309418' |
---|
43 | #SERVICETYPEID = '4430731' |
---|
44 | |
---|
45 | class CustomRemitaRequestPaymentStatusPageStudent( |
---|
46 | RemitaRequestPaymentStatusPageStudent): |
---|
47 | """ Request webservice view for the Remita gateway. |
---|
48 | """ |
---|
49 | |
---|
50 | merchantId = MERCHANTID |
---|
51 | host = HOST |
---|
52 | https = HTTPS |
---|
53 | api_key = API_KEY |
---|
54 | |
---|
55 | class CustomRemitaVerifyPaymentStatusPageStudent( |
---|
56 | RemitaVerifyPaymentStatusPageStudent): |
---|
57 | """ Request webservice view for the Remita gateway. |
---|
58 | """ |
---|
59 | |
---|
60 | merchantId = MERCHANTID |
---|
61 | host = HOST |
---|
62 | https = HTTPS |
---|
63 | api_key = API_KEY |
---|
64 | |
---|
65 | class CustomRemitaPageStudent(RemitaPageStudent): |
---|
66 | """ View which sends a POST request to the Remita payment gateway. |
---|
67 | """ |
---|
68 | |
---|
69 | merchantId = MERCHANTID |
---|
70 | host = HOST |
---|
71 | https = HTTPS |
---|
72 | api_key = API_KEY |
---|
73 | |
---|
74 | init_url = '/remita/ecomm/split/init.reg' |
---|
75 | |
---|
76 | @property |
---|
77 | def serviceTypeId(self): |
---|
78 | student = self.context.student |
---|
79 | if self.context.p_category == 'schoolfee': |
---|
80 | if student.current_mode.startswith('dp_'): |
---|
81 | return '2067090482' |
---|
82 | if student.current_mode == 'pg_ft': |
---|
83 | return '2067090691' |
---|
84 | if student.current_mode.endswith('pg_pt'): |
---|
85 | return '2067091011' |
---|
86 | if student.current_mode == 'ug_sw': |
---|
87 | return '2066967204' |
---|
88 | if student.current_mode.endswith('ug_ft'): |
---|
89 | return '2067091395' |
---|
90 | if student.current_mode == 'ug_pt': |
---|
91 | return '2067091679' |
---|
92 | if student.current_mode == 'special_ft': |
---|
93 | return '2750318564' # Module 2 |
---|
94 | if student.is_jupeb: |
---|
95 | return '1946888188' |
---|
96 | if self.context.p_category == 'bed_allocation': |
---|
97 | if student.is_postgrad: |
---|
98 | return '2067086599' |
---|
99 | return '2067089893' |
---|
100 | if self.context.p_category == 'hostel_maintenance': |
---|
101 | if student.is_postgrad: |
---|
102 | return '2067089226' |
---|
103 | return '2066966390' |
---|
104 | if self.context.p_category == 'clearance': |
---|
105 | if student.current_mode.startswith('dp_'): |
---|
106 | return '2067080314' |
---|
107 | if student.is_jupeb: |
---|
108 | return '1947201668' |
---|
109 | if student.is_postgrad: |
---|
110 | return '2067086157' |
---|
111 | return '2067089446' |
---|
112 | if self.context.p_category == 'jupeb': |
---|
113 | return '1947198586' |
---|
114 | #if self.context.p_category == 'pharmd_1': |
---|
115 | # return '2750314820' # Clerkship |
---|
116 | if self.context.p_category == 'pharmd_2': |
---|
117 | return '2750174184' # Module 1 |
---|
118 | return '' |
---|
119 | |
---|
120 | @property |
---|
121 | def lineitems(self): |
---|
122 | ba1 = self.context.amount_auth / 2 |
---|
123 | ba2 = self.context.amount_auth / 2 |
---|
124 | lineitems = ( |
---|
125 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
126 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
127 | "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"}, |
---|
128 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
129 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
130 | "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"} |
---|
131 | ) |
---|
132 | return lineitems |
---|
133 | |
---|
134 | def dynamic_provider_amt(self, student): |
---|
135 | if student.entry_session >= 2016: |
---|
136 | return 2500.0 |
---|
137 | return 1500.0 |
---|
138 | |
---|
139 | @property |
---|
140 | def live_lineitems(self): |
---|
141 | inst_bankcode = "000" |
---|
142 | inst_acct = "0040217361011" |
---|
143 | provider_amt = 0.0 |
---|
144 | student_union = 0.0 |
---|
145 | if self.context.p_category == 'schoolfee' and \ |
---|
146 | not self.context.p_item == 'Balance': |
---|
147 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
148 | if self.context.student.current_mode == 'ug_ft': |
---|
149 | student_union = 1000.0 |
---|
150 | elif self.context.p_category == 'clearance': |
---|
151 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
152 | #elif self.context.p_category == 'pharmd_1': |
---|
153 | # inst_acct = "0020197061015" |
---|
154 | # provider_amt = 0.0 |
---|
155 | if self.context.student.is_jupeb \ |
---|
156 | or self.context.student.current_mode == 'dp_ft': |
---|
157 | inst_acct = "0040217361038" |
---|
158 | inst_amt = self.context.amount_auth - provider_amt - student_union |
---|
159 | lineitems = ( |
---|
160 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
161 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
162 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
163 | ) |
---|
164 | if provider_amt: |
---|
165 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
166 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
167 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
168 | if student_union: |
---|
169 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union", |
---|
170 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
171 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
172 | |
---|
173 | # Split pharmd school fee payments into 3 parts if students decide to pay the |
---|
174 | # entire school fee at once. If the amount is less than N240000, the student |
---|
175 | # has obviously paid the first installment of N80000 (pharmd_1) |
---|
176 | # (disabled on 16/03/18) |
---|
177 | #if self.context.p_category == 'schoolfee' \ |
---|
178 | # and self.context.student.current_mode == 'special_ft' \ |
---|
179 | # and self.context.amount_auth >= 240000: |
---|
180 | # pcn_amt = 80000.0 |
---|
181 | # inst_amt -= pcn_amt |
---|
182 | # lineitems = ( |
---|
183 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
184 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
185 | # "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
186 | # {"lineItemsId":"itemid2","beneficiaryName":"PCN", |
---|
187 | # "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode, |
---|
188 | # "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"}, |
---|
189 | # {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
190 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
191 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
192 | # ) |
---|
193 | self.context.provider_amt = provider_amt |
---|
194 | self.context.net_amt = inst_amt |
---|
195 | return lineitems |
---|
196 | |
---|
197 | def update(self): |
---|
198 | if not module_activated( |
---|
199 | self.context.student.current_session, self.context): |
---|
200 | return |
---|
201 | self.orderId = self.context.p_id |
---|
202 | self.amount = str(self.context.amount_auth) |
---|
203 | error = self.init_update() |
---|
204 | if error: |
---|
205 | self.flash(error, type='danger') |
---|
206 | self.redirect(self.url(self.context, '@@index')) |
---|
207 | return |
---|
208 | self.context.r_company = u'remita' |
---|
209 | return |
---|
210 | |
---|
211 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
212 | RemitaRequestPaymentStatusPageApplicant): |
---|
213 | """ Request webservice view for the Remita gateway. |
---|
214 | """ |
---|
215 | |
---|
216 | merchantId = MERCHANTID |
---|
217 | host = HOST |
---|
218 | https = HTTPS |
---|
219 | api_key = API_KEY |
---|
220 | |
---|
221 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
222 | RemitaVerifyPaymentStatusPageApplicant): |
---|
223 | """ Request webservice view for the Remita gateway. |
---|
224 | """ |
---|
225 | |
---|
226 | merchantId = MERCHANTID |
---|
227 | host = HOST |
---|
228 | https = HTTPS |
---|
229 | api_key = API_KEY |
---|
230 | |
---|
231 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
232 | """ View which sends a POST request to the Remita payment gateway. |
---|
233 | """ |
---|
234 | |
---|
235 | merchantId = MERCHANTID |
---|
236 | host = HOST |
---|
237 | https = HTTPS |
---|
238 | api_key = API_KEY |
---|
239 | |
---|
240 | init_url = '/remita/ecomm/split/init.reg' |
---|
241 | |
---|
242 | @property |
---|
243 | def serviceTypeId(self): |
---|
244 | applicant = self.context.__parent__ |
---|
245 | if applicant.__parent__.prefix.startswith('dp'): |
---|
246 | return '2066963437' |
---|
247 | if applicant.__parent__.prefix in ('spft', ): |
---|
248 | return '2067086388' |
---|
249 | if applicant.__parent__.prefix == 'pre': |
---|
250 | return '1946882248' |
---|
251 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
252 | 'ab','ak','akj','ase'): |
---|
253 | return '2066965951' |
---|
254 | return '' |
---|
255 | |
---|
256 | @property |
---|
257 | def lineitems(self): |
---|
258 | lineitems = ( |
---|
259 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
260 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
261 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
262 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
263 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
264 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
265 | ) |
---|
266 | return lineitems |
---|
267 | |
---|
268 | @property |
---|
269 | def demo_lineitems(self): |
---|
270 | provider_amt = 1000.0 |
---|
271 | if self.context.__parent__.applicant_id.startswith('pre'): |
---|
272 | provider_amt = 2000.0 |
---|
273 | if self.context.__parent__.applicant_id.startswith('dp'): |
---|
274 | inst_acct = "0040217361038" |
---|
275 | else: |
---|
276 | inst_acct = "0040217361011" |
---|
277 | if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
278 | provider_amt = 500.0 |
---|
279 | inst_amt = self.context.amount_auth - provider_amt |
---|
280 | lineitems = ( |
---|
281 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
282 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
283 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
284 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
285 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
286 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
287 | ) |
---|
288 | self.context.provider_amt = provider_amt |
---|
289 | self.context.net_amt = inst_amt |
---|
290 | return lineitems |
---|
291 | |
---|
292 | def update(self): |
---|
293 | if not module_activated( |
---|
294 | self.context.__parent__.__parent__.year, self.context): |
---|
295 | return |
---|
296 | self.orderId = self.context.p_id |
---|
297 | self.amount = str(self.context.amount_auth) |
---|
298 | error = self.init_update() |
---|
299 | if error: |
---|
300 | self.flash(error, type='danger') |
---|
301 | self.redirect(self.url(self.context, '@@index')) |
---|
302 | return |
---|
303 | self.context.r_company = u'remita' |
---|
304 | return |
---|