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

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

Reset service type id. No idea why it was removed on 07/02/22

  • Property svn:keywords set to Id
File size: 13.7 KB
RevLine 
[14746]1## $Id: browser.py 16878 2022-03-11 15:51:39Z 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
[16090]30MERCHANTID = '2067163382'
31HOST = 'login.remita.net'
32HTTPS = True
33API_KEY = '309418'
34SERVICETYPEID = '4430731'
[14792]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
[16782]46    def render(self):
47        if self.context.p_category == 'plag_test'\
48            and self.context.p_state  == 'paid':
49            self.redirect(self.url(self.context, 'plagtestinfo'))
50        else:
51            self.redirect(self.url(self.context, '@@index'))
52        return
53
[14792]54class CustomRemitaVerifyPaymentStatusPageStudent(
55    RemitaVerifyPaymentStatusPageStudent):
56    """ Request webservice view for the Remita gateway.
57    """
58
59    merchantId = MERCHANTID
60    host = HOST
61    https = HTTPS
62    api_key = API_KEY
63
[14746]64class CustomRemitaPageStudent(RemitaPageStudent):
65    """ View which sends a POST request to the Remita payment gateway.
66    """
67
[14792]68    merchantId = MERCHANTID
69    host = HOST
70    https = HTTPS
71    api_key = API_KEY
72
[14746]73    init_url = '/remita/ecomm/split/init.reg'
74
[14776]75    @property
[14795]76    def serviceTypeId(self):
77        student = self.context.student
78        if self.context.p_category == 'schoolfee':
79            if student.current_mode.startswith('dp_'):
80                return '2067090482'
81            if student.current_mode == 'pg_ft':
82                return '2067090691'
[14852]83            if student.current_mode.endswith('pg_pt'):
[14795]84                return '2067091011'
85            if student.current_mode == 'ug_sw':
86                return '2066967204'
[14809]87            if student.current_mode.endswith('ug_ft'):
[14795]88                return '2067091395'
89            if student.current_mode == 'ug_pt':
90                return '2067091679'
[14960]91            if student.current_mode == 'special_ft':
92                return '2750318564' # Module 2
[14902]93            if student.is_jupeb:
[14795]94                return '1946888188'
[14799]95        if self.context.p_category == 'bed_allocation':
96            if student.is_postgrad:
97                return '2067086599'
98            return '2067089893'
99        if self.context.p_category == 'hostel_maintenance':
100            if student.is_postgrad:
101                return '2067089226'
102            return '2066966390'
103        if self.context.p_category == 'clearance':
104            if student.current_mode.startswith('dp_'):
105                return '2067080314'
[14902]106            if student.is_jupeb:
[14799]107                return '1947201668'
108            if student.is_postgrad:
109                return '2067086157'
110            return '2067089446'
111        if self.context.p_category == 'jupeb':
112            return '1947198586'
[16783]113        if self.context.p_category == 'plag_test':
[16785]114            return '2051987298'
[14970]115        #if self.context.p_category == 'pharmd_1':
116        #    return '2750314820' # Clerkship
[14960]117        if self.context.p_category == 'pharmd_2':
118            return '2750174184' # Module 1
[16388]119        if self.context.p_category == 'medical_quest':
[16878]120            return '512570052'
[16877]121        if self.context.p_category == 'flc_modules':
122            return '757257557'
[14795]123        return ''
124
[14767]125    def dynamic_provider_amt(self, student):
126        if student.entry_session >= 2016:
127            return 2500.0
128        return 1500.0
129
130    @property
[16090]131    def lineitems(self):
[14960]132        inst_bankcode = "000"
133        inst_acct = "0040217361011"
[14767]134        provider_amt = 0.0
[15929]135        student_union = 0.0
[16337]136        jupeb_amt = 0.0
137        reduced_inst_amt = 0.0
138        lab_amt = 0.0
[14767]139        if self.context.p_category == 'schoolfee' and \
140            not self.context.p_item == 'Balance':
[14770]141            provider_amt = self.dynamic_provider_amt(self.context.student)
[15929]142            if self.context.student.current_mode == 'ug_ft':
143                student_union = 1000.0
[14767]144        elif self.context.p_category == 'clearance':
[14770]145            provider_amt = self.dynamic_provider_amt(self.context.student)
[16337]146
[15938]147        inst_amt = self.context.amount_auth - provider_amt - student_union
[16337]148
[15929]149        lineitems = (
150                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
151                      "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
152                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
153                    )
[14767]154        if provider_amt:
[15929]155            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
[14767]156                          "beneficiaryAccount":"1014261520","bankCode":"057",
[15929]157                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
158        if student_union:
159            lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union",
160                          "beneficiaryAccount":"0025636203","bankCode":"039",
161                          "beneficiaryAmount":student_union,"deductFeeFrom":"0"},)
162
[16398]163        ## Disabled on 24/02/21
164        ## We overwrite linetems in case of JUPEB students
165        #if self.context.student.is_jupeb:
166        #    if self.context.p_category == 'clearance':
167        #        provider_amt = self.dynamic_provider_amt(self.context.student)
168        #        reduced_inst_amt = 0.7 * inst_amt
169        #        jupeb_amt = 0.3 * inst_amt
170        #    elif self.context.p_category == 'schoolfee' and \
171        #        not self.context.p_item == 'Balance':
172        #        provider_amt = self.dynamic_provider_amt(self.context.student)
173        #        if self.context.student.depcode in ('AGR_JUP','EDU_JUP','ENG_JUP',
174        #                                       'LSC_JUP','MED_JUP','PSC_JUP'):
175        #            lab_amt = 10000
176        #        reduced_inst_amt = 0.7 * (inst_amt - lab_amt)
177        #        jupeb_amt = 0.3 * (inst_amt - lab_amt) + lab_amt
178        #    lineitems = (
179        #                  {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
180        #                  "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
181        #                  "beneficiaryAmount":reduced_inst_amt,"deductFeeFrom":"1"},
182        #                )
183        #    lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"JUPEB",
184        #                  "beneficiaryAccount":"1100020192","bankCode":"039",
185        #                  "beneficiaryAmount":jupeb_amt,"deductFeeFrom":"0"},)
186        #    if provider_amt:
187        #        lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
188        #                      "beneficiaryAccount":"1014261520","bankCode":"057",
189        #                      "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
190        #    if student_union:
191        #        lineitems += ({"lineItemsId":"itemid4","beneficiaryName":"Student Union",
192        #                      "beneficiaryAccount":"0025636203","bankCode":"039",
193        #                      "beneficiaryAmount":student_union,"deductFeeFrom":"0"},)
[16337]194
195
[14960]196        # Split pharmd school fee payments into 3 parts if students decide to pay the
197        # entire school fee at once. If the amount is less than N240000, the student
198        # has obviously paid the first installment of N80000 (pharmd_1)
[14970]199        # (disabled on 16/03/18)
200        #if self.context.p_category == 'schoolfee' \
201        #    and self.context.student.current_mode == 'special_ft' \
202        #    and self.context.amount_auth >= 240000:
203        #    pcn_amt = 80000.0
204        #    inst_amt -= pcn_amt
205        #    lineitems = (
206        #                  {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
207        #                  "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
208        #                  "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
209        #                  {"lineItemsId":"itemid2","beneficiaryName":"PCN",
210        #                  "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode,
211        #                  "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"},
212        #                  {"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
213        #                  "beneficiaryAccount":"1014261520","bankCode":"057",
214        #                  "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
215        #                )
[14960]216        self.context.provider_amt = provider_amt
[15817]217        self.context.net_amt = inst_amt
[14767]218        return lineitems
219
[14746]220    def update(self):
[15828]221        if not module_activated(
222            self.context.student.current_session, self.context):
[14746]223            return
[14778]224        self.orderId = self.context.p_id
225        self.amount = str(self.context.amount_auth)
[14746]226        error = self.init_update()
227        if error:
228            self.flash(error, type='danger')
229            self.redirect(self.url(self.context, '@@index'))
230            return
[15817]231        self.context.r_company = u'remita'
[14767]232        return
233
234class CustomRemitaRequestPaymentStatusPageApplicant(
235    RemitaRequestPaymentStatusPageApplicant):
236    """ Request webservice view for the Remita gateway.
237    """
238
[14792]239    merchantId = MERCHANTID
240    host = HOST
241    https = HTTPS
242    api_key = API_KEY
[14767]243
[14792]244class CustomRemitaVerifyPaymentStatusPageApplicant(
245    RemitaVerifyPaymentStatusPageApplicant):
246    """ Request webservice view for the Remita gateway.
247    """
248
249    merchantId = MERCHANTID
250    host = HOST
251    https = HTTPS
252    api_key = API_KEY
253
[14767]254class CustomRemitaPageApplicant(RemitaPageApplicant):
255    """ View which sends a POST request to the Remita payment gateway.
256    """
257
[14792]258    merchantId = MERCHANTID
259    host = HOST
260    https = HTTPS
261    api_key = API_KEY
262
[14767]263    init_url = '/remita/ecomm/split/init.reg'
264
[14776]265    @property
[14795]266    def serviceTypeId(self):
[14799]267        applicant = self.context.__parent__
[14800]268        if applicant.__parent__.prefix.startswith('dp'):
[14813]269            return '2066963437'
[14832]270        if applicant.__parent__.prefix in ('spft', ):
[14813]271            return '2067086388'
[14800]272        if applicant.__parent__.prefix == 'pre':
[14813]273            return '1946882248'
[14800]274        if applicant.__parent__.prefix in ('pude','putme','cbt',
[16230]275                                           'ab','ak','akj','ase'):
[14813]276            return '2066965951'
[16230]277        if applicant.__parent__.prefix in ('tscs', 'tscf'):
278            return '698984179'
[16826]279        if applicant.__parent__.prefix == 'flc':
280            return '757257557'
[14799]281        return ''
[14795]282
283    @property
[16090]284    def demo_lineitems(self):
[14800]285        lineitems = (
[14776]286                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
287                      "beneficiaryAccount":"6020067886","bankCode":"011",
288                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
289                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
290                      "beneficiaryAccount":"0360883515","bankCode":"050",
291                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
292                    )
293        return lineitems
[14770]294
[14767]295    @property
[16090]296    def lineitems(self):
[15491]297        provider_amt = 1000.0
[16205]298        if self.context.__parent__.applicant_id.startswith('pre'):
299            provider_amt = 2000.0
300        if self.context.__parent__.applicant_id.startswith('tsc'):
301            provider_amt = 1200.0
[16606]302            if self.context.__parent__.order == 'c':
[16597]303                provider_amt = 1000.0
[16205]304        if self.context.__parent__.applicant_id.startswith('ase'):
305            provider_amt = 500.0
[16310]306        if self.context.__parent__.applicant_id.startswith('pude'):
307            provider_amt = 500.0
[14888]308        if self.context.__parent__.applicant_id.startswith('dp'):
309            inst_acct = "0040217361038"
310        else:
311            inst_acct = "0040217361011"
[15499]312        if self.context.__parent__.applicant_id.startswith('cbt'):
[16201]313            provider_amt = 300.0
[16205]314        if self.context.p_item == 'Balance':
315            provider_amt = 0.0
[14770]316        inst_amt = self.context.amount_auth - provider_amt
[14767]317        lineitems = (
[14770]318                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
[14888]319                      "beneficiaryAccount":inst_acct,"bankCode":"000",
[14770]320                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
[14767]321                    )
[16205]322        if provider_amt:
323            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
324                          "beneficiaryAccount":"1014261520","bankCode":"057",
325                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
326
[14960]327        self.context.provider_amt = provider_amt
[15817]328        self.context.net_amt = inst_amt
[14767]329        return lineitems
330
331    def update(self):
[15828]332        if not module_activated(
333            self.context.__parent__.__parent__.year, self.context):
[14767]334            return
[14778]335        self.orderId = self.context.p_id
336        self.amount = str(self.context.amount_auth)
[14767]337        error = self.init_update()
338        if error:
339            self.flash(error, type='danger')
340            self.redirect(self.url(self.context, '@@index'))
341            return
[15817]342        self.context.r_company = u'remita'
[14746]343        return
Note: See TracBrowser for help on using the repository browser.