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

Last change on this file since 16261 was 16261, checked in by Henrik Bettermann, 4 years ago

Fic Etranzact CATEGORY_MAPPING.

  • Property svn:keywords set to Id
File size: 11.3 KB
Line 
1## $Id: browser.py 16261 2020-09-30 17:09:01Z 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        provider_amt = 0.0
162        if self.context.p_category in (
163            'registration', 'required_combi', 'pg_other'):
164            provider_amt = 5000.0
165        if not self.context.r_company:
166            self.context.net_amt = self.context.amount_auth
167            self.context.amount_auth += self.gateway_amt
168            self.context.amount_auth += provider_amt
169            self.context.gateway_amt = self.gateway_amt
170            self.context.provider_amt = provider_amt
171            self.context.r_company = u'etranzact'
172        self.amount = "%.1f" % self.context.amount_auth
173        error = self.init_update()
174        if error:
175            self.flash(error, type='danger')
176            self.redirect(self.url(self.context, '@@index'))
177            return
178        return
179
180class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent):
181
182    @property
183    def terminal_id(self):
184        return determine_stud_params(self.context)[0]
185
186    @property
187    def secret_key(self):
188        return determine_stud_params(self.context)[1]
189
190class CustomEtranzactRequestPaymentStatusPageStudent(
191    EtranzactRequestPaymentStatusPageStudent):
192
193    host = HOST
194    https = HTTPS
195    logo_url = LOGO_URL
196
197    @property
198    def terminal_id(self):
199        return determine_stud_params(self.context)[0]
200
201    @property
202    def secret_key(self):
203        return determine_stud_params(self.context)[1]
204
205
206
207
208
209# Payoutlet customizations
210
211class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent):
212    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
213    """
214    gateway_amt = GATEWAY_AMT
215
216    def update(self):
217        if not payoutlet_module_activated(
218            self.context.student.current_session, self.context):
219            self.flash(_('Forbidden'), type='danger')
220            self.redirect(self.url(self.context, '@@index'))
221            return
222        # Already now it becomes an Etranzact payment. We set the net amount
223        # and add the gateway amount.
224        provider_amt = 0.0
225        if self.context.p_category in (
226            'registration', 'required_combi', 'pg_other'):
227            provider_amt = 5000.0
228        if not self.context.r_company:
229            self.context.net_amt = self.context.amount_auth
230            self.context.amount_auth += self.gateway_amt
231            self.context.amount_auth += provider_amt
232            self.context.gateway_amt = self.gateway_amt
233            self.context.provider_amt = provider_amt
234            self.context.r_company = u'etranzact'
235        return
236
237class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
238    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
239    """
240    gateway_amt = GATEWAY_AMT
241
242    def update(self):
243        if not payoutlet_module_activated(
244            self.context.__parent__.__parent__.year, self.context):
245            self.flash(_('Forbidden'), type='danger')
246            self.redirect(self.url(self.context, '@@index'))
247            return
248        # Already now it becomes an Etranzact payment. We set the net amount
249        # and add the gateway amount.
250        provider_amt = 0.0
251        if not self.context.r_company:
252            self.context.net_amt = self.context.amount_auth
253            self.context.amount_auth += self.gateway_amt
254            self.context.amount_auth += provider_amt
255            self.context.gateway_amt = self.gateway_amt
256            self.context.provider_amt = provider_amt
257            self.context.r_company = u'etranzact'
258        return
259
260class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
261    """ Query history of Etranzact payments
262    """
263    terminal_id = '7007134590'
264    host = HOST
265    https = HTTPS
266
267class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant):
268    """ Query history of Etranzact payments
269    """
270    terminal_id = '7009158847'
271    host = HOST
272    https = HTTPS
273
274class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
275    """A simple webservice to publish payment and payer details on request from
276    accepted IP addresses without authentication.
277    """
278    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
279    ACCEPTED_IP = None
280
281    CATEGORY_MAPPING = {
282        'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',),
283        'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',),
284        'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',),
285
286        'IUO_SUNDRY_FEES': ('combi',),
287
288        'IUO_MATRICULATION_FEE': ('matric',),
289        'IUO_LATE_REGISTRATION_FEE': ('late_registration',),
290        'IUO_WAEC/NECO_VERIFICATION_FEE': ('waecneco',),
291        'IUO_JAMB_VERIFICATION': ('jambver',),
292        'IUO_CONVOCATION_FEE': ('conv',),
293        'IUO_ALUMNI_FEE': ('alumni',),
294        'IUO_SCIENCE_BENCE_FEE': ('science',),
295        'IUO_LETTER_OF_IDENTIFICATION_FEE': ('lo_ident',),
296        'IUO_CHANGE_OF_COURSE_FEE': ('change_course',),
297        'IUO_IUITS_FEE': ('iuits',),
298        'IUO_FINES_FEE': ('fine',),
299        'IUO_PHARMACY_LAB_SUPPORT_FEE': ('pharmlab',),
300        'IUO_MAKEUP_FEE': ('resit1', 'resit2', 'resit3', 'resit4',
301                           'resit5', 'resit6', 'resit7', 'resit8',
302                           'resit9',),
303        'IUO_CLINICAL_FEE_MEDICAL_STUDENTS': ('clinical',),
304        'IUO_TRANSCRIPT_FEE_INTERNATIONAL': ('transcript_overseas',),
305        'IUO_TRANCRIPT_FEE_LOCAL': ('transcript_local', 'transcript'),
306        'IUO_ACCEPTANCE_FEE': ('clearance',),
307        'IUO_CLEARANCE_FEE': ('grad_clearance',),
308        'IUO_ID_CARD_FEE': ('id_card',),
309        'IUO_REGISTRATION_FEE': ('registration',),
310        'IUO_DEVELOPMENT_FEE': ('develop',),
311        'IUO_MUNICIPAL_FEE': ('municipal_fresh','municipal_returning'),
312        'IUO_BOOK_DEPOSIT': ('book',),
313        'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',),
314         }
Note: See TracBrowser for help on using the repository browser.