[14746] | 1 | ## $Id: browser.py 16089 2020-05-11 14:21:06Z 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 |
---|
| 30 | |
---|
[16089] | 31 | from kofacustom.nigeria.remita.tests import ( |
---|
| 32 | MERCHANTID, |
---|
| 33 | HOST, |
---|
| 34 | HTTPS, |
---|
| 35 | API_KEY, |
---|
| 36 | SERVICETYPEID |
---|
| 37 | ) |
---|
| 38 | |
---|
| 39 | #MERCHANTID = '2067163382' |
---|
| 40 | #HOST = 'login.remita.net' |
---|
| 41 | #HTTPS = True |
---|
| 42 | #API_KEY = '309418' |
---|
| 43 | #SERVICETYPEID = '4430731' |
---|
| 44 | |
---|
[14757] | 45 | class CustomRemitaRequestPaymentStatusPageStudent( |
---|
| 46 | RemitaRequestPaymentStatusPageStudent): |
---|
[14746] | 47 | """ Request webservice view for the Remita gateway. |
---|
| 48 | """ |
---|
| 49 | |
---|
[14792] | 50 | merchantId = MERCHANTID |
---|
| 51 | host = HOST |
---|
| 52 | https = HTTPS |
---|
| 53 | api_key = API_KEY |
---|
[14746] | 54 | |
---|
[14792] | 55 | class CustomRemitaVerifyPaymentStatusPageStudent( |
---|
| 56 | RemitaVerifyPaymentStatusPageStudent): |
---|
| 57 | """ Request webservice view for the Remita gateway. |
---|
| 58 | """ |
---|
| 59 | |
---|
| 60 | merchantId = MERCHANTID |
---|
| 61 | host = HOST |
---|
| 62 | https = HTTPS |
---|
| 63 | api_key = API_KEY |
---|
| 64 | |
---|
[14746] | 65 | class CustomRemitaPageStudent(RemitaPageStudent): |
---|
| 66 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 67 | """ |
---|
| 68 | |
---|
[14792] | 69 | merchantId = MERCHANTID |
---|
| 70 | host = HOST |
---|
| 71 | https = HTTPS |
---|
| 72 | api_key = API_KEY |
---|
| 73 | |
---|
[14746] | 74 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 75 | |
---|
[14776] | 76 | @property |
---|
[14795] | 77 | def serviceTypeId(self): |
---|
| 78 | student = self.context.student |
---|
| 79 | if self.context.p_category == 'schoolfee': |
---|
| 80 | if student.current_mode.startswith('dp_'): |
---|
| 81 | return '2067090482' |
---|
| 82 | if student.current_mode == 'pg_ft': |
---|
| 83 | return '2067090691' |
---|
[14852] | 84 | if student.current_mode.endswith('pg_pt'): |
---|
[14795] | 85 | return '2067091011' |
---|
| 86 | if student.current_mode == 'ug_sw': |
---|
| 87 | return '2066967204' |
---|
[14809] | 88 | if student.current_mode.endswith('ug_ft'): |
---|
[14795] | 89 | return '2067091395' |
---|
| 90 | if student.current_mode == 'ug_pt': |
---|
| 91 | return '2067091679' |
---|
[14960] | 92 | if student.current_mode == 'special_ft': |
---|
| 93 | return '2750318564' # Module 2 |
---|
[14902] | 94 | if student.is_jupeb: |
---|
[14795] | 95 | return '1946888188' |
---|
[14799] | 96 | if self.context.p_category == 'bed_allocation': |
---|
| 97 | if student.is_postgrad: |
---|
| 98 | return '2067086599' |
---|
| 99 | return '2067089893' |
---|
| 100 | if self.context.p_category == 'hostel_maintenance': |
---|
| 101 | if student.is_postgrad: |
---|
| 102 | return '2067089226' |
---|
| 103 | return '2066966390' |
---|
| 104 | if self.context.p_category == 'clearance': |
---|
| 105 | if student.current_mode.startswith('dp_'): |
---|
| 106 | return '2067080314' |
---|
[14902] | 107 | if student.is_jupeb: |
---|
[14799] | 108 | return '1947201668' |
---|
| 109 | if student.is_postgrad: |
---|
| 110 | return '2067086157' |
---|
| 111 | return '2067089446' |
---|
| 112 | if self.context.p_category == 'jupeb': |
---|
| 113 | return '1947198586' |
---|
[14970] | 114 | #if self.context.p_category == 'pharmd_1': |
---|
| 115 | # return '2750314820' # Clerkship |
---|
[14960] | 116 | if self.context.p_category == 'pharmd_2': |
---|
| 117 | return '2750174184' # Module 1 |
---|
[14795] | 118 | return '' |
---|
| 119 | |
---|
| 120 | @property |
---|
[16089] | 121 | def lineitems(self): |
---|
[14776] | 122 | ba1 = self.context.amount_auth / 2 |
---|
| 123 | ba2 = self.context.amount_auth / 2 |
---|
| 124 | lineitems = ( |
---|
| 125 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 126 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 127 | "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"}, |
---|
| 128 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 129 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 130 | "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"} |
---|
| 131 | ) |
---|
| 132 | return lineitems |
---|
[14751] | 133 | |
---|
[14767] | 134 | def dynamic_provider_amt(self, student): |
---|
| 135 | if student.entry_session >= 2016: |
---|
| 136 | return 2500.0 |
---|
| 137 | return 1500.0 |
---|
| 138 | |
---|
| 139 | @property |
---|
[16089] | 140 | def live_lineitems(self): |
---|
[14960] | 141 | inst_bankcode = "000" |
---|
| 142 | inst_acct = "0040217361011" |
---|
[14767] | 143 | provider_amt = 0.0 |
---|
[15929] | 144 | student_union = 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) |
---|
[15929] | 148 | if self.context.student.current_mode == 'ug_ft': |
---|
| 149 | student_union = 1000.0 |
---|
[14767] | 150 | elif self.context.p_category == 'clearance': |
---|
[14770] | 151 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
[14970] | 152 | #elif self.context.p_category == 'pharmd_1': |
---|
| 153 | # inst_acct = "0020197061015" |
---|
| 154 | # provider_amt = 0.0 |
---|
[14902] | 155 | if self.context.student.is_jupeb \ |
---|
[14888] | 156 | or self.context.student.current_mode == 'dp_ft': |
---|
[14872] | 157 | inst_acct = "0040217361038" |
---|
[15938] | 158 | inst_amt = self.context.amount_auth - provider_amt - student_union |
---|
[15929] | 159 | lineitems = ( |
---|
| 160 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
| 161 | "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
| 162 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 163 | ) |
---|
[14767] | 164 | if provider_amt: |
---|
[15929] | 165 | lineitems += ({"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
[14767] | 166 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
[15929] | 167 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"},) |
---|
| 168 | if student_union: |
---|
| 169 | lineitems += ({"lineItemsId":"itemid3","beneficiaryName":"Student Union", |
---|
| 170 | "beneficiaryAccount":"0025636203","bankCode":"039", |
---|
| 171 | "beneficiaryAmount":student_union,"deductFeeFrom":"0"},) |
---|
| 172 | |
---|
[14960] | 173 | # Split pharmd school fee payments into 3 parts if students decide to pay the |
---|
| 174 | # entire school fee at once. If the amount is less than N240000, the student |
---|
| 175 | # has obviously paid the first installment of N80000 (pharmd_1) |
---|
[14970] | 176 | # (disabled on 16/03/18) |
---|
| 177 | #if self.context.p_category == 'schoolfee' \ |
---|
| 178 | # and self.context.student.current_mode == 'special_ft' \ |
---|
| 179 | # and self.context.amount_auth >= 240000: |
---|
| 180 | # pcn_amt = 80000.0 |
---|
| 181 | # inst_amt -= pcn_amt |
---|
| 182 | # lineitems = ( |
---|
| 183 | # {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
| 184 | # "beneficiaryAccount":inst_acct,"bankCode":inst_bankcode, |
---|
| 185 | # "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 186 | # {"lineItemsId":"itemid2","beneficiaryName":"PCN", |
---|
| 187 | # "beneficiaryAccount":"0020197061015","bankCode":inst_bankcode, |
---|
| 188 | # "beneficiaryAmount":pcn_amt,"deductFeeFrom":"0"}, |
---|
| 189 | # {"lineItemsId":"itemid3","beneficiaryName":"WAeAC", |
---|
| 190 | # "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 191 | # "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
| 192 | # ) |
---|
[14960] | 193 | self.context.provider_amt = provider_amt |
---|
[15817] | 194 | self.context.net_amt = inst_amt |
---|
[14767] | 195 | return lineitems |
---|
| 196 | |
---|
[14746] | 197 | def update(self): |
---|
[15828] | 198 | if not module_activated( |
---|
| 199 | self.context.student.current_session, self.context): |
---|
[14746] | 200 | return |
---|
[14778] | 201 | self.orderId = self.context.p_id |
---|
| 202 | self.amount = str(self.context.amount_auth) |
---|
[14746] | 203 | error = self.init_update() |
---|
| 204 | if error: |
---|
| 205 | self.flash(error, type='danger') |
---|
| 206 | self.redirect(self.url(self.context, '@@index')) |
---|
| 207 | return |
---|
[15817] | 208 | self.context.r_company = u'remita' |
---|
[14767] | 209 | return |
---|
| 210 | |
---|
| 211 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
| 212 | RemitaRequestPaymentStatusPageApplicant): |
---|
| 213 | """ Request webservice view for the Remita gateway. |
---|
| 214 | """ |
---|
| 215 | |
---|
[14792] | 216 | merchantId = MERCHANTID |
---|
| 217 | host = HOST |
---|
| 218 | https = HTTPS |
---|
| 219 | api_key = API_KEY |
---|
[14767] | 220 | |
---|
[14792] | 221 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
| 222 | RemitaVerifyPaymentStatusPageApplicant): |
---|
| 223 | """ Request webservice view for the Remita gateway. |
---|
| 224 | """ |
---|
| 225 | |
---|
| 226 | merchantId = MERCHANTID |
---|
| 227 | host = HOST |
---|
| 228 | https = HTTPS |
---|
| 229 | api_key = API_KEY |
---|
| 230 | |
---|
[14767] | 231 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
| 232 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 233 | """ |
---|
| 234 | |
---|
[14792] | 235 | merchantId = MERCHANTID |
---|
| 236 | host = HOST |
---|
| 237 | https = HTTPS |
---|
| 238 | api_key = API_KEY |
---|
| 239 | |
---|
[14767] | 240 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 241 | |
---|
[14776] | 242 | @property |
---|
[14795] | 243 | def serviceTypeId(self): |
---|
[14799] | 244 | applicant = self.context.__parent__ |
---|
[14800] | 245 | if applicant.__parent__.prefix.startswith('dp'): |
---|
[14813] | 246 | return '2066963437' |
---|
[14832] | 247 | if applicant.__parent__.prefix in ('spft', ): |
---|
[14813] | 248 | return '2067086388' |
---|
[14800] | 249 | if applicant.__parent__.prefix == 'pre': |
---|
[14813] | 250 | return '1946882248' |
---|
[14800] | 251 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
[14825] | 252 | 'ab','ak','akj','ase'): |
---|
[14813] | 253 | return '2066965951' |
---|
[14799] | 254 | return '' |
---|
[14795] | 255 | |
---|
| 256 | @property |
---|
[16089] | 257 | def lineitems(self): |
---|
[14800] | 258 | lineitems = ( |
---|
[14776] | 259 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 260 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 261 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
| 262 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 263 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 264 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
| 265 | ) |
---|
| 266 | return lineitems |
---|
[14770] | 267 | |
---|
[14767] | 268 | @property |
---|
[16089] | 269 | def demo_lineitems(self): |
---|
[15491] | 270 | provider_amt = 1000.0 |
---|
| 271 | if self.context.__parent__.applicant_id.startswith('pre'): |
---|
| 272 | provider_amt = 2000.0 |
---|
[14888] | 273 | if self.context.__parent__.applicant_id.startswith('dp'): |
---|
| 274 | inst_acct = "0040217361038" |
---|
| 275 | else: |
---|
| 276 | inst_acct = "0040217361011" |
---|
[15499] | 277 | if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
| 278 | provider_amt = 500.0 |
---|
[14770] | 279 | inst_amt = self.context.amount_auth - provider_amt |
---|
[14767] | 280 | lineitems = ( |
---|
[14770] | 281 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
[14888] | 282 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
[14770] | 283 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 284 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
| 285 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 286 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
[14767] | 287 | ) |
---|
[14960] | 288 | self.context.provider_amt = provider_amt |
---|
[15817] | 289 | self.context.net_amt = inst_amt |
---|
[14767] | 290 | return lineitems |
---|
| 291 | |
---|
| 292 | def update(self): |
---|
[15828] | 293 | if not module_activated( |
---|
| 294 | self.context.__parent__.__parent__.year, self.context): |
---|
[14767] | 295 | return |
---|
[14778] | 296 | self.orderId = self.context.p_id |
---|
| 297 | self.amount = str(self.context.amount_auth) |
---|
[14767] | 298 | error = self.init_update() |
---|
| 299 | if error: |
---|
| 300 | self.flash(error, type='danger') |
---|
| 301 | self.redirect(self.url(self.context, '@@index')) |
---|
| 302 | return |
---|
[15817] | 303 | self.context.r_company = u'remita' |
---|
[14746] | 304 | return |
---|