[15601] | 1 | ## $Id: browser.py 16685 2021-10-26 07:13:29Z 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 | |
---|
| 19 | from kofacustom.nigeria.etranzact.applicantsbrowser import ( |
---|
| 20 | EtranzactPageApplicant, EtranzactReceiveResponseApplicant, |
---|
| 21 | EtranzactRequestPaymentStatusPageApplicant) |
---|
| 22 | from kofacustom.nigeria.etranzact.studentsbrowser import ( |
---|
| 23 | EtranzactPageStudent, EtranzactReceiveResponseStudent, |
---|
[15773] | 24 | EtranzactRequestPaymentStatusPageStudent, webconnect_module_activated) |
---|
[15733] | 25 | from kofacustom.nigeria.etranzact.payoutletbrowser import ( |
---|
[15773] | 26 | EtranzactEnterPinPageStudent, EtranzactEnterPinPageApplicant, |
---|
| 27 | EtranzactQueryHistoryPageStudent, EtranzactQueryHistoryPageApplicant, |
---|
| 28 | payoutlet_module_activated) |
---|
| 29 | from kofacustom.nigeria.etranzact.payoutletwebservice import NigeriaPaymentDataWebservice |
---|
[15601] | 30 | |
---|
| 31 | # Temporarily we can use the test portal like in kofacustom.nigeria |
---|
| 32 | |
---|
| 33 | from kofacustom.nigeria.etranzact.tests import ( |
---|
[16104] | 34 | HOST, HTTPS) |
---|
[15601] | 35 | |
---|
[16637] | 36 | HOST = 'www.etranzactng.net' |
---|
[15824] | 37 | HTTPS = True |
---|
[16141] | 38 | GATEWAY_AMT = 0.0 # is beeing added by Etranzact |
---|
[15601] | 39 | LOGO_URL = 'https://iuokada.waeup.org/static_custom/iou_logo.png' |
---|
| 40 | |
---|
[16084] | 41 | WEBCONNECT_STUD_PARAMS = { |
---|
| 42 | 'schoolfee': ('7007139588','QIgl9a35R30A1RGK'), |
---|
| 43 | 'schoolfee40': ('7007139589','3coU0eolOEbEUeO3'), |
---|
| 44 | 'secondinstal': ('7007139590','zGpEjy6CdPxCHqen'), |
---|
| 45 | 'transcript_local': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
[16142] | 46 | 'transcript': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
[16084] | 47 | 'transcript_overseas': ('7007139592','ndgxUtzJgHRkvXlB'), |
---|
| 48 | 'registration': ('7007139599','KGHjZ2hRbaDJGBX8'), |
---|
| 49 | 'book': ('7007139600','rrKE2Ua7eu8TF0Is'), |
---|
| 50 | 'parentsconsult': ('7007139598','HsqjOlAB5xfQNDyo'), |
---|
| 51 | 'sundry': ('7007139591','0XkOFShPnWn8tY5O'), |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | def determine_appl_params(payment): |
---|
| 55 | terminal_id = '' |
---|
| 56 | secret_key = '' |
---|
| 57 | if payment.__parent__.__parent__.prefix.startswith('pg'): |
---|
| 58 | terminal_id = '7007139606' |
---|
| 59 | secret_key = 'E64s3IN9cXRJeltY' |
---|
| 60 | else: |
---|
| 61 | terminal_id = '7007139604' |
---|
| 62 | secret_key = 'vlEEJxvJBjC468g1' |
---|
| 63 | return terminal_id, secret_key |
---|
| 64 | |
---|
| 65 | def determine_stud_params(payment): |
---|
| 66 | terminal_id = '' |
---|
| 67 | secret_key = '' |
---|
| 68 | for key in WEBCONNECT_STUD_PARAMS.keys(): |
---|
| 69 | if payment.p_category == key: |
---|
| 70 | terminal_id = WEBCONNECT_STUD_PARAMS[key][0] |
---|
| 71 | secret_key = WEBCONNECT_STUD_PARAMS[key][1] |
---|
| 72 | if not terminal_id: |
---|
| 73 | terminal_id = WEBCONNECT_STUD_PARAMS['sundry'][0] |
---|
| 74 | secret_key = WEBCONNECT_STUD_PARAMS['sundry'][1] |
---|
| 75 | return terminal_id, secret_key |
---|
| 76 | |
---|
[15601] | 77 | class CustomEtranzactPageApplicant(EtranzactPageApplicant): |
---|
| 78 | |
---|
| 79 | host = HOST |
---|
| 80 | https = HTTPS |
---|
| 81 | logo_url = LOGO_URL |
---|
[15773] | 82 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 83 | |
---|
[16084] | 84 | @property |
---|
| 85 | def terminal_id(self): |
---|
| 86 | return determine_appl_params(self.context)[0] |
---|
| 87 | |
---|
| 88 | @property |
---|
| 89 | def secret_key(self): |
---|
| 90 | return determine_appl_params(self.context)[1] |
---|
| 91 | |
---|
[15773] | 92 | def update(self): |
---|
[15999] | 93 | if not webconnect_module_activated( |
---|
| 94 | self.context.__parent__.__parent__.year, self.context): |
---|
[16350] | 95 | self.flash('Forbidden', type='danger') |
---|
[15999] | 96 | self.redirect(self.url(self.context, '@@index')) |
---|
| 97 | return |
---|
[15773] | 98 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 99 | # and add the gateway amount. |
---|
| 100 | if not self.context.r_company: |
---|
| 101 | self.context.net_amt = self.context.amount_auth |
---|
| 102 | self.context.amount_auth += self.gateway_amt |
---|
| 103 | self.context.gateway_amt = self.gateway_amt |
---|
| 104 | self.context.r_company = u'etranzact' |
---|
| 105 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 106 | error = self.init_update() |
---|
| 107 | if error: |
---|
| 108 | self.flash(error, type='danger') |
---|
| 109 | self.redirect(self.url(self.context, '@@index')) |
---|
| 110 | return |
---|
| 111 | return |
---|
| 112 | |
---|
[15601] | 113 | class CustomEtranzactReceiveResponseApplicant(EtranzactReceiveResponseApplicant): |
---|
| 114 | |
---|
[16084] | 115 | @property |
---|
| 116 | def terminal_id(self): |
---|
| 117 | return determine_appl_params(self.context)[0] |
---|
[15601] | 118 | |
---|
[16084] | 119 | @property |
---|
| 120 | def secret_key(self): |
---|
| 121 | return determine_appl_params(self.context)[1] |
---|
| 122 | |
---|
[15601] | 123 | class CustomEtranzactRequestPaymentStatusPageApplicant( |
---|
| 124 | EtranzactRequestPaymentStatusPageApplicant): |
---|
| 125 | |
---|
| 126 | host = HOST |
---|
| 127 | https = HTTPS |
---|
| 128 | logo_url = LOGO_URL |
---|
| 129 | |
---|
[16084] | 130 | @property |
---|
| 131 | def terminal_id(self): |
---|
| 132 | return determine_appl_params(self.context)[0] |
---|
| 133 | |
---|
| 134 | @property |
---|
| 135 | def secret_key(self): |
---|
| 136 | return determine_appl_params(self.context)[1] |
---|
| 137 | |
---|
[15601] | 138 | class CustomEtranzactPageStudent(EtranzactPageStudent): |
---|
| 139 | |
---|
| 140 | host = HOST |
---|
| 141 | https = HTTPS |
---|
| 142 | logo_url = LOGO_URL |
---|
[15773] | 143 | gateway_amt = GATEWAY_AMT |
---|
[15601] | 144 | |
---|
[16084] | 145 | @property |
---|
| 146 | def terminal_id(self): |
---|
| 147 | return determine_stud_params(self.context)[0] |
---|
| 148 | |
---|
| 149 | @property |
---|
| 150 | def secret_key(self): |
---|
| 151 | return determine_stud_params(self.context)[1] |
---|
| 152 | |
---|
[15773] | 153 | def update(self): |
---|
[15999] | 154 | if not webconnect_module_activated( |
---|
| 155 | self.context.student.current_session, self.context): |
---|
| 156 | self.flash(_('Forbidden'), type='danger') |
---|
| 157 | self.redirect(self.url(self.context, '@@index')) |
---|
| 158 | return |
---|
[15773] | 159 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 160 | # and add the gateway amount. |
---|
| 161 | if not self.context.r_company: |
---|
| 162 | self.context.net_amt = self.context.amount_auth |
---|
| 163 | self.context.amount_auth += self.gateway_amt |
---|
| 164 | self.context.gateway_amt = self.gateway_amt |
---|
| 165 | self.context.r_company = u'etranzact' |
---|
| 166 | self.amount = "%.1f" % self.context.amount_auth |
---|
| 167 | error = self.init_update() |
---|
| 168 | if error: |
---|
| 169 | self.flash(error, type='danger') |
---|
| 170 | self.redirect(self.url(self.context, '@@index')) |
---|
| 171 | return |
---|
| 172 | return |
---|
| 173 | |
---|
[15601] | 174 | class CustomEtranzactReceiveResponseStudent(EtranzactReceiveResponseStudent): |
---|
| 175 | |
---|
[16084] | 176 | @property |
---|
| 177 | def terminal_id(self): |
---|
| 178 | return determine_stud_params(self.context)[0] |
---|
[15601] | 179 | |
---|
[16084] | 180 | @property |
---|
| 181 | def secret_key(self): |
---|
| 182 | return determine_stud_params(self.context)[1] |
---|
| 183 | |
---|
[15601] | 184 | class CustomEtranzactRequestPaymentStatusPageStudent( |
---|
| 185 | EtranzactRequestPaymentStatusPageStudent): |
---|
| 186 | |
---|
| 187 | host = HOST |
---|
| 188 | https = HTTPS |
---|
| 189 | logo_url = LOGO_URL |
---|
| 190 | |
---|
[16084] | 191 | @property |
---|
| 192 | def terminal_id(self): |
---|
| 193 | return determine_stud_params(self.context)[0] |
---|
| 194 | |
---|
| 195 | @property |
---|
| 196 | def secret_key(self): |
---|
| 197 | return determine_stud_params(self.context)[1] |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | |
---|
[15773] | 203 | # Payoutlet customizations |
---|
| 204 | |
---|
| 205 | class CustomEtranzactEnterPinPageStudent(EtranzactEnterPinPageStudent): |
---|
| 206 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageStudent` |
---|
| 207 | """ |
---|
| 208 | gateway_amt = GATEWAY_AMT |
---|
| 209 | |
---|
| 210 | def update(self): |
---|
| 211 | if not payoutlet_module_activated( |
---|
| 212 | self.context.student.current_session, self.context): |
---|
[15999] | 213 | self.flash(_('Forbidden'), type='danger') |
---|
| 214 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 215 | return |
---|
| 216 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 217 | # and add the gateway amount. |
---|
| 218 | if not self.context.r_company: |
---|
| 219 | self.context.net_amt = self.context.amount_auth |
---|
| 220 | self.context.amount_auth += self.gateway_amt |
---|
| 221 | self.context.gateway_amt = self.gateway_amt |
---|
| 222 | self.context.r_company = u'etranzact' |
---|
| 223 | return |
---|
| 224 | |
---|
| 225 | class CustomEtranzactEnterPinPageApplicant(EtranzactEnterPinPageApplicant): |
---|
| 226 | """Enter confirmation PIN and submit to `EtranzactQueryHistoryPageApplicant` |
---|
| 227 | """ |
---|
| 228 | gateway_amt = GATEWAY_AMT |
---|
| 229 | |
---|
| 230 | def update(self): |
---|
| 231 | if not payoutlet_module_activated( |
---|
| 232 | self.context.__parent__.__parent__.year, self.context): |
---|
[15999] | 233 | self.flash(_('Forbidden'), type='danger') |
---|
| 234 | self.redirect(self.url(self.context, '@@index')) |
---|
[15773] | 235 | return |
---|
| 236 | # Already now it becomes an Etranzact payment. We set the net amount |
---|
| 237 | # and add the gateway amount. |
---|
| 238 | if not self.context.r_company: |
---|
| 239 | self.context.net_amt = self.context.amount_auth |
---|
| 240 | self.context.amount_auth += self.gateway_amt |
---|
| 241 | self.context.gateway_amt = self.gateway_amt |
---|
| 242 | self.context.r_company = u'etranzact' |
---|
| 243 | return |
---|
| 244 | |
---|
[15733] | 245 | class CustomEtranzactQueryHistoryPageStudent(EtranzactQueryHistoryPageStudent): |
---|
| 246 | """ Query history of Etranzact payments |
---|
| 247 | """ |
---|
[16084] | 248 | terminal_id = '7007134590' |
---|
[15733] | 249 | host = HOST |
---|
| 250 | https = HTTPS |
---|
[15601] | 251 | |
---|
[15733] | 252 | class CustomEtranzactQueryHistoryPageApplicant(EtranzactQueryHistoryPageApplicant): |
---|
| 253 | """ Query history of Etranzact payments |
---|
| 254 | """ |
---|
[15898] | 255 | terminal_id = '7009158847' |
---|
[15733] | 256 | host = HOST |
---|
[15773] | 257 | https = HTTPS |
---|
| 258 | |
---|
| 259 | class CustomPaymentDataWebservice(NigeriaPaymentDataWebservice): |
---|
| 260 | """A simple webservice to publish payment and payer details on request from |
---|
| 261 | accepted IP addresses without authentication. |
---|
| 262 | """ |
---|
| 263 | #ACCEPTED_IP = ('195.219.3.181', '195.219.3.184') |
---|
| 264 | ACCEPTED_IP = None |
---|
| 265 | |
---|
| 266 | CATEGORY_MAPPING = { |
---|
[15781] | 267 | 'IUO_SCHOOL_FEES_FULL_PAYMENT': ('schoolfee',), |
---|
| 268 | 'IUO_SCHOOL_FEES_FIRST_INSTALLMENT': ('schoolfee40',), |
---|
| 269 | 'IUO_SCHOOL_FEES_OTHER_INSTALLMENT': ('secondinstal',), |
---|
[16111] | 270 | |
---|
| 271 | 'IUO_SUNDRY_FEES': ('combi',), |
---|
| 272 | |
---|
| 273 | 'IUO_MATRICULATION_FEE': ('matric',), |
---|
| 274 | 'IUO_LATE_REGISTRATION_FEE': ('late_registration',), |
---|
[16311] | 275 | 'IUO_WAEC/NECO_VERIFICATION_FEE': ('waecneco',), |
---|
[16111] | 276 | 'IUO_JAMB_VERIFICATION': ('jambver',), |
---|
| 277 | 'IUO_CONVOCATION_FEE': ('conv',), |
---|
| 278 | 'IUO_ALUMNI_FEE': ('alumni',), |
---|
| 279 | 'IUO_SCIENCE_BENCE_FEE': ('science',), |
---|
| 280 | 'IUO_LETTER_OF_IDENTIFICATION_FEE': ('lo_ident',), |
---|
| 281 | 'IUO_CHANGE_OF_COURSE_FEE': ('change_course',), |
---|
| 282 | 'IUO_IUITS_FEE': ('iuits',), |
---|
| 283 | 'IUO_FINES_FEE': ('fine',), |
---|
| 284 | 'IUO_PHARMACY_LAB_SUPPORT_FEE': ('pharmlab',), |
---|
| 285 | 'IUO_MAKEUP_FEE': ('resit1', 'resit2', 'resit3', 'resit4', |
---|
| 286 | 'resit5', 'resit6', 'resit7', 'resit8', |
---|
| 287 | 'resit9',), |
---|
| 288 | 'IUO_CLINICAL_FEE_MEDICAL_STUDENTS': ('clinical',), |
---|
| 289 | 'IUO_TRANSCRIPT_FEE_INTERNATIONAL': ('transcript_overseas',), |
---|
[16142] | 290 | 'IUO_TRANCRIPT_FEE_LOCAL': ('transcript_local', 'transcript'), |
---|
[16261] | 291 | 'IUO_ACCEPTANCE_FEE': ('clearance',), |
---|
| 292 | 'IUO_CLEARANCE_FEE': ('grad_clearance',), |
---|
[16111] | 293 | 'IUO_ID_CARD_FEE': ('id_card',), |
---|
[15781] | 294 | 'IUO_REGISTRATION_FEE': ('registration',), |
---|
[16111] | 295 | 'IUO_DEVELOPMENT_FEE': ('develop',), |
---|
| 296 | 'IUO_MUNICIPAL_FEE': ('municipal_fresh','municipal_returning'), |
---|
| 297 | 'IUO_BOOK_DEPOSIT': ('book',), |
---|
[15781] | 298 | 'IUO_PARENTS_CONSULTATIVE_FORUM_FEE': ('parentsconsult',), |
---|
[16340] | 299 | |
---|
| 300 | 'IUO_APPLICATION_FORM_UNDERGRADUATE': ('application',), |
---|
| 301 | 'IUO_APPLICATION_FORM_POSTGRADUATE': ('application',), |
---|
[16397] | 302 | |
---|
[16577] | 303 | 'IUO_MAKE_UP_REGISTRATION_FEE': ('makeup_admin',), |
---|
| 304 | |
---|
[16685] | 305 | 'IUO_COMBI_PAYMENT': ('combi',), |
---|
| 306 | |
---|
[16397] | 307 | 'JUPEB_FORM_FEE': ('jupeb_form',), |
---|
| 308 | 'JUPEB_ACCEPTANCE_FEE': ('jupeb_acc',), |
---|
| 309 | 'JUPEB_SCIENCE_COURSE': ('jupeb_sci',), |
---|
| 310 | 'JUPEB_ARTS_COURSE': ('jupeb_arts',), |
---|
| 311 | 'JUPEB_HOSTEL_FEE': ('jupeb_hostel',), |
---|
| 312 | 'JUPEB_REGISTRATION_FEE': ('jupeb_reg',), |
---|
[15773] | 313 | } |
---|