source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/etranzact/browser.py @ 17567

Last change on this file since 17567 was 17545, checked in by Henrik Bettermann, 15 months ago

#197

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