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

Last change on this file since 16337 was 16337, checked in by Henrik Bettermann, 4 years ago

Configure jupeb payments.

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