[14746] | 1 | ## $Id: browser.py 14876 2017-10-24 09:27:55Z 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 |
---|
[14795] | 30 | MERCHANTID = '2067163382' |
---|
| 31 | HOST = 'login.remita.net' |
---|
| 32 | HTTPS = True |
---|
| 33 | API_KEY = '309418' |
---|
[14792] | 34 | SERVICETYPEID = '4430731' |
---|
| 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' |
---|
| 83 | if student.faccode == 'JUPEB': |
---|
| 84 | return '1946888188' |
---|
[14799] | 85 | if self.context.p_category == 'bed_allocation': |
---|
| 86 | if student.is_postgrad: |
---|
| 87 | return '2067086599' |
---|
| 88 | return '2067089893' |
---|
| 89 | if self.context.p_category == 'hostel_maintenance': |
---|
| 90 | if student.is_postgrad: |
---|
| 91 | return '2067089226' |
---|
| 92 | return '2066966390' |
---|
| 93 | if self.context.p_category == 'clearance': |
---|
| 94 | if student.current_mode.startswith('dp_'): |
---|
| 95 | return '2067080314' |
---|
| 96 | if student.faccode == 'JUPEB': |
---|
| 97 | return '1947201668' |
---|
| 98 | if student.is_postgrad: |
---|
| 99 | return '2067086157' |
---|
| 100 | return '2067089446' |
---|
| 101 | if self.context.p_category == 'jupeb': |
---|
| 102 | return '1947198586' |
---|
[14795] | 103 | return '' |
---|
| 104 | |
---|
| 105 | @property |
---|
| 106 | def demo_lineitems(self): |
---|
[14776] | 107 | ba1 = self.context.amount_auth / 2 |
---|
| 108 | ba2 = self.context.amount_auth / 2 |
---|
| 109 | lineitems = ( |
---|
| 110 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 111 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 112 | "beneficiaryAmount":str(ba1),"deductFeeFrom":"1"}, |
---|
| 113 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 114 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 115 | "beneficiaryAmount":str(ba2),"deductFeeFrom":"0"} |
---|
| 116 | ) |
---|
| 117 | return lineitems |
---|
[14751] | 118 | |
---|
[14767] | 119 | def dynamic_provider_amt(self, student): |
---|
| 120 | if student.entry_session >= 2016: |
---|
| 121 | return 2500.0 |
---|
| 122 | return 1500.0 |
---|
| 123 | |
---|
| 124 | @property |
---|
[14795] | 125 | def lineitems(self): |
---|
[14767] | 126 | provider_amt = 0.0 |
---|
| 127 | if self.context.p_category == 'schoolfee' and \ |
---|
| 128 | not self.context.p_item == 'Balance': |
---|
[14770] | 129 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
[14767] | 130 | elif self.context.p_category == 'clearance': |
---|
[14770] | 131 | provider_amt = self.dynamic_provider_amt(self.context.student) |
---|
[14767] | 132 | inst_amt = self.context.amount_auth - provider_amt |
---|
[14876] | 133 | if self.context.student.faccode == 'JUPEB': |
---|
[14872] | 134 | inst_acct = "0040217361038" |
---|
| 135 | else: |
---|
| 136 | inst_acct = "0040217361011" |
---|
[14767] | 137 | if provider_amt: |
---|
| 138 | lineitems = ( |
---|
| 139 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
[14872] | 140 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
[14767] | 141 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 142 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
| 143 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 144 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
| 145 | ) |
---|
| 146 | else: |
---|
| 147 | lineitems = ( |
---|
| 148 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
[14872] | 149 | "beneficiaryAccount":inst_acct,"bankCode":"000", |
---|
[14767] | 150 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 151 | ) |
---|
| 152 | return lineitems |
---|
| 153 | |
---|
[14746] | 154 | def update(self): |
---|
| 155 | if not module_activated(self.context.student.current_session): |
---|
| 156 | return |
---|
[14778] | 157 | self.orderId = self.context.p_id |
---|
| 158 | self.amount = str(self.context.amount_auth) |
---|
[14746] | 159 | error = self.init_update() |
---|
| 160 | if error: |
---|
| 161 | self.flash(error, type='danger') |
---|
| 162 | self.redirect(self.url(self.context, '@@index')) |
---|
| 163 | return |
---|
[14767] | 164 | return |
---|
| 165 | |
---|
| 166 | class CustomRemitaRequestPaymentStatusPageApplicant( |
---|
| 167 | RemitaRequestPaymentStatusPageApplicant): |
---|
| 168 | """ Request webservice view for the Remita gateway. |
---|
| 169 | """ |
---|
| 170 | |
---|
[14792] | 171 | merchantId = MERCHANTID |
---|
| 172 | host = HOST |
---|
| 173 | https = HTTPS |
---|
| 174 | api_key = API_KEY |
---|
[14767] | 175 | |
---|
[14792] | 176 | class CustomRemitaVerifyPaymentStatusPageApplicant( |
---|
| 177 | RemitaVerifyPaymentStatusPageApplicant): |
---|
| 178 | """ Request webservice view for the Remita gateway. |
---|
| 179 | """ |
---|
| 180 | |
---|
| 181 | merchantId = MERCHANTID |
---|
| 182 | host = HOST |
---|
| 183 | https = HTTPS |
---|
| 184 | api_key = API_KEY |
---|
| 185 | |
---|
[14767] | 186 | class CustomRemitaPageApplicant(RemitaPageApplicant): |
---|
| 187 | """ View which sends a POST request to the Remita payment gateway. |
---|
| 188 | """ |
---|
| 189 | |
---|
[14792] | 190 | merchantId = MERCHANTID |
---|
| 191 | host = HOST |
---|
| 192 | https = HTTPS |
---|
| 193 | api_key = API_KEY |
---|
| 194 | |
---|
[14767] | 195 | init_url = '/remita/ecomm/split/init.reg' |
---|
| 196 | |
---|
[14776] | 197 | @property |
---|
[14795] | 198 | def serviceTypeId(self): |
---|
[14799] | 199 | applicant = self.context.__parent__ |
---|
[14800] | 200 | if applicant.__parent__.prefix.startswith('dp'): |
---|
[14813] | 201 | return '2066963437' |
---|
[14832] | 202 | if applicant.__parent__.prefix in ('spft', ): |
---|
[14813] | 203 | return '2067086388' |
---|
[14800] | 204 | if applicant.__parent__.prefix == 'pre': |
---|
[14813] | 205 | return '1946882248' |
---|
[14800] | 206 | if applicant.__parent__.prefix in ('pude','putme','cbt', |
---|
[14825] | 207 | 'ab','ak','akj','ase'): |
---|
[14813] | 208 | return '2066965951' |
---|
[14799] | 209 | return '' |
---|
[14795] | 210 | |
---|
| 211 | @property |
---|
[14800] | 212 | def demo_lineitems(self): |
---|
| 213 | lineitems = ( |
---|
[14776] | 214 | {"lineItemsId":"itemid1","beneficiaryName":"Klaus Mueller", |
---|
| 215 | "beneficiaryAccount":"6020067886","bankCode":"011", |
---|
| 216 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"1"}, |
---|
| 217 | {"lineItemsId":"itemid2","beneficiaryName":"Werner Rumm", |
---|
| 218 | "beneficiaryAccount":"0360883515","bankCode":"050", |
---|
| 219 | "beneficiaryAmount":self.context.amount_auth/2,"deductFeeFrom":"0"} |
---|
| 220 | ) |
---|
| 221 | return lineitems |
---|
[14770] | 222 | |
---|
[14767] | 223 | @property |
---|
[14799] | 224 | def lineitems(self): |
---|
[14826] | 225 | provider_amt = 1000.0 |
---|
[14813] | 226 | #if self.context.__parent__.applicant_id.startswith('cbt'): |
---|
| 227 | # provider_amt = 200.0 |
---|
[14770] | 228 | inst_amt = self.context.amount_auth - provider_amt |
---|
[14767] | 229 | lineitems = ( |
---|
[14770] | 230 | {"lineItemsId":"itemid1","beneficiaryName":"Uniben", |
---|
| 231 | "beneficiaryAccount":"0040217361011","bankCode":"000", |
---|
| 232 | "beneficiaryAmount":inst_amt,"deductFeeFrom":"1"}, |
---|
| 233 | {"lineItemsId":"itemid2","beneficiaryName":"WAeAC", |
---|
| 234 | "beneficiaryAccount":"1014261520","bankCode":"057", |
---|
| 235 | "beneficiaryAmount":provider_amt,"deductFeeFrom":"0"} |
---|
[14767] | 236 | ) |
---|
| 237 | return lineitems |
---|
| 238 | |
---|
| 239 | def update(self): |
---|
| 240 | if not module_activated(self.context.__parent__.__parent__.year): |
---|
| 241 | return |
---|
[14778] | 242 | self.orderId = self.context.p_id |
---|
| 243 | self.amount = str(self.context.amount_auth) |
---|
[14767] | 244 | error = self.init_update() |
---|
| 245 | if error: |
---|
| 246 | self.flash(error, type='danger') |
---|
| 247 | self.redirect(self.url(self.context, '@@index')) |
---|
| 248 | return |
---|
[14746] | 249 | return |
---|