[10765] | 1 | ## $Id: browser.py 15214 2018-11-02 07:06:07Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2012 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 | import httplib |
---|
[12479] | 19 | import hashlib |
---|
[10765] | 20 | import grok |
---|
| 21 | from kofacustom.nigeria.interswitch.browser import ( |
---|
| 22 | InterswitchPaymentRequestWebservicePageApplicant, |
---|
[11638] | 23 | InterswitchPaymentRequestWebservicePageStudent, |
---|
[13587] | 24 | InterswitchPaymentVerifyWebservicePageApplicant, |
---|
| 25 | InterswitchPaymentVerifyWebservicePageStudent, |
---|
[11638] | 26 | InterswitchPageStudent, InterswitchPageApplicant, |
---|
[10765] | 27 | ) |
---|
[14716] | 28 | from kofacustom.dspg.students.interfaces import ICustomStudentOnlinePayment |
---|
| 29 | from kofacustom.dspg.applicants.interfaces import ICustomApplicantOnlinePayment |
---|
| 30 | from kofacustom.dspg.interfaces import MessageFactory as _ |
---|
[10765] | 31 | |
---|
[14726] | 32 | PRODUCT_ID = '7269' # must be provided by Interswitch |
---|
[14749] | 33 | SITE_NAME = 'dspg.waeup.org' |
---|
[14879] | 34 | PROVIDER_ACCT = '2028964403' |
---|
| 35 | PROVIDER_BANK_ID = '8' |
---|
[10765] | 36 | PROVIDER_ITEM_NAME = 'BT Education' |
---|
[14722] | 37 | INSTITUTION_NAME = 'Delta State Polytechnic Ogwashi-Uku' |
---|
[10765] | 38 | CURRENCY = '566' |
---|
[14727] | 39 | GATEWAY_AMT = 250.0 |
---|
[15021] | 40 | MAC = 'D43ED93B7A307B152C7111D04E1F384428057CD1E75428D3A4C5631C28ACB9C8C822A88CA76DEDC5F9A520CF4BFDB2824FF8B207AAFC667DF3CBB13685B66627' |
---|
[10765] | 41 | |
---|
[14726] | 42 | POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay' |
---|
| 43 | #POST_ACTION = 'https://sandbox.interswitchng.com/webpay/pay' |
---|
| 44 | HOST = 'webpay.interswitchng.com' |
---|
| 45 | #HOST = 'sandbox.interswitchng.com' |
---|
| 46 | URL = '/paydirect/api/v1/gettransaction.json' |
---|
| 47 | #URL = '/webpay/api/v1/gettransaction.json' |
---|
[14276] | 48 | |
---|
[12479] | 49 | httplib.HTTPSConnection.debuglevel = 0 |
---|
| 50 | HTTPS = True |
---|
[10765] | 51 | |
---|
[14859] | 52 | SPECIAL_PAYMENT_PARAMS = { |
---|
[14864] | 53 | |
---|
| 54 | 'carryover1': ('101', 500.0, '1012808851', '117'), |
---|
[15195] | 55 | 'carryover4': ('101', 500.0, '1012808851', '117'), |
---|
[14864] | 56 | 'carryover5': ('101', 500.0, '1012808851', '117'), |
---|
| 57 | 'carryover6': ('101', 500.0, '1012808851', '117'), |
---|
| 58 | 'carryover7': ('101', 500.0, '1012808851', '117'), |
---|
| 59 | 'carryover8': ('101', 500.0, '1012808851', '117'), |
---|
| 60 | 'carryover9': ('101', 500.0, '1012808851', '117'), |
---|
| 61 | 'carryover10': ('101', 500.0, '1012808851', '117'), |
---|
[14868] | 62 | 'carryover11': ('101', 500.0, '1012808851', '117'), |
---|
| 63 | 'carryover12': ('101', 500.0, '1012808851', '117'), |
---|
[14869] | 64 | 'balance': ('101', 500.0, '1012808851', '117'), |
---|
[14864] | 65 | |
---|
[14859] | 66 | 'certificate': ('111', 500.0, '1012808851', '117'), |
---|
| 67 | 'state_result': ('112', 500.0, '1012808851', '117'), |
---|
| 68 | 'transcript_local': ('113', 500.0, '1012808851', '117'), |
---|
| 69 | 'transcript_foreign': ('114', 500.0, '1012808851', '117'), |
---|
| 70 | 'ver_result': ('115', 500.0, '1012808851', '117'), |
---|
| 71 | 'change_course': ('116', 500.0, '1012808851', '117'), |
---|
| 72 | 'change_inst': ('117', 500.0, '1012808851', '117'), |
---|
| 73 | 'jamb_reject': ('118', 500.0, '1012808851', '117'), |
---|
| 74 | 'cert_of_cert': ('119', 500.0, '1012808851', '117'), |
---|
| 75 | 'ref_let': ('120', 500.0, '1012808851', '117'), |
---|
| 76 | 'proc_cert': ('121', 500.0, '1012808851', '117'), |
---|
| 77 | 'loss_idcard': ('122', 9.0, '1012808851', '117'), |
---|
| 78 | 'loss_examcard': ('123', 4.5, '1012808851', '117'), |
---|
| 79 | 'loss_result': ('124', 500.0, '1012808851', '117'), |
---|
| 80 | 'loss_receipt': ('125', 500.0, '1012808851', '117'), |
---|
| 81 | 'loss_clearance': ('126', 500.0, '1012808851', '117'), |
---|
| 82 | 'conv_brochure': ('127', 500.0, '1012808851', '117'), |
---|
| 83 | 'hnd_certificate': ('128', 500.0, '1012808851', '117'), |
---|
| 84 | 'hnd_state_result': ('129', 500.0, '1012808851', '117'), |
---|
| 85 | 'hnd_transcript_local': ('130', 500.0, '1012808851', '117'), |
---|
| 86 | 'hnd_transcript_foreign': ('131', 500.0, '1012808851', '117'), |
---|
| 87 | 'staff_loss_idcard': ('132', 9.0, '1012808851', '117'), |
---|
| 88 | 'hnd_conv_brochure': ('133', 500.0, '1012808851', '117'), |
---|
| 89 | 'pgd_state_result': ('134', 500.0, '1012808851', '117'), |
---|
| 90 | 'pgd_conv_brochure': ('135', 500.0, '1012808851', '117'), |
---|
| 91 | 'pgd_certificate': ('136', 500.0, '1012808851', '117'), |
---|
| 92 | 'log_book': ('137', 4.5, '1012808851', '117'), |
---|
| 93 | 'pgd_transcript_foreign': ('138', 500.0, '1012808851', '117'), |
---|
| 94 | 'pgd_transcript_local': ('139', 500.0, '1012808851', '117'), |
---|
| 95 | 'jamb_regularization': ('140', 500.0, '1012808851', '117'), |
---|
| 96 | 'utme_registration': ('142', 9.0, '1012808851', '117'), |
---|
| 97 | 'utme_cbt': ('143', 9.0, '1012808851', '117'), |
---|
| 98 | 'nysc_id_card': ('144', 9.0, '1012808851', '117'), |
---|
| 99 | 'ijmb_result': ('147', 500.0, '1012808851', '117'), |
---|
| 100 | } |
---|
| 101 | |
---|
[14862] | 102 | |
---|
[14875] | 103 | # Not yet readily configured. Bank account numbers are |
---|
[14862] | 104 | # contradictory. pay_item_ids are not yet assigned. |
---|
| 105 | |
---|
[11638] | 106 | class CustomInterswitchPageStudent(InterswitchPageStudent): |
---|
[10765] | 107 | """ View which sends a POST request to the Interswitch |
---|
| 108 | CollegePAY payment gateway. |
---|
| 109 | """ |
---|
| 110 | grok.context(ICustomStudentOnlinePayment) |
---|
| 111 | action = POST_ACTION |
---|
| 112 | site_name = SITE_NAME |
---|
| 113 | currency = CURRENCY |
---|
| 114 | product_id = PRODUCT_ID |
---|
[15021] | 115 | mac = MAC |
---|
[14875] | 116 | pay_item_id = '000' |
---|
[10765] | 117 | |
---|
| 118 | def update(self): |
---|
[12979] | 119 | error = self.init_update() |
---|
| 120 | if error: |
---|
| 121 | self.flash(error, type='danger') |
---|
| 122 | self.redirect(self.url(self.context, '@@index')) |
---|
| 123 | return |
---|
[11647] | 124 | student = self.student |
---|
| 125 | xmldict = self.xmldict |
---|
[10765] | 126 | # Provider data |
---|
| 127 | xmldict['detail_ref'] = self.context.p_id |
---|
| 128 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 129 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 130 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
| 131 | # Institution data |
---|
[14875] | 132 | xmldict['institution_acct'] = '00000000' |
---|
| 133 | xmldict['institution_bank_id'] = '00' |
---|
[10765] | 134 | xmldict['institution_amt'] = '0.0' |
---|
[14875] | 135 | provider_amt = 0.0 |
---|
[14961] | 136 | tech_fee = 0.0 |
---|
[14862] | 137 | if self.context.p_category.startswith('schoolfee'): |
---|
| 138 | self.pay_item_id = '102' |
---|
[14875] | 139 | provider_amt = 2800.0 |
---|
[14961] | 140 | tech_fee = 1200.0 |
---|
[14889] | 141 | if student.faccode == 'SPAT': |
---|
[15214] | 142 | xmldict['institution_acct'] = '1015220292' |
---|
[14875] | 143 | xmldict['institution_bank_id'] = '117' |
---|
[14889] | 144 | elif student.current_mode in ('nd_ft', 'hnd_ft'): |
---|
[15214] | 145 | xmldict['institution_acct'] = '1012808851' |
---|
[15202] | 146 | xmldict['institution_bank_id'] = '117' |
---|
[14862] | 147 | elif self.context.p_category == 'clearance': |
---|
| 148 | self.pay_item_id = '103' |
---|
[14875] | 149 | provider_amt = 500.0 |
---|
[14889] | 150 | if student.faccode == 'SPAT': |
---|
| 151 | xmldict['institution_acct'] = '1012808851' |
---|
[14875] | 152 | xmldict['institution_bank_id'] = '117' |
---|
[15179] | 153 | elif student.current_mode in ('nd_ft', 'hnd_ft'): |
---|
| 154 | xmldict['institution_acct'] = '5210039869' |
---|
| 155 | xmldict['institution_bank_id'] = '51' |
---|
[14942] | 156 | elif self.context.p_category == 'gown': |
---|
| 157 | self.pay_item_id = '102' # We use school fee item id. |
---|
| 158 | xmldict['institution_acct'] = '2006612782' |
---|
| 159 | xmldict['institution_bank_id'] = '8' |
---|
[15021] | 160 | elif self.context.p_category == 'sports': |
---|
| 161 | self.pay_item_id = '110' |
---|
| 162 | xmldict['institution_acct'] = '6060300688' |
---|
| 163 | xmldict['institution_bank_id'] = '51' |
---|
| 164 | elif self.context.p_category == 'siwes': |
---|
| 165 | self.pay_item_id = '111' |
---|
| 166 | xmldict['institution_acct'] = '1001174679' |
---|
| 167 | xmldict['institution_bank_id'] = '123' |
---|
[15022] | 168 | elif self.context.p_category == 'eed_1': |
---|
[15021] | 169 | self.pay_item_id = '112' |
---|
| 170 | xmldict['institution_acct'] = '0039782431' |
---|
| 171 | xmldict['institution_bank_id'] = '11' |
---|
[15022] | 172 | elif self.context.p_category == 'eed_2': |
---|
| 173 | self.pay_item_id = '116' |
---|
| 174 | xmldict['institution_acct'] = '0039782431' |
---|
| 175 | xmldict['institution_bank_id'] = '11' |
---|
| 176 | elif self.context.p_category == 'olevel_results_1': |
---|
[15021] | 177 | self.pay_item_id = '113' |
---|
| 178 | xmldict['institution_acct'] = '2015327204' |
---|
| 179 | xmldict['institution_bank_id'] = '8' |
---|
[15022] | 180 | elif self.context.p_category == 'olevel_results_2': |
---|
| 181 | self.pay_item_id = '115' |
---|
| 182 | xmldict['institution_acct'] = '2015327204' |
---|
| 183 | xmldict['institution_bank_id'] = '8' |
---|
[14862] | 184 | elif self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys(): |
---|
| 185 | self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0] |
---|
| 186 | provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1] |
---|
| 187 | xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2] |
---|
| 188 | xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3] |
---|
[10765] | 189 | xmldict['provider_amt'] = 100 * provider_amt |
---|
[14961] | 190 | xmldict['tech_fee'] = 100 * tech_fee |
---|
[12511] | 191 | xmldict['institution_item_name'] = self.context.category |
---|
[10765] | 192 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
[14889] | 193 | xmldict['institution_amt'] = institution_amt = 100 * ( |
---|
[14961] | 194 | self.context.amount_auth - provider_amt - tech_fee - GATEWAY_AMT) |
---|
| 195 | |
---|
[10765] | 196 | if provider_amt == 0: |
---|
| 197 | xmltext = """<payment_item_detail> |
---|
| 198 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 199 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 200 | </item_details> |
---|
| 201 | </payment_item_detail>""" % xmldict |
---|
[14961] | 202 | elif tech_fee == 0: |
---|
| 203 | xmltext = """<payment_item_detail> |
---|
| 204 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 205 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 206 | <item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 207 | </item_details> |
---|
| 208 | </payment_item_detail>""" % xmldict |
---|
[10765] | 209 | else: |
---|
| 210 | xmltext = """<payment_item_detail> |
---|
| 211 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 212 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 213 | <item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
[14962] | 214 | <item_detail item_id="3" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="307" acct_num="5100189030" /> |
---|
[10765] | 215 | </item_details> |
---|
| 216 | </payment_item_detail>""" % xmldict |
---|
[14889] | 217 | |
---|
| 218 | # isouaba: All certificates in SPAT are part time thus any payments |
---|
| 219 | # coming from those certificates (Application, Acceptance, school fees |
---|
| 220 | # etc) 40% should be split to keystone account. |
---|
| 221 | if student.faccode == 'SPAT': |
---|
| 222 | xmldict['institution_amt_2'] = 0.4 * institution_amt |
---|
| 223 | xmldict['institution_amt_1'] = 0.6 * institution_amt |
---|
| 224 | if provider_amt == 0: |
---|
| 225 | xmltext = """<payment_item_detail> |
---|
| 226 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 227 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 228 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 229 | </item_details> |
---|
| 230 | </payment_item_detail>""" % xmldict |
---|
[14964] | 231 | elif tech_fee == 0: |
---|
| 232 | xmltext = """<payment_item_detail> |
---|
| 233 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 234 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 235 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 236 | <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 237 | </item_details> |
---|
| 238 | </payment_item_detail>""" % xmldict |
---|
[14889] | 239 | else: |
---|
| 240 | xmltext = """<payment_item_detail> |
---|
| 241 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 242 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 243 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 244 | <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
[14964] | 245 | <item_detail item_id="4" item_name="Technology Fee" item_amt="%(tech_fee)d" bank_id="307" acct_num="5100189030" /> |
---|
[14889] | 246 | </item_details> |
---|
| 247 | </payment_item_detail>""" % xmldict |
---|
[14921] | 248 | # dep_sug payments are treated completely separately. The following lines |
---|
| 249 | # override the configuration above. |
---|
| 250 | if self.context.p_category == 'dep_sug': |
---|
| 251 | self.pay_item_id = '102' # We use school fee item id |
---|
| 252 | # amount_auth is being ignored. However, the sum of all split payments |
---|
| 253 | # must coincide with the amount_auth configured in students/utils.py |
---|
[14938] | 254 | xmldict['amt1'] = 100 * 1000 |
---|
[14921] | 255 | xmldict['amt2'] = 100 * 500 |
---|
| 256 | xmldict['amt3'] = 100 * 900 |
---|
| 257 | xmldict['amt4'] = 100 * 500 |
---|
[14938] | 258 | |
---|
[14940] | 259 | xmltext = """<payment_item_detail> |
---|
[14921] | 260 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 261 | <item_detail item_id="1" item_name="SUG" item_amt="%(amt1)d" bank_id="11" acct_num="0038079930" /> |
---|
| 262 | <item_detail item_id="2" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" /> |
---|
| 263 | <item_detail item_id="3" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" /> |
---|
[14938] | 264 | <item_detail item_id="4" item_name="NADESSTU" item_amt="%(amt4)d" bank_id="11" acct_num="0036375968" /> |
---|
[14921] | 265 | </item_details> |
---|
| 266 | </payment_item_detail>""" % xmldict |
---|
[14940] | 267 | |
---|
| 268 | # if student.faccode == 'SPAT': |
---|
| 269 | # xmltext = """<payment_item_detail> |
---|
| 270 | #<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s"> |
---|
| 271 | #<item_detail item_id="1" item_name="Students Welfare" item_amt="%(amt2)d" bank_id="11" acct_num="0037892949" /> |
---|
| 272 | #<item_detail item_id="2" item_name="Anti-Cult Book" item_amt="%(amt3)d" bank_id="11" acct_num="0037892949" /> |
---|
| 273 | #</item_details> |
---|
| 274 | #</payment_item_detail>""" % xmldict |
---|
| 275 | |
---|
[10765] | 276 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 277 | self.context.provider_amt = provider_amt |
---|
| 278 | self.context.gateway_amt = GATEWAY_AMT |
---|
[12479] | 279 | hashargs = ( |
---|
| 280 | self.context.p_id + |
---|
| 281 | PRODUCT_ID + |
---|
| 282 | self.pay_item_id + |
---|
| 283 | str(int(self.amount_auth)) + |
---|
| 284 | self.site_redirect_url + |
---|
| 285 | self.mac) |
---|
| 286 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
[10765] | 287 | return |
---|
| 288 | |
---|
[11638] | 289 | class CustomInterswitchPageApplicant(InterswitchPageApplicant): |
---|
[10765] | 290 | """ View which sends a POST request to the Interswitch |
---|
| 291 | CollegePAY payment gateway. |
---|
| 292 | """ |
---|
| 293 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 294 | action = POST_ACTION |
---|
| 295 | site_name = SITE_NAME |
---|
| 296 | currency = CURRENCY |
---|
[14729] | 297 | pay_item_id = '101' # must be provided by Interswitch |
---|
[10765] | 298 | product_id = PRODUCT_ID |
---|
[15021] | 299 | mac = MAC |
---|
[10765] | 300 | |
---|
| 301 | def update(self): |
---|
[12979] | 302 | error = self.init_update() |
---|
| 303 | if error: |
---|
| 304 | self.flash(error, type='danger') |
---|
| 305 | self.redirect(self.url(self.context, '@@index')) |
---|
| 306 | return |
---|
[10765] | 307 | xmldict = {} |
---|
[14731] | 308 | provider_amt = 500.0 |
---|
[14859] | 309 | gateway_amt = GATEWAY_AMT |
---|
[15075] | 310 | xmldict['institution_acct'] = '00000000' |
---|
| 311 | xmldict['institution_bank_id'] = '00' |
---|
| 312 | if self.applicant.__parent__.application_category in ('ndft', 'hndft'): |
---|
[15098] | 313 | xmldict['institution_acct'] = '5210039869' |
---|
| 314 | xmldict['institution_bank_id'] = '51' |
---|
[15075] | 315 | elif self.applicant.__parent__.application_category in ( |
---|
| 316 | 'ndpt', 'hndpt', 'ndwe', 'hndwe'): |
---|
[15098] | 317 | xmldict['institution_acct'] = '1015220292' |
---|
| 318 | xmldict['institution_bank_id'] = '117' |
---|
[15075] | 319 | elif self.applicant.applicant_id.startswith('special'): |
---|
[14859] | 320 | if self.context.p_category in SPECIAL_PAYMENT_PARAMS.keys(): |
---|
| 321 | self.pay_item_id = SPECIAL_PAYMENT_PARAMS[self.context.p_category][0] |
---|
| 322 | provider_amt = SPECIAL_PAYMENT_PARAMS[self.context.p_category][1] |
---|
| 323 | xmldict['institution_acct'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][2] |
---|
| 324 | xmldict['institution_bank_id'] = SPECIAL_PAYMENT_PARAMS[self.context.p_category][3] |
---|
| 325 | if self.pay_item_id in ('122', '123', '132', '137', '141', |
---|
| 326 | '142', '143', '144', '146', '147',): |
---|
| 327 | gateway_amt = round(0.015 * self.context.amount_auth, 2) |
---|
[10765] | 328 | xmldict['detail_ref'] = self.context.p_id |
---|
| 329 | xmldict['provider_amt'] = 100 * provider_amt |
---|
| 330 | xmldict['provider_acct'] = PROVIDER_ACCT |
---|
| 331 | xmldict['provider_bank_id'] = PROVIDER_BANK_ID |
---|
| 332 | xmldict['provider_item_name'] = PROVIDER_ITEM_NAME |
---|
[14889] | 333 | xmldict['institution_amt'] = institution_amt = 100 * ( |
---|
| 334 | self.context.amount_auth - provider_amt - gateway_amt) |
---|
[12511] | 335 | xmldict['institution_item_name'] = self.context.category |
---|
[10765] | 336 | xmldict['institution_name'] = INSTITUTION_NAME |
---|
| 337 | xmltext = """<payment_item_detail> |
---|
| 338 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 339 | <item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 340 | <item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 341 | </item_details> |
---|
| 342 | </payment_item_detail>""" % xmldict |
---|
[14889] | 343 | |
---|
| 344 | # isouaba: All certificates in SPAT are part time thus any payments |
---|
| 345 | # coming from those certificates (Application, Acceptance, school fees |
---|
| 346 | # etc) 40% should be split to keystone account. |
---|
| 347 | if self.applicant.__parent__.application_category in ( |
---|
| 348 | 'ndpt', 'hndpt', 'ndwe', 'hndwe'): |
---|
| 349 | xmldict['institution_amt_2'] = 0.4 * institution_amt |
---|
| 350 | xmldict['institution_amt_1'] = 0.6 * institution_amt |
---|
| 351 | xmltext = """<payment_item_detail> |
---|
| 352 | <item_details detail_ref="%(detail_ref)s" college="%(institution_name)s"> |
---|
| 353 | <item_detail item_id="1" item_name="%(institution_item_name)s 1" item_amt="%(institution_amt_1)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" /> |
---|
| 354 | <item_detail item_id="2" item_name="%(institution_item_name)s 2" item_amt="%(institution_amt_2)d" bank_id="123" acct_num="1002883141" /> |
---|
| 355 | <item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" /> |
---|
| 356 | </item_details> |
---|
| 357 | </payment_item_detail>""" % xmldict |
---|
| 358 | |
---|
[10765] | 359 | self.xml_data = """<input type="hidden" name="xml_data" value='%s' />""" % xmltext |
---|
| 360 | self.context.provider_amt = provider_amt |
---|
| 361 | self.context.gateway_amt = GATEWAY_AMT |
---|
[12479] | 362 | |
---|
| 363 | hashargs = ( |
---|
| 364 | self.context.p_id + |
---|
| 365 | PRODUCT_ID + |
---|
| 366 | self.pay_item_id + |
---|
| 367 | str(int(self.amount_auth)) + |
---|
| 368 | self.site_redirect_url + |
---|
| 369 | self.mac) |
---|
| 370 | self.hashvalue = hashlib.sha512(hashargs).hexdigest() |
---|
[10765] | 371 | return |
---|
| 372 | |
---|
[11638] | 373 | class CustomInterswitchPaymentRequestWebservicePageStudent( |
---|
[10765] | 374 | InterswitchPaymentRequestWebservicePageStudent): |
---|
[13587] | 375 | """Request webservice view for the CollegePAY gateway |
---|
[10765] | 376 | """ |
---|
| 377 | grok.context(ICustomStudentOnlinePayment) |
---|
| 378 | product_id = PRODUCT_ID |
---|
| 379 | gateway_host = HOST |
---|
| 380 | gateway_url = URL |
---|
[15021] | 381 | mac = MAC |
---|
[10765] | 382 | |
---|
[13587] | 383 | class CustomInterswitchPaymentVerifyWebservicePageStudent( |
---|
| 384 | InterswitchPaymentVerifyWebservicePageStudent): |
---|
| 385 | """Payment verify view for the CollegePAY gateway |
---|
| 386 | """ |
---|
| 387 | grok.context(ICustomStudentOnlinePayment) |
---|
| 388 | product_id = PRODUCT_ID |
---|
| 389 | gateway_host = HOST |
---|
| 390 | gateway_url = URL |
---|
[15021] | 391 | mac = MAC |
---|
[13587] | 392 | |
---|
[11638] | 393 | class CustomInterswitchPaymentRequestWebservicePageApplicant( |
---|
[10765] | 394 | InterswitchPaymentRequestWebservicePageApplicant): |
---|
[13587] | 395 | """Request webservice view for the CollegePAY gateway |
---|
[10765] | 396 | """ |
---|
| 397 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 398 | product_id = PRODUCT_ID |
---|
| 399 | gateway_host = HOST |
---|
[12479] | 400 | gateway_url = URL |
---|
[15021] | 401 | mac = MAC |
---|
[13587] | 402 | |
---|
| 403 | class CustomInterswitchPaymentVerifyWebservicePageApplicant( |
---|
| 404 | InterswitchPaymentVerifyWebservicePageApplicant): |
---|
| 405 | """Payment verify view for the CollegePAY gateway |
---|
| 406 | """ |
---|
| 407 | grok.context(ICustomApplicantOnlinePayment) |
---|
| 408 | product_id = PRODUCT_ID |
---|
| 409 | gateway_host = HOST |
---|
[14722] | 410 | gateway_url = URL |
---|
[15021] | 411 | mac = MAC |
---|