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

Last change on this file since 17225 was 17147, checked in by Henrik Bettermann, 2 years ago

Set provider amount for cdl schoolfee and application payments.

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