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

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

Switch to production system.

  • Property svn:keywords set to Id
File size: 7.7 KB
RevLine 
[15601]1## $Id: browser.py 15824 2019-11-19 10:36:13Z 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,
[15773]24    EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated)
[15733]25from kofacustom.nigeria.etranzact.payoutletbrowser import (
[15773]26    EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant,
27    EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant,
28    payoutlet_module_activated)
29from kofacustom.nigeria.etranzact.payoutletwebservice  import NigeriaPaymentDataWebservice
[15601]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, TERMINAL_ID)
35
[15824]36HOST = 'www.etranzact.net'
37HTTPS = True
[15601]38#SECRET_KEY =
[15824]39TERMINAL_ID = '7007134590'
[15773]40GATEWAY_AMT = 500.0
[15601]41LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png'
42
43class CustomEtranzactPageApplicant(EtranzactPageApplicant):
44
45    host = HOST
46    https = HTTPS
47    secret_key = SECRET_KEY
48    terminal_id = TERMINAL_ID
49    logo_url = LOGO_URL
[15773]50    gateway_amt = GATEWAY_AMT
[15601]51
[15773]52    def update(self):
53        # Already now it becomes an Etranzact payment. We set the net amount
54        # and add the gateway amount.
55        if not webconnect_module_activated(
56            self.context.__parent__.__parent__.year, self.context):
57            return _("Etranzact payments deactivated.")
58        if not self.context.r_company:
59            self.context.net_amt = self.context.amount_auth
60            self.context.amount_auth += self.gateway_amt
61            self.context.gateway_amt = self.gateway_amt
62            self.context.r_company = u'etranzact'
63        self.amount = "%.1f" % self.context.amount_auth
64        error = self.init_update()
65        if error:
66            self.flash(error, type='danger')
67            self.redirect(self.url(self.context, '@@index'))
68            return
69        return
70
[15601]71class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant):
72
73    secret_key = SECRET_KEY
74    terminal_id = TERMINAL_ID
75
76class CustomEtranzactRequestPaymentStatusPageApplicant(
77    EtranzactRequestPaymentStatusPageApplicant):
78
79    host = HOST
80    https = HTTPS
81    secret_key = SECRET_KEY
82    terminal_id = TERMINAL_ID
83    logo_url = LOGO_URL
84
85class CustomEtranzactPageStudent(EtranzactPageStudent):
86
87    host = HOST
88    https = HTTPS
89    secret_key = SECRET_KEY
90    terminal_id = TERMINAL_ID
91    logo_url = LOGO_URL
[15773]92    gateway_amt = GATEWAY_AMT
[15601]93
[15773]94    def update(self):
95        # Already now it becomes an Etranzact payment. We set the net amount
96        # and add the gateway amount.
97        if not webconnect_module_activated(
98            self.context.student.current_session, self.context):
99            return _("Etranzact payments deactivated.")
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
[15601]113class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent):
114
115    secret_key = SECRET_KEY
116    terminal_id = TERMINAL_ID
117
118class CustomEtranzactRequestPaymentStatusPageStudent(
119    EtranzactRequestPaymentStatusPageStudent):
120
121    host = HOST
122    https = HTTPS
123    secret_key = SECRET_KEY
124    terminal_id = TERMINAL_ID
125    logo_url = LOGO_URL
126
[15773]127# Payoutlet customizations
128
129class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent):
130    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
131    """
132    gateway_amt = GATEWAY_AMT
133
134    def update(self):
135        if not payoutlet_module_activated(
136            self.context.student.current_session, self.context):
137            return
138        super(EtranzactEnterPinPageStudent, self).update()
139        # Already now it becomes an Etranzact payment. We set the net amount
140        # and add the gateway amount.
141        provider_amt = 0.0
142        if self.context.p_category == 'registration':
143            provider_amt = 5000.0
144        if not self.context.r_company:
145            self.context.net_amt = self.context.amount_auth
146            self.context.amount_auth += self.gateway_amt
147            self.context.amount_auth += provider_amt
148            self.context.gateway_amt = self.gateway_amt
149            self.context.provider_amt = provider_amt
150            self.context.r_company = u'etranzact'
151        return
152
153class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
154    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
155    """
156    gateway_amt = GATEWAY_AMT
157
158    def update(self):
159        if not payoutlet_module_activated(
160            self.context.__parent__.__parent__.year, self.context):
161            return
162        super(EtranzactEnterPinPageStudent, self).update()
163        # Already now it becomes an Etranzact payment. We set the net amount
164        # and add the gateway amount.
165        provider_amt = 0.0
166        if not self.context.r_company:
167            self.context.net_amt = self.context.amount_auth
168            self.context.amount_auth += self.gateway_amt
169            self.context.amount_auth += provider_amt
170            self.context.gateway_amt = self.gateway_amt
171            self.context.provider_amt = provider_amt
172            self.context.r_company = u'etranzact'
173        return
174
[15733]175class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
176    """ Query history of Etranzact payments
177    """
178    terminal_id = TERMINAL_ID
179    host = HOST
180    https = HTTPS
[15601]181
[15733]182class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant):
183    """ Query history of Etranzact payments
184    """
185    terminal_id = TERMINAL_ID
186    host = HOST
[15773]187    https = HTTPS
188
189class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
190    """A simple webservice to publish payment and payer details on request from
191    accepted IP addresses without authentication.
192    """
193    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
194    ACCEPTED_IP = None
195
196    CATEGORY_MAPPING = {
[15781]197        'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',),
198        'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',),
199        'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',),
200        'IUO_TRANSCRIPT_FEE': ('transcript',),
201        'IUO_REGISTRATION_FEE': ('registration',),
202        'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',),
203        'IUO_BOOK_DEPOSIT_FEE': ('book',),
204        'IUO_SUNDRY_FEES': ('late_registration',
205            'science','clinical','develop','municipal',
206            'alumni','conv','matric','waecneco','jambver','pharmlab','lo_ident',
207            'change_course','make_up','iuits','fine','combi'),
[15773]208         }
Note: See TracBrowser for help on using the repository browser.