source: main/kofacustom.unidel/trunk/src/kofacustom/unidel/etranzact/browser.py @ 17304

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

Add Id keyword

  • Property svn:keywords set to Id
File size: 5.7 KB
Line 
1## $Id: browser.py 16717 2021-11-24 06:44:33Z 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,
25    webconnect_module_activated)
26from kofacustom.nigeria.etranzact.payoutletbrowser import (
27    EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant,
28    EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant,
29    payoutlet_module_activated)
30from kofacustom.nigeria.etranzact.payoutletwebservice  import NigeriaPaymentDataWebservice
31
32# Temporarily we can use the test portal like in kofacustom.nigeria
33
34from kofacustom.nigeria.etranzact.tests import (
35    HOST, HTTPS, SECRET_KEY, TERMINAL_ID, GATEWAY_AMT)
36
37#HOST =
38#HTTPS =
39#SECRET_KEY =
40#TERMINAL_ID =
41#GATEWAY_AMT =
42LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png'
43
44class CustomEtranzactPageApplicant(EtranzactPageApplicant):
45
46    host = HOST
47    https = HTTPS
48    secret_key = SECRET_KEY
49    terminal_id = TERMINAL_ID
50    logo_url = LOGO_URL
51    gateway_amt = GATEWAY_AMT
52
53    def update(self):
54        if not webconnect_module_activated(
55            self.context.__parent__.__parent__.year, self.context):
56            self.flash(_('Forbidden'), type='danger')
57            self.redirect(self.url(self.context, '@@index'))
58            return
59        # Already now it becomes an Etranzact payment. We set the net amount
60        # and add the gateway amount.
61        if not self.context.r_company:
62            self.context.net_amt = self.context.amount_auth
63            self.context.amount_auth += self.gateway_amt
64            self.context.gateway_amt = self.gateway_amt
65            self.context.r_company = u'etranzact'
66        self.amount = "%.1f" % self.context.amount_auth
67        error = self.init_update()
68        if error:
69            self.flash(error, type='danger')
70            self.redirect(self.url(self.context, '@@index'))
71        return
72
73class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant):
74
75    secret_key = SECRET_KEY
76    terminal_id = TERMINAL_ID
77
78class CustomEtranzactRequestPaymentStatusPageApplicant(
79    EtranzactRequestPaymentStatusPageApplicant):
80
81    host = HOST
82    https = HTTPS
83    secret_key = SECRET_KEY
84    terminal_id = TERMINAL_ID
85    logo_url = LOGO_URL
86
87class CustomEtranzactPageStudent(EtranzactPageStudent):
88
89    host = HOST
90    https = HTTPS
91    secret_key = SECRET_KEY
92    terminal_id = TERMINAL_ID
93    logo_url = LOGO_URL
94    gateway_amt = GATEWAY_AMT
95
96    def update(self):
97        if not webconnect_module_activated(
98            self.context.student.current_session, self.context):
99            self.flash(_('Forbidden'), type='danger')
100            self.redirect(self.url(self.context, '@@index'))
101            return
102        # Already now it becomes an Etranzact payment. We set the net amount
103        # and add the gateway amount.
104        if not self.context.r_company:
105            self.context.net_amt = self.context.amount_auth
106            self.context.amount_auth += self.gateway_amt
107            self.context.gateway_amt = self.gateway_amt
108            self.context.r_company = u'etranzact'
109        self.amount = "%.1f" % self.context.amount_auth
110        error = self.init_update()
111        if error:
112            self.flash(error, type='danger')
113            self.redirect(self.url(self.context, '@@index'))
114            return
115        return
116
117class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent):
118
119    secret_key = SECRET_KEY
120    terminal_id = TERMINAL_ID
121
122class CustomEtranzactRequestPaymentStatusPageStudent(
123    EtranzactRequestPaymentStatusPageStudent):
124
125    host = HOST
126    https = HTTPS
127    secret_key = SECRET_KEY
128    terminal_id = TERMINAL_ID
129    logo_url = LOGO_URL
130
131# Payoutlet customizations
132
133class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent):
134    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
135    """
136    gateway_amt = GATEWAY_AMT
137
138class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
139    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
140    """
141    gateway_amt = GATEWAY_AMT
142
143class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
144    """ Query history of Etranzact payments
145    """
146    terminal_id = TERMINAL_ID
147    host = HOST
148    https = HTTPS
149
150class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant):
151    """ Query history of Etranzact payments
152    """
153    terminal_id = TERMINAL_ID
154    host = HOST
155    https = HTTPS
156
157class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
158    """A simple webservice to publish payment and payer details on request from
159    accepted IP addresses without authentication.
160    """
161    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
162    ACCEPTED_IP = None
163
164    CATEGORY_MAPPING = {
165        'SCHOOLFEE': ('schoolfee',),
166         }
167
Note: See TracBrowser for help on using the repository browser.