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

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

Add ´is_student´ property attribute to student objects.

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