source: main/waeup.uniben/trunk/src/waeup/uniben/remita/browser.py @ 14876

Last change on this file since 14876 was 14876, checked in by Henrik Bettermann, 7 years ago

Emergency fix.

  • Property svn:keywords set to Id
File size: 9.0 KB
Line 
1## $Id: browser.py 14876 2017-10-24 09:27:55Z 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.remita.studentsbrowser import (
20    module_activated,
21    RemitaRequestPaymentStatusPageStudent,
22    RemitaVerifyPaymentStatusPageStudent,
23    RemitaPageStudent)
24from kofacustom.nigeria.remita.applicantsbrowser import (
25    RemitaRequestPaymentStatusPageApplicant,
26    RemitaVerifyPaymentStatusPageApplicant,
27    RemitaPageApplicant)
28
29# Temporarily we can use the test portal like in kofacustom.nigeria
30MERCHANTID = '2067163382'
31HOST = 'login.remita.net'
32HTTPS = True
33API_KEY = '309418'
34SERVICETYPEID = '4430731'
35
36class CustomRemitaRequestPaymentStatusPageStudent(
37    RemitaRequestPaymentStatusPageStudent):
38    """ Request webservice view for the Remita gateway.
39    """
40
41    merchantId = MERCHANTID
42    host = HOST
43    https = HTTPS
44    api_key = API_KEY
45
46class CustomRemitaVerifyPaymentStatusPageStudent(
47    RemitaVerifyPaymentStatusPageStudent):
48    """ Request webservice view for the Remita gateway.
49    """
50
51    merchantId = MERCHANTID
52    host = HOST
53    https = HTTPS
54    api_key = API_KEY
55
56class CustomRemitaPageStudent(RemitaPageStudent):
57    """ View which sends a POST request to the Remita payment gateway.
58    """
59
60    merchantId = MERCHANTID
61    host = HOST
62    https = HTTPS
63    api_key = API_KEY
64
65    init_url = '/remita/ecomm/split/init.reg'
66
67    @property
68    def serviceTypeId(self):
69        student = self.context.student
70        if self.context.p_category == 'schoolfee':
71            if student.current_mode.startswith('dp_'):
72                return '2067090482'
73            if student.current_mode == 'pg_ft':
74                return '2067090691'
75            if student.current_mode.endswith('pg_pt'):
76                return '2067091011'
77            if student.current_mode == 'ug_sw':
78                return '2066967204'
79            if student.current_mode.endswith('ug_ft'):
80                return '2067091395'
81            if student.current_mode == 'ug_pt':
82                return '2067091679'
83            if student.faccode == 'JUPEB':
84                return '1946888188'
85        if self.context.p_category == 'bed_allocation':
86            if student.is_postgrad:
87                return '2067086599'
88            return '2067089893'
89        if self.context.p_category == 'hostel_maintenance':
90            if student.is_postgrad:
91                return '2067089226'
92            return '2066966390'
93        if self.context.p_category == 'clearance':
94            if student.current_mode.startswith('dp_'):
95                return '2067080314'
96            if student.faccode == 'JUPEB':
97                return '1947201668'
98            if student.is_postgrad:
99                return '2067086157'
100            return '2067089446'
101        if self.context.p_category == 'jupeb':
102            return '1947198586'
103        return ''
104
105    @property
106    def demo_lineitems(self):
107        ba1 = self.context.amount_auth / 2
108        ba2 = self.context.amount_auth / 2
109        lineitems = (
110                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
111                      "beneficiaryAccount":"6020067886","bankCode":"011",
112                      "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"},
113                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
114                      "beneficiaryAccount":"0360883515","bankCode":"050",
115                      "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"}
116                    )
117        return lineitems
118
119    def dynamic_provider_amt(self, student):
120        if student.entry_session >= 2016:
121            return 2500.0
122        return 1500.0
123
124    @property
125    def lineitems(self):
126        provider_amt = 0.0
127        if self.context.p_category == 'schoolfee' and \
128            not self.context.p_item == 'Balance':
129            provider_amt = self.dynamic_provider_amt(self.context.student)
130        elif self.context.p_category == 'clearance':
131            provider_amt = self.dynamic_provider_amt(self.context.student)
132        inst_amt = self.context.amount_auth - provider_amt
133        if self.context.student.faccode == 'JUPEB':
134            inst_acct = "0040217361038"
135        else:
136            inst_acct = "0040217361011"
137        if provider_amt:
138            lineitems = (
139                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
140                          "beneficiaryAccount":inst_acct,"bankCode":"000",
141                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
142                          {"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
143                          "beneficiaryAccount":"1014261520","bankCode":"057",
144                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
145                        )
146        else:
147            lineitems = (
148                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
149                          "beneficiaryAccount":inst_acct,"bankCode":"000",
150                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
151                        )
152        return lineitems
153
154    def update(self):
155        if not module_activated(self.context.student.current_session):
156            return
157        self.orderId = self.context.p_id
158        self.amount = str(self.context.amount_auth)
159        error = self.init_update()
160        if error:
161            self.flash(error, type='danger')
162            self.redirect(self.url(self.context, '@@index'))
163            return
164        return
165
166class CustomRemitaRequestPaymentStatusPageApplicant(
167    RemitaRequestPaymentStatusPageApplicant):
168    """ Request webservice view for the Remita gateway.
169    """
170
171    merchantId = MERCHANTID
172    host = HOST
173    https = HTTPS
174    api_key = API_KEY
175
176class CustomRemitaVerifyPaymentStatusPageApplicant(
177    RemitaVerifyPaymentStatusPageApplicant):
178    """ Request webservice view for the Remita gateway.
179    """
180
181    merchantId = MERCHANTID
182    host = HOST
183    https = HTTPS
184    api_key = API_KEY
185
186class CustomRemitaPageApplicant(RemitaPageApplicant):
187    """ View which sends a POST request to the Remita payment gateway.
188    """
189
190    merchantId = MERCHANTID
191    host = HOST
192    https = HTTPS
193    api_key = API_KEY
194
195    init_url = '/remita/ecomm/split/init.reg'
196
197    @property
198    def serviceTypeId(self):
199        applicant = self.context.__parent__
200        if applicant.__parent__.prefix.startswith('dp'):
201            return '2066963437'
202        if applicant.__parent__.prefix in ('spft', ):
203            return '2067086388'
204        if applicant.__parent__.prefix == 'pre':
205            return '1946882248'
206        if applicant.__parent__.prefix in ('pude','putme','cbt',
207                                           'ab','ak','akj','ase'):
208            return '2066965951'
209        return ''
210
211    @property
212    def demo_lineitems(self):
213        lineitems = (
214                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
215                      "beneficiaryAccount":"6020067886","bankCode":"011",
216                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
217                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
218                      "beneficiaryAccount":"0360883515","bankCode":"050",
219                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
220                    )
221        return lineitems
222
223    @property
224    def lineitems(self):
225        provider_amt = 1000.0
226        #if self.context.__parent__.applicant_id.startswith('cbt'):
227        #    provider_amt = 200.0
228        inst_amt = self.context.amount_auth - provider_amt
229        lineitems = (
230                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
231                      "beneficiaryAccount":"0040217361011","bankCode":"000",
232                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
233                      {"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
234                      "beneficiaryAccount":"1014261520","bankCode":"057",
235                      "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
236                    )
237        return lineitems
238
239    def update(self):
240        if not module_activated(self.context.__parent__.__parent__.year):
241            return
242        self.orderId = self.context.p_id
243        self.amount = str(self.context.amount_auth)
244        error = self.init_update()
245        if error:
246            self.flash(error, type='danger')
247            self.redirect(self.url(self.context, '@@index'))
248            return
249        return
Note: See TracBrowser for help on using the repository browser.