source: main/kofacustom.skeleton/trunk/src/kofacustom/skeleton/etranzact/browser.py @ 15895

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

Adjust skeleton. Remove XMLRPC test user.

File size: 5.6 KB
Line 
1## $Id: browser.py 15601 2019-09-20 15:42:16Z 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        # Already now it becomes an Etranzact payment. We set the net amount
55        # and add the gateway amount.
56        if not webconnect_module_activated(
57            self.context.__parent__.__parent__.year, self.context):
58            return _("Etranzact payments deactivated.")
59        if not self.context.r_company:
60            self.context.net_amt = self.context.amount_auth
61            self.context.amount_auth += self.gateway_amt
62            self.context.gateway_amt = self.gateway_amt
63            self.context.r_company = u'etranzact'
64        self.amount = "%.1f" % self.context.amount_auth
65        error = self.init_update()
66        if error:
67            self.flash(error, type='danger')
68            self.redirect(self.url(self.context, '@@index'))
69            return
70        return
71
72class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant):
73
74    secret_key = SECRET_KEY
75    terminal_id = TERMINAL_ID
76
77class CustomEtranzactRequestPaymentStatusPageApplicant(
78    EtranzactRequestPaymentStatusPageApplicant):
79
80    host = HOST
81    https = HTTPS
82    secret_key = SECRET_KEY
83    terminal_id = TERMINAL_ID
84    logo_url = LOGO_URL
85
86class CustomEtranzactPageStudent(EtranzactPageStudent):
87
88    host = HOST
89    https = HTTPS
90    secret_key = SECRET_KEY
91    terminal_id = TERMINAL_ID
92    logo_url = LOGO_URL
93    gateway_amt = GATEWAY_AMT
94
95    def update(self):
96        # Already now it becomes an Etranzact payment. We set the net amount
97        # and add the gateway amount.
98        if not webconnect_module_activated(
99            self.context.student.current_session, self.context):
100            return _("Etranzact payments deactivated.")
101        if not self.context.r_company:
102            self.context.net_amt = self.context.amount_auth
103            self.context.amount_auth += self.gateway_amt
104            self.context.gateway_amt = self.gateway_amt
105            self.context.r_company = u'etranzact'
106        self.amount = "%.1f" % self.context.amount_auth
107        error = self.init_update()
108        if error:
109            self.flash(error, type='danger')
110            self.redirect(self.url(self.context, '@@index'))
111            return
112        return
113
114class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent):
115
116    secret_key = SECRET_KEY
117    terminal_id = TERMINAL_ID
118
119class CustomEtranzactRequestPaymentStatusPageStudent(
120    EtranzactRequestPaymentStatusPageStudent):
121
122    host = HOST
123    https = HTTPS
124    secret_key = SECRET_KEY
125    terminal_id = TERMINAL_ID
126    logo_url = LOGO_URL
127
128# Payoutlet customizations
129
130class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent):
131    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent`
132    """
133    gateway_amt = GATEWAY_AMT
134
135class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant):
136    """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant`
137    """
138    gateway_amt = GATEWAY_AMT
139
140class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent):
141    """ Query history of Etranzact payments
142    """
143    terminal_id = TERMINAL_ID
144    host = HOST
145    https = HTTPS
146
147class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant):
148    """ Query history of Etranzact payments
149    """
150    terminal_id = TERMINAL_ID
151    host = HOST
152    https = HTTPS
153
154class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice):
155    """A simple webservice to publish payment and payer details on request from
156    accepted IP addresses without authentication.
157    """
158    #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184')
159    ACCEPTED_IP = None
160
161    CATEGORY_MAPPING = {
162        'SCHOOLFEE': ('schoolfee',),
163         }
164
Note: See TracBrowser for help on using the repository browser.