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

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

Change payment types.

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