[14746] | 1 | ## $Id: browser.py 16230 2020-09-08 10:09:42Z 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] | 19 | from kofacustom.nigeria.remita.studentsbrowser import ( |
---|
[14746] | 20 | module_activated, |
---|
[14757] | 21 | RemitaRequestPaymentStatusPageStudent, |
---|
[14792] | 22 | RemitaVerifyPaymentStatusPageStudent, |
---|
[14746] | 23 | RemitaPageStudent) |
---|
[14767] | 24 | from 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] | 30 | MERCHANTID = '2067163382' |
---|
| 31 | HOST = 'login.remita.net' |
---|
| 32 | HTTPS = True |
---|
| 33 | API_KEY = '309418' |
---|
| 34 | SERVICETYPEID = '4430731' |
---|
[14792] | 35 | |
---|
[14757] | 36 | class 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] | 46 | class 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] | 56 | class 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 |
---|
[16090] | 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 |
---|
[16090] | 131 | def lineitems(self): |
---|
[14960] | 132 | inst_bankcode = "000" |
---|
| 133 | inst_acct = "0040217361011" |
---|
[14767] | 134 | provider_amt = 0.0 |
---|
[15929] | 135 | student_union = 0.0 |
---|
[14767] | 136 | if self.context.p_category == 'schoolfee' and \ |
---|
| 137 | not self.context.p_item == 'Balance': |
---|
[14770] | 138 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
[15929] | 139 | if self.context.student.current_mode == 'ug_ft': |
---|
| 140 | student_union = 1000.0 |
---|
[14767] | 141 | elif self.context.p_category == 'clearance': |
---|
[14770] | 142 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
[14970] | 143 | #elif self.context.p_category == 'pharmd_1': |
---|
| 144 | # inst_acct = "0020197061015" |
---|
| 145 | # provider_amt = 0.0 |
---|
[14902] | 146 | if self.context.student.is_jupeb \ |
---|
[14888] | 147 | or self.context.student.current_mode == 'dp_ft': |
---|
[14872] | 148 | inst_acct = "0040217361038" |
---|
[15938] | 149 | inst_amt = self.context.amount_auth - provider_amt - student_union |
---|
[15929] | 150 | lineitems = ( |
---|
| 151 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
| 152 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
| 153 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 154 | ) |
---|
[14767] | 155 | if provider_amt: |
---|
[15929] | 156 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
[14767] | 157 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
[15929] | 158 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
| 159 | if student_union: |
---|
| 160 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union", |
---|
| 161 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
| 162 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
| 163 | |
---|
[14960] | 164 | # Split pharmd school fee payments into 3 parts if students decide to pay the |
---|
| 165 | # entire school fee at once. If the amount is less than N240000, the student |
---|
| 166 | # has obviously paid the first installment of N80000 (pharmd_1) |
---|
[14970] | 167 | # (disabled on 16/03/18) |
---|
| 168 | #if self.context.p_category == 'schoolfee' \ |
---|
| 169 | # and self.context.student.current_mode == 'special_ft' \ |
---|
| 170 | # and self.context.amount_auth >= 240000: |
---|
| 171 | # pcn_amt = 80000.0 |
---|
| 172 | # inst_amt -= pcn_amt |
---|
| 173 | # lineitems = ( |
---|
| 174 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
| 175 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
| 176 | # "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 177 | # {"lineItemsId":"itemid2","beneficiaryName":"PCN", |
---|
| 178 | # "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode, |
---|
| 179 | # "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"}, |
---|
| 180 | # {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
| 181 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 182 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
| 183 | # ) |
---|
[14960] | 184 | self.context.provider_amt = provider_amt |
---|
[15817] | 185 | self.context.net_amt = inst_amt |
---|
[14767] | 186 | return lineitems |
---|
| 187 | |
---|
[14746] | 188 | def update(self): |
---|
[15828] | 189 | if not module_activated( |
---|
| 190 | self.context.student.current_session, self.context): |
---|
[14746] | 191 | return |
---|
[14778] | 192 | self.orderId = self.context.p_id |
---|
| 193 | self.amount = str(self.context.amount_auth) |
---|
[14746] | 194 | error = self.init_update() |
---|
| 195 | if error: |
---|
| 196 | self.flash(error, type='danger') |
---|
| 197 | self.redirect(self.url(self.context, '@@index')) |
---|
| 198 | return |
---|
[15817] | 199 | self.context.r_company = u'remita' |
---|
[14767] | 200 | return |
---|
| 201 | |
---|
| 202 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
| 203 | RemitaRequestPaymentStatusPageApplicant): |
---|
| 204 | """ Request webservice view for the Remita gateway. |
---|
| 205 | """ |
---|
| 206 | |
---|
[14792] | 207 | merchantId = MERCHANTID |
---|
| 208 | host = HOST |
---|
| 209 | https = HTTPS |
---|
| 210 | api_key = API_KEY |
---|
[14767] | 211 | |
---|
[14792] | 212 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
| 213 | RemitaVerifyPaymentStatusPageApplicant): |
---|
| 214 | """ Request webservice view for the Remita gateway. |
---|
| 215 | """ |
---|
| 216 | |
---|
| 217 | merchantId = MERCHANTID |
---|
| 218 | host = HOST |
---|
| 219 | https = HTTPS |
---|
| 220 | api_key = API_KEY |
---|
| 221 | |
---|
[14767] | 222 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
| 223 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 224 | """ |
---|
| 225 | |
---|
[14792] | 226 | merchantId = MERCHANTID |
---|
| 227 | host = HOST |
---|
| 228 | https = HTTPS |
---|
| 229 | api_key = API_KEY |
---|
| 230 | |
---|
[14767] | 231 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 232 | |
---|
[14776] | 233 | @property |
---|
[14795] | 234 | def serviceTypeId(self): |
---|
[14799] | 235 | applicant = self.context.__parent__ |
---|
[14800] | 236 | if applicant.__parent__.prefix.startswith('dp'): |
---|
[14813] | 237 | return '2066963437' |
---|
[14832] | 238 | if applicant.__parent__.prefix in ('spft', ): |
---|
[14813] | 239 | return '2067086388' |
---|
[14800] | 240 | if applicant.__parent__.prefix == 'pre': |
---|
[14813] | 241 | return '1946882248' |
---|
[14800] | 242 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
[16230] | 243 | 'ab','ak','akj','ase'): |
---|
[14813] | 244 | return '2066965951' |
---|
[16230] | 245 | if applicant.__parent__.prefix in ('tscs', 'tscf'): |
---|
| 246 | return '698984179' |
---|
[14799] | 247 | return '' |
---|
[14795] | 248 | |
---|
| 249 | @property |
---|
[16090] | 250 | def demo_lineitems(self): |
---|
[14800] | 251 | lineitems = ( |
---|
[14776] | 252 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 253 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 254 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
| 255 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 256 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 257 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
| 258 | ) |
---|
| 259 | return lineitems |
---|
[14770] | 260 | |
---|
[14767] | 261 | @property |
---|
[16090] | 262 | def lineitems(self): |
---|
[15491] | 263 | provider_amt = 1000.0 |
---|
[16205] | 264 | if self.context.__parent__.applicant_id.startswith('pre'): |
---|
| 265 | provider_amt = 2000.0 |
---|
| 266 | if self.context.__parent__.applicant_id.startswith('tsc'): |
---|
| 267 | provider_amt = 1200.0 |
---|
| 268 | if self.context.__parent__.applicant_id.startswith('ase'): |
---|
| 269 | provider_amt = 500.0 |
---|
[14888] | 270 | if self.context.__parent__.applicant_id.startswith('dp'): |
---|
| 271 | inst_acct = "0040217361038" |
---|
| 272 | else: |
---|
| 273 | inst_acct = "0040217361011" |
---|
[15499] | 274 | if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
[16201] | 275 | provider_amt = 300.0 |
---|
[16205] | 276 | if self.context.p_item == 'Balance': |
---|
| 277 | provider_amt = 0.0 |
---|
[14770] | 278 | inst_amt = self.context.amount_auth - provider_amt |
---|
[14767] | 279 | lineitems = ( |
---|
[14770] | 280 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
[14888] | 281 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
[14770] | 282 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
[14767] | 283 | ) |
---|
[16205] | 284 | if provider_amt: |
---|
| 285 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
| 286 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 287 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
| 288 | |
---|
[14960] | 289 | self.context.provider_amt = provider_amt |
---|
[15817] | 290 | self.context.net_amt = inst_amt |
---|
[14767] | 291 | return lineitems |
---|
| 292 | |
---|
| 293 | def update(self): |
---|
[15828] | 294 | if not module_activated( |
---|
| 295 | self.context.__parent__.__parent__.year, self.context): |
---|
[14767] | 296 | return |
---|
[14778] | 297 | self.orderId = self.context.p_id |
---|
| 298 | self.amount = str(self.context.amount_auth) |
---|
[14767] | 299 | error = self.init_update() |
---|
| 300 | if error: |
---|
| 301 | self.flash(error, type='danger') |
---|
| 302 | self.redirect(self.url(self.context, '@@index')) |
---|
| 303 | return |
---|
[15817] | 304 | self.context.r_company = u'remita' |
---|
[14746] | 305 | return |
---|