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

Last change on this file since 16161 was 16142, checked in by Henrik Bettermann, 5 years ago

Implement transcript application.

  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1## $Id: browser.py 16142 2020-07-03 07:11:31Z 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.etranzact.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        provider_amt = 0.0
219        if self.context.p_category == 'registration':
220            provider_amt = 5000.0
221        if not self.context.r_company:
222            self.context.net_amt = self.context.amount_auth
223            self.context.amount_auth += self.gateway_amt
224            self.context.amount_auth += provider_amt
225            self.context.gateway_amt = self.gateway_amt
226            self.context.provider_amt = provider_amt
227            self.context.r_company = u'etranzact'
228        return
229
230class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
231    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
232    """
233    gateway_amt = GATEWAY_AMT
234
235    def update(self):
236        if not payoutlet_module_activated(
237            self.context.__parent__.__parent__.year, self.context):
238            self.flash(_('Forbidden'), type='danger')
239            self.redirect(self.url(self.context, '@@index'))
240            return
241        # Already now it becomes an Etranzact payment. We set the net amount
242        # and add the gateway amount.
243        provider_amt = 0.0
244        if not self.context.r_company:
245            self.context.net_amt = self.context.amount_auth
246            self.context.amount_auth += self.gateway_amt
247            self.context.amount_auth += provider_amt
248            self.context.gateway_amt = self.gateway_amt
249            self.context.provider_amt = provider_amt
250            self.context.r_company = u'etranzact'
251        return
252
253class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
254    """ Query history of Etranzact payments
255    """
256    terminal_id = '7007134590'
257    host = HOST
258    https = HTTPS
259
260class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant):
261    """ Query history of Etranzact payments
262    """
263    terminal_id = '7009158847'
264    host = HOST
265    https = HTTPS
266
267class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
268    """A simple webservice to publish payment and payer details on request from
269    accepted IP addresses without authentication.
270    """
271    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
272    ACCEPTED_IP = None
273
274    CATEGORY_MAPPING = {
275        'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',),
276        'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',),
277        'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',),
278
279        'IUO_SUNDRY_FEES': ('combi',),
280
281        'IUO_MATRICULATION_FEE': ('matric',),
282        'IUO_LATE_REGISTRATION_FEE': ('late_registration',),
283        'IUO_WAEC/NECO_VERIFICATION_FEE': ('waecneco',),
284        'IUO_JAMB_VERIFICATION': ('jambver',),
285        'IUO_CONVOCATION_FEE': ('conv',),
286        'IUO_ALUMNI_FEE': ('alumni',),
287        'IUO_SCIENCE_BENCE_FEE': ('science',),
288        'IUO_LETTER_OF_IDENTIFICATION_FEE': ('lo_ident',),
289        'IUO_CHANGE_OF_COURSE_FEE': ('change_course',),
290        'IUO_IUITS_FEE': ('iuits',),
291        'IUO_FINES_FEE': ('fine',),
292        'IUO_PHARMACY_LAB_SUPPORT_FEE': ('pharmlab',),
293        'IUO_MAKEUP_FEE': ('resit1', 'resit2', 'resit3', 'resit4',
294                           'resit5', 'resit6', 'resit7', 'resit8',
295                           'resit9',),
296        'IUO_CLINICAL_FEE_MEDICAL_STUDENTS': ('clinical',),
297        'IUO_TRANSCRIPT_FEE_INTERNATIONAL': ('transcript_overseas',),
298        'IUO_TRANCRIPT_FEE_LOCAL': ('transcript_local', 'transcript'),
299        'IUO_CLEARANCE_FEE': ('clearance',),
300        'IUO_ID_CARD_FEE': ('id_card',),
301        'IUO_REGISTRATION_FEE': ('registration',),
302        'IUO_DEVELOPMENT_FEE': ('develop',),
303        'IUO_MUNICIPAL_FEE': ('municipal_fresh','municipal_returning'),
304        'IUO_BOOK_DEPOSIT': ('book',),
305        'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',),
306         }
Note: See TracBrowser for help on using the repository browser.