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

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

Disable payments to PCN.

  • Property svn:keywords set to Id
File size: 11.0 KB
RevLine 
[14746]1## $Id: browser.py 14970 2018-03-16 11:35:33Z 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'
[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
111    @property
112    def demo_lineitems(self):
[14776]113        ba1 = self.context.amount_auth / 2
114        ba2 = self.context.amount_auth / 2
115        lineitems = (
116                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
117                      "beneficiaryAccount":"6020067886","bankCode":"011",
118                      "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"},
119                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
120                      "beneficiaryAccount":"0360883515","bankCode":"050",
121                      "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"}
122                    )
123        return lineitems
[14751]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
[14795]131    def lineitems(self):
[14960]132        inst_bankcode = "000"
133        inst_acct = "0040217361011"
[14767]134        provider_amt = 0.0
135        if self.context.p_category == 'schoolfee' and \
136            not self.context.p_item == 'Balance':
[14770]137            provider_amt = self.dynamic_provider_amt(self.context.student)
[14767]138        elif self.context.p_category == 'clearance':
[14770]139            provider_amt = self.dynamic_provider_amt(self.context.student)
[14970]140        #elif self.context.p_category == 'pharmd_1':
141        #    inst_acct = "0020197061015"
142        #    provider_amt = 0.0
[14902]143        if self.context.student.is_jupeb \
[14888]144            or self.context.student.current_mode == 'dp_ft':
[14872]145            inst_acct = "0040217361038"
[14960]146        inst_amt = self.context.amount_auth - provider_amt
[14767]147        if provider_amt:
148            lineitems = (
149                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
[14960]150                          "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
[14767]151                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
152                          {"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
153                          "beneficiaryAccount":"1014261520","bankCode":"057",
154                          "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
155                        )
156        else:
157            lineitems = (
158                          {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
[14960]159                          "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
[14767]160                          "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
161                        )
[14960]162        # Split pharmd school fee payments into 3 parts if students decide to pay the
163        # entire school fee at once. If the amount is less than N240000, the student
164        # has obviously paid the first installment of N80000 (pharmd_1)
[14970]165        # (disabled on 16/03/18)
166        #if self.context.p_category == 'schoolfee' \
167        #    and self.context.student.current_mode == 'special_ft' \
168        #    and self.context.amount_auth >= 240000:
169        #    pcn_amt = 80000.0
170        #    inst_amt -= pcn_amt
171        #    lineitems = (
172        #                  {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
173        #                  "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode,
174        #                  "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
175        #                  {"lineItemsId":"itemid2","beneficiaryName":"PCN",
176        #                  "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode,
177        #                  "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"},
178        #                  {"lineItemsId":"itemid3","beneficiaryName":"WAeAC",
179        #                  "beneficiaryAccount":"1014261520","bankCode":"057",
180        #                  "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
181        #                )
[14960]182        self.context.provider_amt = provider_amt
[14767]183        return lineitems
184
[14746]185    def update(self):
186        if not module_activated(self.context.student.current_session):
187            return
[14778]188        self.orderId = self.context.p_id
189        self.amount = str(self.context.amount_auth)
[14746]190        error = self.init_update()
191        if error:
192            self.flash(error, type='danger')
193            self.redirect(self.url(self.context, '@@index'))
194            return
[14767]195        return
196
197class CustomRemitaRequestPaymentStatusPageApplicant(
198    RemitaRequestPaymentStatusPageApplicant):
199    """ Request webservice view for the Remita gateway.
200    """
201
[14792]202    merchantId = MERCHANTID
203    host = HOST
204    https = HTTPS
205    api_key = API_KEY
[14767]206
[14792]207class CustomRemitaVerifyPaymentStatusPageApplicant(
208    RemitaVerifyPaymentStatusPageApplicant):
209    """ Request webservice view for the Remita gateway.
210    """
211
212    merchantId = MERCHANTID
213    host = HOST
214    https = HTTPS
215    api_key = API_KEY
216
[14767]217class CustomRemitaPageApplicant(RemitaPageApplicant):
218    """ View which sends a POST request to the Remita payment gateway.
219    """
220
[14792]221    merchantId = MERCHANTID
222    host = HOST
223    https = HTTPS
224    api_key = API_KEY
225
[14767]226    init_url = '/remita/ecomm/split/init.reg'
227
[14776]228    @property
[14795]229    def serviceTypeId(self):
[14799]230        applicant = self.context.__parent__
[14800]231        if applicant.__parent__.prefix.startswith('dp'):
[14813]232            return '2066963437'
[14832]233        if applicant.__parent__.prefix in ('spft', ):
[14813]234            return '2067086388'
[14800]235        if applicant.__parent__.prefix == 'pre':
[14813]236            return '1946882248'
[14800]237        if applicant.__parent__.prefix in ('pude','putme','cbt',
[14825]238                                           'ab','ak','akj','ase'):
[14813]239            return '2066965951'
[14799]240        return ''
[14795]241
242    @property
[14800]243    def demo_lineitems(self):
244        lineitems = (
[14776]245                      {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller",
246                      "beneficiaryAccount":"6020067886","bankCode":"011",
247                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"},
248                      {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm",
249                      "beneficiaryAccount":"0360883515","bankCode":"050",
250                      "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"}
251                    )
252        return lineitems
[14770]253
[14767]254    @property
[14799]255    def lineitems(self):
[14826]256        provider_amt = 1000.0
[14888]257        if self.context.__parent__.applicant_id.startswith('dp'):
258            inst_acct = "0040217361038"
259        else:
260            inst_acct = "0040217361011"
[14813]261        #if self.context.__parent__.applicant_id.startswith('cbt'):
262        #    provider_amt = 200.0
[14770]263        inst_amt = self.context.amount_auth - provider_amt
[14767]264        lineitems = (
[14770]265                      {"lineItemsId":"itemid1","beneficiaryName":"Uniben",
[14888]266                      "beneficiaryAccount":inst_acct,"bankCode":"000",
[14770]267                      "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"},
268                      {"lineItemsId":"itemid2","beneficiaryName":"WAeAC",
269                      "beneficiaryAccount":"1014261520","bankCode":"057",
270                      "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"}
[14767]271                    )
[14960]272        self.context.provider_amt = provider_amt
[14767]273        return lineitems
274
275    def update(self):
276        if not module_activated(self.context.__parent__.__parent__.year):
277            return
[14778]278        self.orderId = self.context.p_id
279        self.amount = str(self.context.amount_auth)
[14767]280        error = self.init_update()
281        if error:
282            self.flash(error, type='danger')
283            self.redirect(self.url(self.context, '@@index'))
284            return
[14746]285        return
Note: See TracBrowser for help on using the repository browser.