1 | ## $Id: browser.py 15999 2020-02-11 09:51:47Z 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 | |
---|
19 | from kofacustom.nigeria.etranzact.applicantsbrowser import ( |
---|
20 | EtranzactPageApplicant, EtranzactReceiveResponseApplicant, |
---|
21 | EtranzactRequestPaymentStatusPageApplicant) |
---|
22 | from kofacustom.nigeria.etranzact.studentsbrowser import ( |
---|
23 | EtranzactPageStudent, EtranzactReceiveResponseStudent, |
---|
24 | EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated) |
---|
25 | from kofacustom.nigeria.etranzact.payoutletbrowser import ( |
---|
26 | EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, |
---|
27 | EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, |
---|
28 | payoutlet_module_activated) |
---|
29 | from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice |
---|
30 | |
---|
31 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
32 | |
---|
33 | from kofacustom.nigeria.etranzact.tests import ( |
---|
34 | HOST, HTTPS, SECRET_KEY, TERMINAL_ID) |
---|
35 | |
---|
36 | HOST = 'www.etranzact.net' |
---|
37 | HTTPS = True |
---|
38 | #SECRET_KEY = |
---|
39 | TERMINAL_ID = '7007134590' |
---|
40 | GATEWAY_AMT = 500.0 |
---|
41 | LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' |
---|
42 | |
---|
43 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
44 | |
---|
45 | host = HOST |
---|
46 | https = HTTPS |
---|
47 | secret_key = SECRET_KEY |
---|
48 | terminal_id = TERMINAL_ID |
---|
49 | logo_url = LOGO_URL |
---|
50 | gateway_amt = GATEWAY_AMT |
---|
51 | |
---|
52 | def update(self): |
---|
53 | if not webconnect_module_activated( |
---|
54 | self.context.__parent__.__parent__.year, self.context): |
---|
55 | self.flash(_('Forbidden'), type='danger') |
---|
56 | self.redirect(self.url(self.context, '@@index')) |
---|
57 | return |
---|
58 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
59 | # and add the gateway amount. |
---|
60 | if not self.context.r_company: |
---|
61 | self.context.net_amt = self.context.amount_auth |
---|
62 | self.context.amount_auth += self.gateway_amt |
---|
63 | self.context.gateway_amt = self.gateway_amt |
---|
64 | self.context.r_company = u'etranzact' |
---|
65 | self.amount = "%.1f" % self.context.amount_auth |
---|
66 | error = self.init_update() |
---|
67 | if error: |
---|
68 | self.flash(error, type='danger') |
---|
69 | self.redirect(self.url(self.context, '@@index')) |
---|
70 | return |
---|
71 | return |
---|
72 | |
---|
73 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
74 | |
---|
75 | secret_key = SECRET_KEY |
---|
76 | terminal_id = TERMINAL_ID |
---|
77 | |
---|
78 | class 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 | |
---|
87 | class 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 | |
---|
117 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
118 | |
---|
119 | secret_key = SECRET_KEY |
---|
120 | terminal_id = TERMINAL_ID |
---|
121 | |
---|
122 | class 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 | |
---|
133 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
134 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
135 | """ |
---|
136 | gateway_amt = GATEWAY_AMT |
---|
137 | |
---|
138 | def update(self): |
---|
139 | if not payoutlet_module_activated( |
---|
140 | self.context.student.current_session, self.context): |
---|
141 | self.flash(_('Forbidden'), type='danger') |
---|
142 | self.redirect(self.url(self.context, '@@index')) |
---|
143 | return |
---|
144 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
145 | # and add the gateway amount. |
---|
146 | provider_amt = 0.0 |
---|
147 | if self.context.p_category == 'registration': |
---|
148 | provider_amt = 5000.0 |
---|
149 | if not self.context.r_company: |
---|
150 | self.context.net_amt = self.context.amount_auth |
---|
151 | self.context.amount_auth += self.gateway_amt |
---|
152 | self.context.amount_auth += provider_amt |
---|
153 | self.context.gateway_amt = self.gateway_amt |
---|
154 | self.context.provider_amt = provider_amt |
---|
155 | self.context.r_company = u'etranzact' |
---|
156 | return |
---|
157 | |
---|
158 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
159 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
160 | """ |
---|
161 | gateway_amt = GATEWAY_AMT |
---|
162 | |
---|
163 | def update(self): |
---|
164 | if not payoutlet_module_activated( |
---|
165 | self.context.__parent__.__parent__.year, self.context): |
---|
166 | self.flash(_('Forbidden'), type='danger') |
---|
167 | self.redirect(self.url(self.context, '@@index')) |
---|
168 | return |
---|
169 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
170 | # and add the gateway amount. |
---|
171 | provider_amt = 0.0 |
---|
172 | if not self.context.r_company: |
---|
173 | self.context.net_amt = self.context.amount_auth |
---|
174 | self.context.amount_auth += self.gateway_amt |
---|
175 | self.context.amount_auth += provider_amt |
---|
176 | self.context.gateway_amt = self.gateway_amt |
---|
177 | self.context.provider_amt = provider_amt |
---|
178 | self.context.r_company = u'etranzact' |
---|
179 | return |
---|
180 | |
---|
181 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
182 | """ Query history of Etranzact payments |
---|
183 | """ |
---|
184 | terminal_id = TERMINAL_ID |
---|
185 | host = HOST |
---|
186 | https = HTTPS |
---|
187 | |
---|
188 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
189 | """ Query history of Etranzact payments |
---|
190 | """ |
---|
191 | terminal_id = '7009158847' |
---|
192 | host = HOST |
---|
193 | https = HTTPS |
---|
194 | |
---|
195 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
196 | """A simple webservice to publish payment and payer details on request from |
---|
197 | accepted IP addresses without authentication. |
---|
198 | """ |
---|
199 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
200 | ACCEPTED_IP = None |
---|
201 | |
---|
202 | CATEGORY_MAPPING = { |
---|
203 | 'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',), |
---|
204 | 'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',), |
---|
205 | 'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',), |
---|
206 | 'IUO_TRANSCRIPT_FEE': ('transcript',), |
---|
207 | 'IUO_REGISTRATION_FEE': ('registration',), |
---|
208 | 'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',), |
---|
209 | 'IUO_BOOK_DEPOSIT_FEE': ('book',), |
---|
210 | 'IUO_SUNDRY_FEES': ('late_registration', |
---|
211 | 'science','clinical','develop','municipal', |
---|
212 | 'alumni','conv','matric','waecneco','jambver','pharmlab','lo_ident', |
---|
213 | 'change_course','resit1','resit2','resit3','resit4','resit5', |
---|
214 | 'resit6','resit7','resit8','resit9','iuits','fine','combi'), |
---|
215 | } |
---|