1 | ## $Id: browser.py 16104 2020-05-27 18:34:05Z 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.etranzact.applicantsbrowser import ( |
---|
20 | EtranzactPageApplicant, EtranzactReceiveResponseApplicant, |
---|
21 | EtranzactRequestPaymentStatusPageApplicant) |
---|
22 | from kofacustom.nigeria.etranzact.studentsbrowser import ( |
---|
23 | EtranzactPageStudent, EtranzactReceiveResponseStudent, |
---|
24 | EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated) |
---|
25 | from kofacustom.nigeria.etranzact.payoutletbrowser import ( |
---|
26 | EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, |
---|
27 | EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, |
---|
28 | payoutlet_module_activated) |
---|
29 | from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice |
---|
30 | |
---|
31 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
32 | |
---|
33 | from kofacustom.nigeria.etranzact.tests import ( |
---|
34 | HOST, HTTPS) |
---|
35 | |
---|
36 | HOST = 'www.etranzact.net' |
---|
37 | HTTPS = True |
---|
38 | GATEWAY_AMT = 500.0 |
---|
39 | LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' |
---|
40 | |
---|
41 | WEBCONNECT_STUD_PARAMS = { |
---|
42 | 'schoolfee': ('7007139588','QIgl9a35R30A1RGK'), |
---|
43 | 'schoolfee40': ('7007139589','3coU0eolOEbEUeO3'), |
---|
44 | 'secondinstal': ('7007139590','zGpEjy6CdPxCHqen'), |
---|
45 | 'transcript_local': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
46 | 'transcript_overseas': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
47 | 'registration': ('7007139599','KGHjZ2hRbaDJGBX8'), |
---|
48 | 'book': ('7007139600','rrKE2Ua7eu8TF0Is'), |
---|
49 | 'parentsconsult': ('7007139598','HsqjOlAB5xfQNDyo'), |
---|
50 | 'sundry': ('7007139591','0XkOFShPnWn8tY5O'), |
---|
51 | } |
---|
52 | |
---|
53 | def determine_appl_params(payment): |
---|
54 | terminal_id = '' |
---|
55 | secret_key = '' |
---|
56 | if payment.__parent__.__parent__.prefix.startswith('pg'): |
---|
57 | terminal_id = '7007139606' |
---|
58 | secret_key = 'E64s3IN9cXRJeltY' |
---|
59 | else: |
---|
60 | terminal_id = '7007139604' |
---|
61 | secret_key = 'vlEEJxvJBjC468g1' |
---|
62 | return terminal_id, secret_key |
---|
63 | |
---|
64 | def determine_stud_params(payment): |
---|
65 | terminal_id = '' |
---|
66 | secret_key = '' |
---|
67 | for key in WEBCONNECT_STUD_PARAMS.keys(): |
---|
68 | if payment.p_category == key: |
---|
69 | terminal_id = WEBCONNECT_STUD_PARAMS[key][0] |
---|
70 | secret_key = WEBCONNECT_STUD_PARAMS[key][1] |
---|
71 | if not terminal_id: |
---|
72 | terminal_id = WEBCONNECT_STUD_PARAMS['sundry'][0] |
---|
73 | secret_key = WEBCONNECT_STUD_PARAMS['sundry'][1] |
---|
74 | return terminal_id, secret_key |
---|
75 | |
---|
76 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
77 | |
---|
78 | host = HOST |
---|
79 | https = HTTPS |
---|
80 | logo_url = LOGO_URL |
---|
81 | gateway_amt = GATEWAY_AMT |
---|
82 | |
---|
83 | @property |
---|
84 | def terminal_id(self): |
---|
85 | return determine_appl_params(self.context)[0] |
---|
86 | |
---|
87 | @property |
---|
88 | def secret_key(self): |
---|
89 | return determine_appl_params(self.context)[1] |
---|
90 | |
---|
91 | def update(self): |
---|
92 | if not webconnect_module_activated( |
---|
93 | self.context.__parent__.__parent__.year, self.context): |
---|
94 | self.flash(_('Forbidden'), type='danger') |
---|
95 | self.redirect(self.url(self.context, '@@index')) |
---|
96 | return |
---|
97 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
98 | # and add the gateway amount. |
---|
99 | if not self.context.r_company: |
---|
100 | self.context.net_amt = self.context.amount_auth |
---|
101 | self.context.amount_auth += self.gateway_amt |
---|
102 | self.context.gateway_amt = self.gateway_amt |
---|
103 | self.context.r_company = u'etranzact' |
---|
104 | self.amount = "%.1f" % self.context.amount_auth |
---|
105 | error = self.init_update() |
---|
106 | if error: |
---|
107 | self.flash(error, type='danger') |
---|
108 | self.redirect(self.url(self.context, '@@index')) |
---|
109 | return |
---|
110 | return |
---|
111 | |
---|
112 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
113 | |
---|
114 | @property |
---|
115 | def terminal_id(self): |
---|
116 | return determine_appl_params(self.context)[0] |
---|
117 | |
---|
118 | @property |
---|
119 | def secret_key(self): |
---|
120 | return determine_appl_params(self.context)[1] |
---|
121 | |
---|
122 | class CustomEtranzactRequestPaymentStatusPageApplicant( |
---|
123 | EtranzactRequestPaymentStatusPageApplicant): |
---|
124 | |
---|
125 | host = HOST |
---|
126 | https = HTTPS |
---|
127 | logo_url = LOGO_URL |
---|
128 | |
---|
129 | @property |
---|
130 | def terminal_id(self): |
---|
131 | return determine_appl_params(self.context)[0] |
---|
132 | |
---|
133 | @property |
---|
134 | def secret_key(self): |
---|
135 | return determine_appl_params(self.context)[1] |
---|
136 | |
---|
137 | class CustomEtranzactPageStudent(EtranzactPageStudent): |
---|
138 | |
---|
139 | host = HOST |
---|
140 | https = HTTPS |
---|
141 | logo_url = LOGO_URL |
---|
142 | gateway_amt = GATEWAY_AMT |
---|
143 | |
---|
144 | @property |
---|
145 | def terminal_id(self): |
---|
146 | return determine_stud_params(self.context)[0] |
---|
147 | |
---|
148 | @property |
---|
149 | def secret_key(self): |
---|
150 | return determine_stud_params(self.context)[1] |
---|
151 | |
---|
152 | def update(self): |
---|
153 | if not webconnect_module_activated( |
---|
154 | self.context.student.current_session, self.context): |
---|
155 | self.flash(_('Forbidden'), type='danger') |
---|
156 | self.redirect(self.url(self.context, '@@index')) |
---|
157 | return |
---|
158 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
159 | # and add the gateway amount. |
---|
160 | if not self.context.r_company: |
---|
161 | self.context.net_amt = self.context.amount_auth |
---|
162 | self.context.amount_auth += self.gateway_amt |
---|
163 | self.context.gateway_amt = self.gateway_amt |
---|
164 | self.context.r_company = u'etranzact' |
---|
165 | self.amount = "%.1f" % self.context.amount_auth |
---|
166 | error = self.init_update() |
---|
167 | if error: |
---|
168 | self.flash(error, type='danger') |
---|
169 | self.redirect(self.url(self.context, '@@index')) |
---|
170 | return |
---|
171 | return |
---|
172 | |
---|
173 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
174 | |
---|
175 | @property |
---|
176 | def terminal_id(self): |
---|
177 | return determine_stud_params(self.context)[0] |
---|
178 | |
---|
179 | @property |
---|
180 | def secret_key(self): |
---|
181 | return determine_stud_params(self.context)[1] |
---|
182 | |
---|
183 | class CustomEtranzactRequestPaymentStatusPageStudent( |
---|
184 | EtranzactRequestPaymentStatusPageStudent): |
---|
185 | |
---|
186 | host = HOST |
---|
187 | https = HTTPS |
---|
188 | logo_url = LOGO_URL |
---|
189 | |
---|
190 | @property |
---|
191 | def terminal_id(self): |
---|
192 | return determine_stud_params(self.context)[0] |
---|
193 | |
---|
194 | @property |
---|
195 | def secret_key(self): |
---|
196 | return determine_stud_params(self.context)[1] |
---|
197 | |
---|
198 | |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | # Payoutlet customizations |
---|
203 | |
---|
204 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
205 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
206 | """ |
---|
207 | gateway_amt = GATEWAY_AMT |
---|
208 | |
---|
209 | def update(self): |
---|
210 | if not payoutlet_module_activated( |
---|
211 | self.context.student.current_session, self.context): |
---|
212 | self.flash(_('Forbidden'), type='danger') |
---|
213 | self.redirect(self.url(self.context, '@@index')) |
---|
214 | return |
---|
215 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
216 | # and add the gateway amount. |
---|
217 | provider_amt = 0.0 |
---|
218 | if self.context.p_category == 'registration': |
---|
219 | provider_amt = 5000.0 |
---|
220 | if not self.context.r_company: |
---|
221 | self.context.net_amt = self.context.amount_auth |
---|
222 | self.context.amount_auth += self.gateway_amt |
---|
223 | self.context.amount_auth += provider_amt |
---|
224 | self.context.gateway_amt = self.gateway_amt |
---|
225 | self.context.provider_amt = provider_amt |
---|
226 | self.context.r_company = u'etranzact' |
---|
227 | return |
---|
228 | |
---|
229 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
230 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
231 | """ |
---|
232 | gateway_amt = GATEWAY_AMT |
---|
233 | |
---|
234 | def update(self): |
---|
235 | if not payoutlet_module_activated( |
---|
236 | self.context.__parent__.__parent__.year, self.context): |
---|
237 | self.flash(_('Forbidden'), type='danger') |
---|
238 | self.redirect(self.url(self.context, '@@index')) |
---|
239 | return |
---|
240 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
241 | # and add the gateway amount. |
---|
242 | provider_amt = 0.0 |
---|
243 | if not self.context.r_company: |
---|
244 | self.context.net_amt = self.context.amount_auth |
---|
245 | self.context.amount_auth += self.gateway_amt |
---|
246 | self.context.amount_auth += provider_amt |
---|
247 | self.context.gateway_amt = self.gateway_amt |
---|
248 | self.context.provider_amt = provider_amt |
---|
249 | self.context.r_company = u'etranzact' |
---|
250 | return |
---|
251 | |
---|
252 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
253 | """ Query history of Etranzact payments |
---|
254 | """ |
---|
255 | terminal_id = '7007134590' |
---|
256 | host = HOST |
---|
257 | https = HTTPS |
---|
258 | |
---|
259 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
260 | """ Query history of Etranzact payments |
---|
261 | """ |
---|
262 | terminal_id = '7009158847' |
---|
263 | host = HOST |
---|
264 | https = HTTPS |
---|
265 | |
---|
266 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
267 | """A simple webservice to publish payment and payer details on request from |
---|
268 | accepted IP addresses without authentication. |
---|
269 | """ |
---|
270 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
271 | ACCEPTED_IP = None |
---|
272 | |
---|
273 | CATEGORY_MAPPING = { |
---|
274 | 'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',), |
---|
275 | 'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',), |
---|
276 | 'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',), |
---|
277 | 'IUO_TRANSCRIPT_FEE': ('transcript_overseas','transcript_local'), |
---|
278 | 'IUO_REGISTRATION_FEE': ('registration',), |
---|
279 | 'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',), |
---|
280 | 'IUO_BOOK_DEPOSIT_FEE': ('book',), |
---|
281 | 'IUO_MATRICULATION_FEE': ('matric',), |
---|
282 | 'IUO_SUNDRY_FEES': ('late_registration', |
---|
283 | 'science','clinical','develop','municipal', |
---|
284 | 'alumni','conv','matric','waecneco','jambver','pharmlab','lo_ident', |
---|
285 | 'change_course','resit1','resit2','resit3','resit4','resit5', |
---|
286 | 'resit6','resit7','resit8','resit9','iuits','fine','combi'), |
---|
287 | } |
---|