Changeset 7919
- Timestamp:
- 19 Mar 2012, 07:01:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py
r7898 r7919 107 107 'redirectURL':site_redirect_url} 108 108 return QUERY_URL + '?%s' % urllib.urlencode(args) 109 110 # Alternative preferred solution 111 class InterswitchRequestWebserviceActionButton(RequestCallbackActionButton): 112 grok.order(4) 113 icon = 'actionicon_call.png' 114 text = _('Request CollegePAY webservice') 115 target = 'request_webservice' 116 109 117 110 118 class InterswitchPage(KofaPage): … … 183 191 query = self.request.form 184 192 # Should be logged instead of printed 185 print query193 write_log_message(self,'callback received: %s' % query) 186 194 if query.get('resp', None) != '00': 187 195 self.flash(_('Unsuccessful callback: ${a}', 188 196 mapping = {'a': query.get('desc', _('Incomplete query string.'))})) 189 write_log_message(self,' invalidcallback: %s' % self.context.p_id)197 write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 190 198 self.context.r_card_num = query.get('cardNum', None) 191 199 self.context.r_code = query.get('resp', None) … … 195 203 if query.get('apprAmt', None) != str(self.context.amount_auth): 196 204 self.flash(_('Wrong amount')) 197 write_log_message(self,' wrong amount: %s' % self.context.p_id)205 write_log_message(self,'successful but wrong amount: %s' % self.context.p_id) 198 206 self.context.r_card_num = query.get('cardNum', None) 199 207 self.context.r_code = query.get('resp', None) … … 247 255 self.redirect(self.url(self.context, '@@index')) 248 256 return 257 258 # Alternative solution, replaces OnlinePaymentCallbackPage 259 class OnlinePaymentRequestWebservicePage(UtilityView, grok.View): 260 """ Request webservice view for the CollegePAY gateway 261 """ 262 grok.context(IStudentOnlinePayment) 263 grok.name('request_webservice') 264 grok.require('waeup.payStudent') 265 266 def update(self): 267 if self.context.p_state == 'paid': 268 self.flash(_('This ticket has already been paid.')) 269 return 270 student = self.context.getStudent() 271 sr = get_SOAP_response(PRODUCT_ID, self.context.p_id) 272 write_log_message(self,'callback received: %s' % sr) 273 wlist = sr.split(':') 274 if len(wlist) != 7: 275 self.flash(_('Invalid callback: ${a}', 276 mapping = {'a': wlist})) 277 write_log_message(self,'invalid callback: %s' % self.context.p_id) 278 return 279 self.context.r_code = wlist[0] 280 self.context.r_desc = wlist[1] 281 self.context.r_amount_approved = int(wlist[2]) 282 self.context.r_card_num = wlist[3] 283 self.context.r_pay_reference = wlist[5] 284 285 if wlist[0] != '00': 286 self.flash(_('Unsuccessful callback: ${a}', 287 mapping = {'a': wlist[1]})) 288 write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 289 self.context.p_state = 'failed' 290 return 291 292 if wlist[2] != str(self.context.amount_auth): 293 self.flash(_('Wrong amount')) 294 write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id) 295 self.context.p_state = 'failed' 296 return 297 298 if wlist[5] != self.context.p_id: 299 self.flash(_('Wrong transaction id')) 300 write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id) 301 self.context.p_state = 'failed' 302 return 303 304 write_log_message(self,'successful callback: %s' % self.context.p_id) 305 306 self.context.p_state = 'paid' 307 self.context.payment_date = datetime.now() 308 309 if self.context.p_category == 'clearance': 310 # Create CLR access code 311 pin, error = create_accesscode('CLR',0,student.student_id) 312 if error: 313 self.flash(_('Valid callback received. ${a}', 314 mapping = {'a':error})) 315 return 316 self.context.ac = pin 317 elif self.context.p_category == 'schoolfee': 318 # Create SFE access code 319 pin, error = create_accesscode('SFE',0,student.student_id) 320 if error: 321 self.flash(_('Valid callback received. ${a}', 322 mapping = {'a':error})) 323 return 324 self.context.ac = pin 325 elif self.context.p_category == 'bed_allocation': 326 # Create HOS access code 327 pin, error = create_accesscode('HOS',0,student.student_id) 328 if error: 329 self.flash(_('Valid callback received. ${a}', 330 mapping = {'a':error})) 331 return 332 self.context.ac = pin 333 self.flash(_('Valid callback received.')) 334 return 335 336 def render(self): 337 self.redirect(self.url(self.context, '@@index')) 338 return
Note: See TracChangeset for help on using the changeset viewer.