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

Last change on this file since 17421 was 16685, checked in by Henrik Bettermann, 3 years ago

Add item.

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