Changeset 9782 for main/waeup.uniben/trunk/src/waeup
- Timestamp:
- 7 Dec 2012, 08:23:58 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py
r9775 r9782 21 21 from kofacustom.nigeria.interswitch.helpers import ( 22 22 query_interswitch, write_payments_log) 23 from kofacustom.nigeria.interswitch.browser import ( 24 InterswitchPaymentRequestWebservicePageApplicant, 25 InterswitchPaymentRequestWebservicePageStudent 26 ) 23 27 from waeup.kofa.browser.layout import KofaPage, UtilityView 24 28 from waeup.kofa.interfaces import IKofaUtils … … 48 52 #URL = '/test_paydirect/services/TransactionQueryWs.asmx' 49 53 httplib.HTTPConnection.debuglevel = 0 50 51 class InterswitchActionButtonStudent(APABStudent):52 grok.order(1)53 grok.context(ICustomStudentOnlinePayment)54 grok.require('waeup.payStudent')55 icon = 'actionicon_pay.png'56 text = _('CollegePAY')57 target = 'goto_interswitch'58 59 @property60 def target_url(self):61 if self.context.p_state != 'unpaid':62 return ''63 return self.view.url(self.view.context, self.target)64 65 class InterswitchActionButtonApplicant(APABApplicant):66 grok.order(1)67 grok.context(ICustomApplicantOnlinePayment)68 grok.require('waeup.payApplicant')69 icon = 'actionicon_pay.png'70 text = _('CollegePAY')71 target = 'goto_interswitch'72 73 @property74 def target_url(self):75 if self.context.p_state != 'unpaid':76 return ''77 return self.view.url(self.view.context, self.target)78 79 # Deprecated80 #class InterswitchRequestCallbackActionButtonStudent(RCABStudent):81 # grok.order(3)82 # grok.context(ICustomStudentOnlinePayment)83 # icon = 'actionicon_call.png'84 # text = _('Request CollegePAY callback')85 86 # def target_url(self):87 # if self.context.p_state == 'paid':88 # return ''89 # site_redirect_url = self.view.url(self.view.context, 'isw_callback')90 # args = {91 # 'transRef':self.context.p_id,92 # 'prodID':PRODUCT_ID,93 # 'redirectURL':site_redirect_url}94 # return QUERY_URL + '?%s' % urllib.urlencode(args)95 96 # Alternative preferred solution97 class InterswitchRequestWebserviceActionButtonStudent(APABStudent):98 grok.order(2)99 grok.context(ICustomStudentOnlinePayment)100 grok.require('waeup.payStudent')101 icon = 'actionicon_call.png'102 text = _('Requery CollegePAY')103 target = 'request_webservice'104 105 class InterswitchRequestWebserviceActionButtonApplicant(APABApplicant):106 grok.order(2)107 grok.context(ICustomApplicantOnlinePayment)108 grok.require('waeup.payApplicant')109 icon = 'actionicon_call.png'110 text = _('Requery CollegePAY')111 target = 'request_webservice'112 54 113 55 class InterswitchPageStudent(KofaPage): … … 296 238 return 297 239 298 # Deprecated 299 #class InterswitchPaymentCallbackPageStudent(UtilityView, grok.View): 300 # """ Callback view for the CollegePAY gateway 301 # """ 302 # grok.context(ICustomStudentOnlinePayment) 303 # grok.name('isw_callback') 304 # grok.require('waeup.payStudent') 305 306 # This view is not yet working for offline querying transactions 307 # since the query string differs from the query string sent after 308 # posting transactions. This Interswitch bug must be removed first. 309 # Alternatively, we could use the webservice only and replace 310 # the RequestCallbackActionButton by a RequestWebserviceActionButton 311 312 # def update(self): 313 # if self.context.p_state == 'paid': 314 # self.flash(_('This ticket has already been paid.')) 315 # return 316 # student = self.context.student 317 # query = self.request.form 318 # write_log_message(self,'callback received: %s' % query) 319 # self.context.r_card_num = query.get('cardNum', None) 320 # self.context.r_code = query.get('resp', None) 321 # self.context.r_pay_reference = query.get('payRef', None) 322 # self.context.r_amount_approved = float(query.get('apprAmt', '0.0')) / 100 323 # self.context.r_desc = query.get('desc', None) 324 # if self.context.r_code != '00': 325 # self.flash(_('Unsuccessful callback: ${a}', 326 # mapping = {'a': query.get('desc', _('Incomplete query string.'))})) 327 # write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 328 # self.context.p_state = 'failed' 329 # return 330 # if self.context.r_amount_approved != payment.amount_auth: 331 # self.flash(_('Wrong amount')) 332 # write_log_message( 333 # self,'successful but wrong amount: %s' % self.context.p_id) 334 # self.context.p_state = 'failed' 335 # return 336 # try: 337 # validation_list = get_SOAP_response( 338 # PRODUCT_ID, self.context.p_id).split(':') 339 # Validation does not make sense yet since the query string 340 # formats are conflicting. We are only printing the validation 341 # string, nothing else. 342 # print 'WARNING: Webservice validation is not yet implemented' 343 # print 'validation list: %s' % validation_list 344 # except: 345 # print 'Connection to webservice failed.' 346 # Add webservice validation here 347 # write_log_message(self,'valid callback: %s' % self.context.p_id) 348 # self.context.p_state = 'paid' 349 # self.context.payment_date = datetime.utcnow() 350 # actions_after_student_payment(student, self.context, self) 351 # return 352 353 # def render(self): 354 # self.redirect(self.url(self.context, '@@index')) 355 # return 356 357 # Alternative solution, replaces InterswitchPaymentCallbackPage 358 class InterswitchPaymentRequestWebservicePageStudent(UtilityView, grok.View): 240 class InterswitchPaymentRequestWebservicePageStudent( 241 InterswitchPaymentRequestWebservicePageStudent): 359 242 """ Request webservice view for the CollegePAY gateway 360 243 """ 361 244 grok.context(ICustomStudentOnlinePayment) 362 grok.name('request_webservice') 363 grok.require('waeup.payStudent') 364 365 def update(self): 366 if self.context.p_state == 'paid': 367 self.flash(_('This ticket has already been paid.')) 368 return 369 student = self.context.student 370 success, msg, log = query_interswitch( 371 self.context, PRODUCT_ID, HOST, URL) 372 student.writeLogMessage(self, log) 373 if not success: 374 self.flash(msg) 375 return 376 write_payments_log(student.student_id, self.context) 377 success, msg, log = self.context.doAfterStudentPayment() 378 if log is not None: 379 student.writeLogMessage(self, log) 380 self.flash(msg) 381 return 382 383 def render(self): 384 self.redirect(self.url(self.context, '@@index')) 385 return 386 387 class InterswitchPaymentRequestWebservicePageApplicant(UtilityView, grok.View): 245 product_id = PRODUCT_ID 246 gateway_host = HOST 247 gateway_url = URL 248 249 class InterswitchPaymentRequestWebservicePageApplicant( 250 InterswitchPaymentRequestWebservicePageApplicant): 388 251 """ Request webservice view for the CollegePAY gateway 389 252 """ 390 253 grok.context(ICustomApplicantOnlinePayment) 391 grok.name('request_webservice') 392 grok.require('waeup.payApplicant') 393 394 def update(self): 395 if self.context.p_state == 'paid': 396 self.flash(_('This ticket has already been paid.')) 397 return 398 applicant = self.context.__parent__ 399 success, msg, log = query_interswitch( 400 self.context, PRODUCT_ID, HOST, URL) 401 applicant.writeLogMessage(self, log) 402 if not success: 403 self.flash(msg) 404 return 405 write_payments_log(applicant.applicant_id, self.context) 406 success, msg, log = self.context.doAfterApplicantPayment() 407 if log is not None: 408 applicant.writeLogMessage(self, log) 409 self.flash(msg) 410 return 411 412 def render(self): 413 self.redirect(self.url(self.context, '@@index')) 414 return 254 product_id = PRODUCT_ID 255 gateway_host = HOST 256 gateway_url = URL -
main/waeup.uniben/trunk/src/waeup/uniben/payments/interfaces.py
r9772 r9782 25 25 26 26 """ 27 28 #amount_auth = schema.Float(29 # title = _(u'Amount Authorized'),30 # default = 0.0,31 # required = False,32 # readonly = False,33 # )34
Note: See TracChangeset for help on using the changeset viewer.