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

Last change on this file since 18107 was 18107, checked in by Henrik Bettermann, 14 hours ago

Change bank account for all pg payments.

  • Property svn:keywords set to Id
File size: 17.7 KB
RevLine 
[14746]1## $Id: browser.py 18107 2025-07-07 09:53:18Z 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
[17747]64    def update(self):
65        super(CustomRemitaVerifyPaymentStatusPageStudent, self).update()
66        # Repair: Uniben allows also previous session students to book a bed
67        if self.context.p_category == 'bed_allocation' and self.context.p_state == 'paid' and self.context.ac == None:
68            flashtype, msg, log = self.context.doAfterStudentPayment()
69            if log is not None:
70                self.context.student.writeLogMessage(self, log)
71            self.flash(msg, type=flashtype)
72        return
73
[14746]74class CustomRemitaPageStudent(RemitaPageStudent):
75    """ View which sends a POST request to the Remita payment gateway.
76    """
77
[14792]78    merchantId = MERCHANTID
79    host = HOST
80    https = HTTPS
81    api_key = API_KEY
82
[14746]83    init_url = '/remita/ecomm/split/init.reg'
84
[14776]85    @property
[14795]86    def serviceTypeId(self):
87        student = self.context.student
[17971]88        if self.context.p_category in ('schoolfee', 'schoolfee_1',
89                                       'secondinstall'):
[14795]90            if student.current_mode.startswith('dp_'):
91                return '2067090482'
[17371]92            if student.current_mode in ('pg_ft', 'pgd_ft'):
[14795]93                return '2067090691'
[17374]94            if student.current_mode in ('pg_pt', 'pgd_pt', 'special_pg_pt'):
[14795]95                return '2067091011'
96            if student.current_mode == 'ug_sw':
97                return '2066967204'
[14809]98            if student.current_mode.endswith('ug_ft'):
[14795]99                return '2067091395'
100            if student.current_mode == 'ug_pt':
101                return '2067091679'
[14960]102            if student.current_mode == 'special_ft':
103                return '2750318564' # Module 2
[14902]104            if student.is_jupeb:
[14795]105                return '1946888188'
[17140]106            if student.current_mode == 'cdl':
107                return '9541632464'
[14799]108        if self.context.p_category == 'bed_allocation':
109            if student.is_postgrad:
110                return '2067086599'
111            return '2067089893'
112        if self.context.p_category == 'hostel_maintenance':
113            if student.is_postgrad:
114                return '2067089226'
115            return '2066966390'
116        if self.context.p_category == 'clearance':
117            if student.current_mode.startswith('dp_'):
118                return '2067080314'
[14902]119            if student.is_jupeb:
[14799]120                return '1947201668'
121            if student.is_postgrad:
122                return '2067086157'
[17035]123            if student.current_mode == 'ug_pt':
124                return '2072765946'
[17140]125            if student.current_mode == 'cdl':
126                return '8242101527'
[14799]127            return '2067089446'
128        if self.context.p_category == 'jupeb':
129            return '1947198586'
[16783]130        if self.context.p_category == 'plag_test':
[16785]131            return '2051987298'
[14970]132        #if self.context.p_category == 'pharmd_1':
133        #    return '2750314820' # Clerkship
[14960]134        if self.context.p_category == 'pharmd_2':
135            return '2750174184' # Module 1
[16388]136        if self.context.p_category == 'medical_quest':
[16878]137            return '512570052'
[16877]138        if self.context.p_category == 'flc_modules':
139            return '757257557'
[14795]140        return ''
141
[14767]142    def dynamic_provider_amt(self, student):
[17953]143        if student.entry_session >= 2024:
144            return 5000.0
145        return 2000.0
[14767]146
147    @property
[16090]148    def lineitems(self):
[14960]149        inst_bankcode = "000"
150        inst_acct = "0040217361011"
[14767]151        provider_amt = 0.0
[15929]152        student_union = 0.0
[16337]153        jupeb_amt = 0.0
154        reduced_inst_amt = 0.0
155        lab_amt = 0.0
[18107]156        if self.context.student.is_postgrad:
157            inst_acct = "3000151027"
[18032]158        if self.context.p_category in ('schoolfee', 'schoolfee_1'):
[14770]159            provider_amt = self.dynamic_provider_amt(self.context.student)
[15929]160            if self.context.student.current_mode == 'ug_ft':
[17708]161                student_union = 2500.0
[14767]162        elif self.context.p_category == 'clearance':
[17953]163            provider_amt = 5000.0
164        elif self.context.p_category == 'bed_allocation':
165            provider_amt = 1000.0
[18032]166        if self.context.p_item == 'Balance':
167            provider_amt = 0.0
[18039]168            student_union = 0.0
[16337]169
[15938]170        inst_amt = self.context.amount_auth - provider_amt - student_union
[16337]171
[15929]172        lineitems = (
173                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
174                      "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
175                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
176                    )
[14767]177        if provider_amt:
[15929]178            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
[17955]179                          "beneficiaryAccount":"1014261520","bankCode":"057",
[15929]180                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
181        if student_union:
182            lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union",
183                          "beneficiaryAccount":"0025636203","bankCode":"039",
184                          "beneficiaryAmount":student_union,"deductFeeFrom":"0"},)
185
[18107]186        ## Disabled on 07/07/25
[17235]187        # We overwrite linetems in case of postgrad student school fee payments
[18107]188        #if self.context.student.is_postgrad and self.context.p_category == 'schoolfee':
189        #    microfinance_amt = 0.1 * inst_amt
190        #    inst_amt -= microfinance_amt
191        #    lineitems = (
192        #                  {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
193        #                  "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
194        #                  "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
195        #                )
196        #    lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"SPGS Scheme",
197        #                  "beneficiaryAccount":"0025636203","bankCode":"039",
198        #                  "beneficiaryAmount":microfinance_amt,"deductFeeFrom":"0"},
199        #                 {"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
200        #                  "beneficiaryAccount":"1014261520","bankCode":"057",
201        #                  "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
[17235]202
[16398]203        ## Disabled on 24/02/21
[17590]204        ## Reenabled on 19/09/23 (ticket #1327)
[16398]205        ## We overwrite linetems in case of JUPEB students
[17977]206        if self.context.student.is_jupeb and self.context.p_category in (
207            'clearance', 'schoolfee', 'schoolfee_1'):
[17590]208            if self.context.p_category == 'clearance':
209                provider_amt = self.dynamic_provider_amt(self.context.student)
[17974]210                reduced_inst_amt = 0.4 * inst_amt
211                jupeb_amt = 0.6 * inst_amt
[18032]212            elif self.context.p_category in ('schoolfee', 'schoolfee_1'):
[17590]213                provider_amt = self.dynamic_provider_amt(self.context.student)
214                #if self.context.student.depcode in ('AGR_JUP','EDU_JUP','ENG_JUP',
215                #                               'LSC_JUP','MED_JUP','PSC_JUP'):
216                #    lab_amt = 10000
[17974]217                reduced_inst_amt = 0.4 * (inst_amt - lab_amt)
218                jupeb_amt = 0.6 * (inst_amt - lab_amt) + lab_amt
[18032]219            if self.context.p_item == 'Balance':
220                provider_amt = 0.0
[18039]221                lab_amt = 0.0
[17590]222            lineitems = (
223                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
224                          "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
225                          "beneficiaryAmount":reduced_inst_amt,"deductFeeFrom":"1"},
226                        )
227            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"JUPEB",
[17592]228                          "beneficiaryAccount":"0025636203","bankCode":"039",
[17590]229                          "beneficiaryAmount":jupeb_amt,"deductFeeFrom":"0"},)
230            if provider_amt:
231                lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
[17955]232                              "beneficiaryAccount":"1014261520","bankCode":"057",
[17590]233                              "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
234            if student_union:
235                lineitems += ({"lineItemsId":"itemid4","beneficiaryName":"Student Union",
236                              "beneficiaryAccount":"0025636203","bankCode":"039",
237                              "beneficiaryAmount":student_union,"deductFeeFrom":"0"},)
[16337]238
239
[14960]240        # Split pharmd school fee payments into 3 parts if students decide to pay the
241        # entire school fee at once. If the amount is less than N240000, the student
242        # has obviously paid the first installment of N80000 (pharmd_1)
[14970]243        # (disabled on 16/03/18)
244        #if self.context.p_category == 'schoolfee' \
245        #    and self.context.student.current_mode == 'special_ft' \
246        #    and self.context.amount_auth >= 240000:
247        #    pcn_amt = 80000.0
248        #    inst_amt -= pcn_amt
249        #    lineitems = (
250        #                  {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
251        #                  "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
252        #                  "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
253        #                  {"lineItemsId":"itemid2","beneficiaryName":"PCN",
254        #                  "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode,
255        #                  "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"},
256        #                  {"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
[17955]257        #                  "beneficiaryAccount":"1014261520","bankCode":"057",
[14970]258        #                  "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
259        #                )
[14960]260        self.context.provider_amt = provider_amt
[15817]261        self.context.net_amt = inst_amt
[14767]262        return lineitems
263
[14746]264    def update(self):
[15828]265        if not module_activated(
266            self.context.student.current_session, self.context):
[14746]267            return
[14778]268        self.orderId = self.context.p_id
269        self.amount = str(self.context.amount_auth)
[14746]270        error = self.init_update()
271        if error:
272            self.flash(error, type='danger')
273            self.redirect(self.url(self.context, '@@index'))
274            return
[15817]275        self.context.r_company = u'remita'
[14767]276        return
277
[17753]278class CustomRemitaRequestPaymentStatusPageApplicant(
279    RemitaRequestPaymentStatusPageApplicant):
280    """ Request webservice view for the Remita gateway.
281    """
282
283    merchantId = MERCHANTID
284    host = HOST
285    https = HTTPS
286    api_key = API_KEY
287
288
[14792]289class CustomRemitaVerifyPaymentStatusPageApplicant(
290    RemitaVerifyPaymentStatusPageApplicant):
291    """ Request webservice view for the Remita gateway.
292    """
293
294    merchantId = MERCHANTID
295    host = HOST
296    https = HTTPS
297    api_key = API_KEY
298
[14767]299class CustomRemitaPageApplicant(RemitaPageApplicant):
300    """ View which sends a POST request to the Remita payment gateway.
301    """
302
[14792]303    merchantId = MERCHANTID
304    host = HOST
305    https = HTTPS
306    api_key = API_KEY
307
[14767]308    init_url = '/remita/ecomm/split/init.reg'
309
[14776]310    @property
[14795]311    def serviceTypeId(self):
[14799]312        applicant = self.context.__parent__
[14800]313        if applicant.__parent__.prefix.startswith('dp'):
[14813]314            return '2066963437'
[14832]315        if applicant.__parent__.prefix in ('spft', ):
[14813]316            return '2067086388'
[14800]317        if applicant.__parent__.prefix == 'pre':
[14813]318            return '1946882248'
[14800]319        if applicant.__parent__.prefix in ('pude','putme','cbt',
[17969]320                                           'ab','ak','akj','ase',
321                                           'afrimal'):
[14813]322            return '2066965951'
[16230]323        if applicant.__parent__.prefix in ('tscs', 'tscf'):
324            return '698984179'
[16826]325        if applicant.__parent__.prefix == 'flc':
[17034]326            return '757257557'     
327        if applicant.__parent__.prefix in ('pt', 'ptext'):
328            return '2072815846'
329        if applicant.__parent__.prefix.startswith('pg'):
330            return '2067086388'   
331        if applicant.__parent__.prefix in ('sandwich'):
[17140]332            return '2072760654'
333        if applicant.__parent__.prefix == 'cdl':
334            return '8197875656'
[14799]335        return ''
[14795]336
337    @property
[16090]338    def demo_lineitems(self):
[14800]339        lineitems = (
[14776]340                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
341                      "beneficiaryAccount":"6020067886","bankCode":"011",
342                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
343                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
344                      "beneficiaryAccount":"0360883515","bankCode":"050",
345                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
346                    )
347        return lineitems
[14770]348
[14767]349    @property
[16090]350    def lineitems(self):
[17037]351        applicant = self.context.__parent__
352        if applicant.applicant_id.startswith('dp'):
[17034]353            inst_acct = "0040217361038"
[17970]354        elif applicant.applicant_id.startswith('afrimal'):
355            inst_acct = "1100088712"
[17034]356        else:
357            inst_acct = "0040217361011"
[15491]358        provider_amt = 1000.0
[17037]359        if applicant.__parent__.prefix == 'pre':
[16205]360            provider_amt = 2000.0
[17037]361        if applicant.__parent__.prefix.startswith('tsc'):
[17953]362            provider_amt = 2500.0
[17037]363            if applicant.order == 'c':
[17953]364                provider_amt = 2500.0
[17037]365        if applicant.__parent__.prefix.startswith('ase'):
[17973]366            provider_amt = 500.0
[17037]367        if applicant.__parent__.prefix == 'pude':
[17973]368            provider_amt = 500.0
[17147]369        if applicant.__parent__.prefix == 'cdl':
[17454]370            provider_amt = 0.0
[17037]371        if applicant.__parent__.prefix == 'cbt':
[16201]372            provider_amt = 300.0
[17037]373        if applicant.__parent__.prefix in ('pt', 'ptext', 'sandwich'):
374            provider_amt = 2000.0
375        if applicant.__parent__.prefix.startswith('pg'):
376            provider_amt = 2000.0
[18107]377            inst_acct = "3000151027"
[16205]378        if self.context.p_item == 'Balance':
379            provider_amt = 0.0
[14770]380        inst_amt = self.context.amount_auth - provider_amt
[14767]381        lineitems = (
[14770]382                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
[14888]383                      "beneficiaryAccount":inst_acct,"bankCode":"000",
[14770]384                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
[14767]385                    )
[16205]386        if provider_amt:
387            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
[17955]388                          "beneficiaryAccount":"1014261520","bankCode":"057",
[16205]389                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
[18011]390
391        ## We overwrite linetems in case of JUPEB applicants
392        if applicant.__parent__.prefix == 'pre':
393            reduced_inst_amt = 0.4 * inst_amt
394            jupeb_amt = 0.6 * inst_amt
395            lineitems = (
396                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
397                          "beneficiaryAccount":inst_acct,"bankCode":"000",
398                          "beneficiaryAmount":reduced_inst_amt,"deductFeeFrom":"1"},
399                        )
400            lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"JUPEB",
401                          "beneficiaryAccount":"0025636203","bankCode":"039",
402                          "beneficiaryAmount":jupeb_amt,"deductFeeFrom":"0"},)
403            lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
404                          "beneficiaryAccount":"1014261520","bankCode":"057",
405                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},)
406
[14960]407        self.context.provider_amt = provider_amt
[15817]408        self.context.net_amt = inst_amt
[14767]409        return lineitems
410
411    def update(self):
[15828]412        if not module_activated(
413            self.context.__parent__.__parent__.year, self.context):
[14767]414            return
[14778]415        self.orderId = self.context.p_id
416        self.amount = str(self.context.amount_auth)
[14767]417        error = self.init_update()
418        if error:
419            self.flash(error, type='danger')
420            self.redirect(self.url(self.context, '@@index'))
421            return
[15817]422        self.context.r_company = u'remita'
[14746]423        return
Note: See TracBrowser for help on using the repository browser.