## $Id: browser.py 14813 2017-08-22 14:02:50Z henrik $ ## ## Copyright (C) 2017 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## from kofacustom.nigeria.remita.studentsbrowser import ( module_activated, RemitaRequestPaymentStatusPageStudent, RemitaVerifyPaymentStatusPageStudent, RemitaPageStudent) from kofacustom.nigeria.remita.applicantsbrowser import ( RemitaRequestPaymentStatusPageApplicant, RemitaVerifyPaymentStatusPageApplicant, RemitaPageApplicant) # Temporarily we can use the test portal like in kofacustom.nigeria MERCHANTID = '2067163382' HOST = 'login.remita.net' HTTPS = True API_KEY = '309418' SERVICETYPEID = '4430731' class CustomRemitaRequestPaymentStatusPageStudent( RemitaRequestPaymentStatusPageStudent): """ Request webservice view for the Remita gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY class CustomRemitaVerifyPaymentStatusPageStudent( RemitaVerifyPaymentStatusPageStudent): """ Request webservice view for the Remita gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY class CustomRemitaPageStudent(RemitaPageStudent): """ View which sends a POST request to the Remita payment gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY init_url = '/remita/ecomm/split/init.reg' @property def serviceTypeId(self): student = self.context.student if self.context.p_category == 'schoolfee': if student.current_mode.startswith('dp_'): return '2067090482' if student.current_mode == 'pg_ft': return '2067090691' if student.current_mode == 'pg_pt': return '2067091011' if student.current_mode == 'ug_sw': return '2066967204' if student.current_mode.endswith('ug_ft'): return '2067091395' if student.current_mode == 'ug_pt': return '2067091679' if student.faccode == 'JUPEB': return '1946888188' if self.context.p_category == 'bed_allocation': if student.is_postgrad: return '2067086599' return '2067089893' if self.context.p_category == 'hostel_maintenance': if student.is_postgrad: return '2067089226' return '2066966390' if self.context.p_category == 'clearance': if student.current_mode.startswith('dp_'): return '2067080314' if student.faccode == 'JUPEB': return '1947201668' if student.is_postgrad: return '2067086157' return '2067089446' if self.context.p_category == 'jupeb': return '1947198586' return '' @property def demo_lineitems(self): ba1 = self.context.amount_auth / 2 ba2 = self.context.amount_auth / 2 lineitems = ( {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", "beneficiaryAccount":"6020067886","bankCode":"011", "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"}, {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", "beneficiaryAccount":"0360883515","bankCode":"050", "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"} ) return lineitems def dynamic_provider_amt(self, student): if student.entry_session >= 2016: return 2500.0 return 1500.0 @property def lineitems(self): provider_amt = 0.0 if self.context.p_category == 'schoolfee' and \ not self.context.p_item == 'Balance': provider_amt = self.dynamic_provider_amt(self.context.student) elif self.context.p_category == 'clearance': provider_amt = self.dynamic_provider_amt(self.context.student) inst_amt = self.context.amount_auth - provider_amt if provider_amt: lineitems = ( {"lineItemsId":"itemid1","beneficiaryName":"Uniben", "beneficiaryAccount":"0040217361011","bankCode":"000", "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", "beneficiaryAccount":"1014261520","bankCode":"057", "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} ) else: lineitems = ( {"lineItemsId":"itemid1","beneficiaryName":"Uniben", "beneficiaryAccount":"0040217361011","bankCode":"000", "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, ) return lineitems def update(self): if not module_activated(self.context.student.current_session): return self.orderId = self.context.p_id self.amount = str(self.context.amount_auth) error = self.init_update() if error: self.flash(error, type='danger') self.redirect(self.url(self.context, '@@index')) return return class CustomRemitaRequestPaymentStatusPageApplicant( RemitaRequestPaymentStatusPageApplicant): """ Request webservice view for the Remita gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY class CustomRemitaVerifyPaymentStatusPageApplicant( RemitaVerifyPaymentStatusPageApplicant): """ Request webservice view for the Remita gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY class CustomRemitaPageApplicant(RemitaPageApplicant): """ View which sends a POST request to the Remita payment gateway. """ merchantId = MERCHANTID host = HOST https = HTTPS api_key = API_KEY init_url = '/remita/ecomm/split/init.reg' @property def serviceTypeId(self): applicant = self.context.__parent__ if applicant.__parent__.prefix.startswith('dp'): return '2066963437' if applicant.__parent__.prefix.startswith('pg'): return '2067086388' if applicant.__parent__.prefix == 'pre': return '1946882248' if applicant.__parent__.prefix in ('pude','putme','cbt', 'ab','ak','akj'): return '2066965951' return '' @property def demo_lineitems(self): lineitems = ( {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", "beneficiaryAccount":"6020067886","bankCode":"011", "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", "beneficiaryAccount":"0360883515","bankCode":"050", "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} ) return lineitems @property def lineitems(self): provider_amt = 1000.0 #if self.context.__parent__.applicant_id.startswith('cbt'): # provider_amt = 200.0 inst_amt = self.context.amount_auth - provider_amt lineitems = ( {"lineItemsId":"itemid1","beneficiaryName":"Uniben", "beneficiaryAccount":"0040217361011","bankCode":"000", "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", "beneficiaryAccount":"1014261520","bankCode":"057", "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} ) return lineitems def update(self): if not module_activated(self.context.__parent__.__parent__.year): return self.orderId = self.context.p_id self.amount = str(self.context.amount_auth) error = self.init_update() if error: self.flash(error, type='danger') self.redirect(self.url(self.context, '@@index')) return return