Changeset 8247 for main/waeup.uniben/trunk/src/waeup
- Timestamp:
- 22 Apr 2012, 12:56:07 (13 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben
- Files:
-
- 9 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py
r8196 r8247 19 19 """ 20 20 import grok 21 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 21 22 from waeup.kofa.applicants.interfaces import ( 22 23 IApplicantRegisterUpdate, IApplicant, IApplicantEdit) … … 24 25 OnlinePaymentCallbackPage, ExportPDFPage, 25 26 ApplicantManageFormPage, ApplicantEditFormPage, 26 ApplicantRegistrationPage, ApplicantAddFormPage) 27 ApplicantRegistrationPage, ApplicantAddFormPage, 28 OnlinePaymentDisplayFormPage, AcceptanceFeePaymentAddPage, 29 OnlinePaymentBreadcrumb) 27 30 from waeup.kofa.applicants.viewlets import RequestCallbackActionButton 28 31 from waeup.kofa.applicants.pdf import PDFApplicationSlip 29 32 from waeup.uniben.applicants.interfaces import ( 30 IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit) 33 IPGApplicant, IUGApplicant, IPGApplicantEdit, IUGApplicantEdit, 34 ICustomApplicantOnlinePayment) 31 35 from waeup.uniben.interfaces import MessageFactory as _ 32 36 33 class CustomRequestCallbackActionButton(RequestCallbackActionButton): 34 """ Do not display the base package callback button in custom pages. 37 #class RequestCallbackActionButton(RequestCallbackActionButton): 38 # """ Do not display the base package callback button in custom pages. 39 # """ 40 # @property 41 # def target_url(self): 42 # return '' 43 44 #class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage): 45 # """ Neutralize callback simulation view 46 # """ 47 # def update(self): 48 # return 49 50 class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb): 51 """A breadcrumb for payments. 35 52 """ 36 @property 37 def target_url(self): 38 return '' 39 40 class CustomOnlinePaymentCallbackPage(OnlinePaymentCallbackPage): 41 """ Neutralize callback simulation view 42 """ 43 def update(self): 44 return 53 grok.context(ICustomApplicantOnlinePayment) 45 54 46 55 class CustomPDFApplicationSlip(PDFApplicationSlip): … … 107 116 form_fields['reg_number'].for_display = True 108 117 return form_fields 118 119 class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage): 120 """ Page to view an online payment ticket 121 """ 122 grok.context(ICustomApplicantOnlinePayment) 123 form_fields = grok.AutoFields(ICustomApplicantOnlinePayment) 124 form_fields[ 125 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 126 form_fields[ 127 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 128 grok.template('payment_view') 129 130 @property 131 def transaction_code(self): 132 tcode = self.context.p_id 133 return tcode[len(tcode)-8:len(tcode)] 134 135 class CustomAcceptanceFeePaymentAddPage(AcceptanceFeePaymentAddPage): 136 """ Page to add an online payment ticket 137 """ 138 factory = u'waeup.CustomApplicantOnlinePayment' 139 140 def _fillCustomFields(self, payment, session_config): 141 payment.surcharge_1 = session_config.surcharge_1 142 payment.surcharge_2 = session_config.surcharge_2 143 payment.surcharge_3 = session_config.surcharge_3 144 return payment -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py
r8196 r8247 24 24 AppCatCertificateSource, CertificateSource) 25 25 from waeup.kofa.schoolgrades import ResultEntryField 26 from waeup.kofa.interfaces import SimpleKofaVocabulary 26 from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab 27 27 from waeup.kofa.schema import FormattedDate 28 28 from waeup.kofa.students.vocabularies import nats_vocab … … 30 30 lgas_vocab, high_qual, high_grade, exam_types) 31 31 from waeup.uniben.interfaces import MessageFactory as _ 32 32 from waeup.uniben.payments.interfaces import ICustomOnlinePayment 33 33 34 34 class IUGApplicant(IApplicantBaseData): … … 261 261 respective form page. 262 262 """ 263 class ICustomApplicantOnlinePayment(ICustomOnlinePayment): 264 """An applicant payment via payment gateways. 265 266 """ -
main/waeup.uniben/trunk/src/waeup/uniben/applicants/utils.py
r8101 r8247 19 19 """ 20 20 21 import sys 21 22 import grok 23 from hurry.workflow.interfaces import IWorkflowInfo, InvalidTransitionError 22 24 from waeup.kofa.applicants.utils import ApplicantsUtils 23 25 from waeup.uniben.interfaces import MessageFactory as _ 26 27 28 def actions_after_applicant_payment(applicant, view): 29 wf_info = IWorkflowInfo(applicant) 30 try: 31 wf_info.fireTransition('pay') 32 except InvalidTransitionError: 33 view.flash('Error: %s' % sys.exc_info()[1]) 34 return 24 35 25 36 class ApplicantsUtils(ApplicantsUtils): -
main/waeup.uniben/trunk/src/waeup/uniben/browser/pages.py
r8204 r8247 19 19 from waeup.kofa.browser.pages import ( 20 20 SessionConfigurationAddFormPage, SessionConfigurationManageFormPage) 21 from waeup.kofa.interfaces import IUserAccount22 21 from waeup.uniben.interfaces import ( 23 22 ICustomSessionConfiguration, ICustomSessionConfigurationAdd) 24 from waeup.kofa.browser.pages import (25 UserEditFormPage, UserManageFormPage, AddUserFormPage)26 23 27 24 class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage): -
main/waeup.uniben/trunk/src/waeup/uniben/etranzact/browser.py
r8129 r8247 23 23 from waeup.kofa.browser.layout import KofaPage, UtilityView 24 24 from waeup.kofa.students.interfaces import IStudentOnlinePayment 25 from waeup.kofa.students.browser import write_log_message 26 from waeup.kofa.students.viewlets import RequestCallbackActionButton 25 from waeup.kofa.applicants.interfaces import IApplicantOnlinePayment 26 from waeup.kofa.applicants.viewlets import RequestCallbackActionButton as RCABApplicant 27 from waeup.kofa.students.viewlets import RequestCallbackActionButton as RCABStudent 27 28 from waeup.uniben.interfaces import MessageFactory as _ 28 from waeup.uniben.utils.utils import actions_after_payment 29 from waeup.uniben.students.utils import actions_after_student_payment 30 from waeup.uniben.applicants.utils import actions_after_applicant_payment 29 31 30 TERMINAL_ID = '0 000000001'31 QUERY_URL = 'http ://demo.etranzact.com:8080/WebConnect/queryPayoutletTransaction.jsp'32 TERMINAL_ID = '0500000003' 33 QUERY_URL = 'https://www.etranzact.net/Query/queryPayoutletTransaction.jsp' 32 34 33 class EtranzactEnterPinActionButton(RequestCallbackActionButton): 34 grok.order(5) 35 36 def query_etranzact(confirmation_number, user, payment, view): 37 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 38 postdict = {} 39 postdict['TERMINAL_ID'] = TERMINAL_ID 40 #postdict['RESPONSE_URL'] = 'http://dummy' 41 postdict['CONFIRMATION_NO'] = confirmation_number 42 data = urllib.urlencode(postdict) 43 try: 44 f = urllib.urlopen(url=QUERY_URL, data=data) 45 success = f.read() 46 user.loggerInfo(ob_class, 'callback received: %s' % success) 47 if 'COL1' not in success: 48 view.flash(_('Invalid or unsuccessful callback: ${a}', 49 mapping = {'a': success})) 50 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id) 51 payment.p_state = 'failed' 52 return False 53 success = success.replace('%20',' ').split('&') 54 # We expect at least two parameters 55 if len(success) < 2: 56 view.flash(_('Invalid callback: ${a}', 57 mapping = {'a': success})) 58 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id) 59 payment.p_state = 'failed' 60 return False 61 try: 62 success_dict = dict([tuple(i.split('=')) for i in success]) 63 except ValueError: 64 view.flash(_('Invalid callback: ${a}', 65 mapping = {'a': success})) 66 user.loggerInfo(ob_class, 'invalid callback: %s' % payment.p_id) 67 payment.p_state = 'failed' 68 return False 69 except IOError: 70 view.flash(_('eTranzact IOError')) 71 return False 72 payment.r_code = u'ET' 73 payment.r_desc = u'%s' % success_dict.get('TRANS_DESCR') 74 payment.r_amount_approved = float(success_dict.get('TRANS_AMOUNT',0.0)) 75 payment.r_card_num = None 76 payment.r_pay_reference = u'%s' % success_dict.get('RECEIPT_NO') 77 if payment.r_amount_approved != payment.amount_auth: 78 view.flash(_('Wrong amount')) 79 user.loggerInfo(ob_class, 'successful callback but wrong amount: %s' 80 % payment.p_id) 81 payment.p_state = 'failed' 82 return False 83 tcode = payment.p_id 84 tcode = tcode[len(tcode)-8:len(tcode)] 85 col1 = success_dict.get('COL1') 86 col1 = col1[len(col1)-8:len(col1)] 87 if tcode != col1: 88 view.flash(_('Wrong transaction code')) 89 write_log_message( 90 view,'successful callback but wrong transaction code: %s' 91 % payment.p_id) 92 user.loggerInfo(ob_class, 'successful callback wrong transaction code: %s' 93 % payment.p_id) 94 payment.p_state = 'failed' 95 return False 96 user.loggerInfo(ob_class, 'successful callback: %s' % payment.p_id) 97 payment.p_state = 'paid' 98 payment.payment_date = datetime.now() 99 return True 100 101 class EtranzactEnterPinActionButtonApplicant(RCABApplicant): 35 102 icon = 'actionicon_call.png' 36 103 text = _('Query eTranzact History') 37 104 target = 'enterpin' 38 105 39 class EtranzactEnterPinPage(KofaPage): 106 class EtranzactEnterPinActionButtonStudent(RCABStudent): 107 icon = 'actionicon_call.png' 108 text = _('Query eTranzact History') 109 target = 'enterpin' 110 111 class EtranzactEnterPinPageStudent(KofaPage): 40 112 """ 41 113 """ … … 49 121 action = 'query_history' 50 122 51 class EtranzactQueryHistoryPage(UtilityView, grok.View): 123 class EtranzactEnterPinPageApplicant(EtranzactEnterPinPageStudent): 124 """ 125 """ 126 grok.require('waeup.payApplicant') 127 grok.context(IApplicantOnlinePayment) 128 129 class EtranzactQueryHistoryPageStudent(UtilityView, grok.View): 52 130 """ Query history of eTranzact payments 53 131 """ … … 61 139 return 62 140 student = self.context.getStudent() 63 postdict = {} 64 postdict['TERMINAL_ID'] = TERMINAL_ID 65 #postdict['RESPONSE_URL'] = 'http://dummy' 66 postdict['CONFIRMATION_NO'] = confirmation_number 67 data = urllib.urlencode(postdict) 68 try: 69 f = urllib.urlopen(url=QUERY_URL, data=data) 70 success = f.read() 71 if '-1' in success: 72 self.flash(_('Unsuccessful callback')) 73 write_log_message(self,'unsuccessful callback: %s' % self.context.p_id) 74 self.context.p_state = 'failed' 75 return 76 success = success.replace('%20',' ').split('&') 77 # We expect at least two parameters 78 if len(success) < 2: 79 self.flash(_('Invalid callback: ${a}', 80 mapping = {'a': success})) 81 write_log_message(self,'invalid callback: %s' % self.context.p_id) 82 self.context.p_state = 'failed' 83 return 84 try: 85 success_dict = dict([tuple(i.split('=')) for i in success]) 86 except ValueError: 87 self.flash(_('Invalid callback: ${a}', 88 mapping = {'a': success})) 89 write_log_message(self,'invalid callback: %s' % self.context.p_id) 90 self.context.p_state = 'failed' 91 return 92 except IOError: 93 self.flash(_('eTranzact IOError')) 94 return 95 write_log_message(self,'callback received: %s' % success) 96 97 self.context.r_code = u'ET' 98 self.context.r_desc = u'%s' % success_dict.get('TRANS_DESCR') 99 self.context.r_amount_approved = float(success_dict.get('TRANS_AMOUNT',0.0)) 100 self.context.r_card_num = None 101 self.context.r_pay_reference = u'%s' % success_dict.get('RECEIPT_NO') 102 103 if self.context.r_amount_approved != self.context.amount_auth: 104 self.flash(_('Wrong amount')) 105 write_log_message( 106 self,'successful callback but wrong amount: %s' 107 % self.context.p_id) 108 self.context.p_state = 'failed' 109 return 110 111 if success_dict.get('COL1') != self.context.p_id: 112 self.flash(_('Wrong transaction id')) 113 write_log_message( 114 self,'successful callback but wrong transaction id: %s' 115 % self.context.p_id) 116 self.context.p_state = 'failed' 117 return 118 119 write_log_message(self,'successful callback: %s' % self.context.p_id) 120 121 self.context.p_state = 'paid' 122 self.context.payment_date = datetime.now() 123 124 actions_after_payment(student, self.context, self) 125 141 if query_etranzact(confirmation_number, student, self.context, self): 142 actions_after_student_payment(student, self.context, self) 126 143 return 127 144 … … 129 146 self.redirect(self.url(self.context, '@@index')) 130 147 return 148 149 class EtranzactQueryHistoryPageApplicant(UtilityView, grok.View): 150 """ Query history of eTranzact payments 151 """ 152 grok.context(IApplicantOnlinePayment) 153 grok.name('query_history') 154 grok.require('waeup.payApplicant') 155 156 def update(self, confirmation_number=None): 157 if self.context.p_state == 'paid': 158 self.flash(_('This ticket has already been paid.')) 159 return 160 applicant = self.context.__parent__ 161 if query_etranzact(confirmation_number, applicant, self.context, self): 162 actions_after_applicant_payment(applicant, self) 163 return 164 165 def render(self): 166 self.redirect(self.url(self.context, '@@index')) 167 return -
main/waeup.uniben/trunk/src/waeup/uniben/interswitch/browser.py
r8020 r8247 26 26 from waeup.kofa.students.browser import write_log_message 27 27 from waeup.kofa.students.viewlets import RequestCallbackActionButton 28 from waeup.uniben. utils.utils import actions_after_payment28 from waeup.uniben.students.utils import actions_after_student_payment 29 29 from waeup.uniben.interfaces import MessageFactory as _ 30 30 -
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r8204 r8247 19 19 from zope.formlib.textwidgets import BytesDisplayWidget 20 20 from zope.component import getUtility 21 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 21 22 from waeup.kofa.interfaces import IExtFileStore 23 from waeup.kofa.browser.layout import action 22 24 from waeup.kofa.students.browser import ( 23 25 StudentPersonalDisplayFormPage, … … 25 27 StudentClearanceDisplayFormPage, OnlinePaymentCallbackPage, 26 28 ExportPDFClearanceSlipPage, StudentBaseManageFormPage, 27 StudentBaseEditFormPage, StudentPersonalEditFormPage) 29 StudentBaseEditFormPage, StudentPersonalEditFormPage, 30 OnlinePaymentDisplayFormPage, OnlinePaymentAddFormPage, 31 OnlinePaymentBreadcrumb) 28 32 from waeup.kofa.students.viewlets import RequestCallbackActionButton 29 33 from waeup.uniben.students.interfaces import ( 30 34 ICustomStudentBase, ICustomStudent, ICustomStudentPersonal, 31 35 ICustomUGStudentClearance,ICustomPGStudentClearance, 36 ICustomStudentOnlinePayment, 32 37 ) 33 38 from waeup.uniben.interfaces import MessageFactory as _ 34 39 35 class CustomRequestCallbackActionButton(RequestCallbackActionButton): 40 class CustomOnlinePaymentBreadcrumb(OnlinePaymentBreadcrumb): 41 """A breadcrumb for payments. 42 """ 43 grok.context(ICustomStudentOnlinePayment) 44 45 class RequestCallbackActionButton(RequestCallbackActionButton): 36 46 """ Do not display the base package callback button in custom pages. 37 47 """ … … 144 154 return False 145 155 156 class CustomOnlinePaymentDisplayFormPage(OnlinePaymentDisplayFormPage): 157 """ Page to view an online payment ticket 158 """ 159 grok.context(ICustomStudentOnlinePayment) 160 form_fields = grok.AutoFields(ICustomStudentOnlinePayment) 161 form_fields[ 162 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 163 form_fields[ 164 'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 165 grok.template('payment_view') 166 167 @property 168 def transaction_code(self): 169 tcode = self.context.p_id 170 return tcode[len(tcode)-8:len(tcode)] 171 172 class CustomOnlinePaymentAddFormPage(OnlinePaymentAddFormPage): 173 """ Page to add an online payment ticket 174 """ 175 form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select( 176 'p_category') 177 factory = u'waeup.CustomStudentOnlinePayment' 178 179 def _fillCustomFields(self, payment, pay_details): 180 payment.surcharge_1 = pay_details['surcharge_1'] 181 payment.surcharge_2 = pay_details['surcharge_2'] 182 payment.surcharge_3 = pay_details['surcharge_3'] 183 return payment -
main/waeup.uniben/trunk/src/waeup/uniben/students/interfaces.py
r8204 r8247 18 18 from zope import schema 19 19 from waeup.kofa.schema import TextLineChoice 20 from waeup.kofa.interfaces import SimpleKofaVocabulary 20 from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab 21 21 from waeup.kofa.schema import FormattedDate 22 22 from waeup.kofa.schoolgrades import ResultEntryField … … 31 31 lgas_vocab, high_qual, high_grade, exam_types) 32 32 from waeup.uniben.interfaces import MessageFactory as _ 33 from waeup.uniben.payments.interfaces import ICustomOnlinePayment 33 34 34 35 class ICustomStudentBase(IStudentBase): … … 339 340 340 341 """ 342 343 class ICustomStudentOnlinePayment(ICustomOnlinePayment): 344 """A student payment via payment gateways. 345 346 """ -
main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
r8204 r8247 20 20 from waeup.kofa.students.utils import StudentsUtils 21 21 from waeup.kofa.students.interfaces import IStudentsUtils 22 from waeup.kofa.accesscodes import create_accesscode 22 23 from waeup.uniben.interfaces import MessageFactory as _ 23 24 … … 41 42 else: 42 43 return 0.0 44 45 def actions_after_student_payment(student, payment, view): 46 if payment.p_category == 'clearance': 47 # Create CLR access code 48 pin, error = create_accesscode('CLR',0,student.student_id) 49 if error: 50 view.flash(_('Valid callback received. ${a}', 51 mapping = {'a':error})) 52 return 53 payment.ac = pin 54 elif payment.p_category == 'schoolfee': 55 # Create SFE access code 56 pin, error = create_accesscode('SFE',0,student.student_id) 57 if error: 58 view.flash(_('Valid callback received. ${a}', 59 mapping = {'a':error})) 60 return 61 payment.ac = pin 62 elif payment.p_category == 'bed_allocation': 63 # Create HOS access code 64 pin, error = create_accesscode('HOS',0,student.student_id) 65 if error: 66 view.flash(_('Valid callback received. ${a}', 67 mapping = {'a':error})) 68 return 69 payment.ac = pin 70 view.flash(_('Valid callback received.')) 71 return 43 72 44 73 class CustomStudentsUtils(StudentsUtils): -
main/waeup.uniben/trunk/src/waeup/uniben/utils/utils.py
r8242 r8247 21 21 import pytz 22 22 from waeup.kofa.utils.utils import KofaUtils, sorted_phone_prefixes 23 from waeup.kofa.accesscodes import create_accesscode24 23 from waeup.uniben.interfaces import MessageFactory as _ 25 26 def actions_after_payment(student, payment, view):27 if payment.p_category == 'clearance':28 # Create CLR access code29 pin, error = create_accesscode('CLR',0,student.student_id)30 if error:31 view.flash(_('Valid callback received. ${a}',32 mapping = {'a':error}))33 return34 payment.ac = pin35 elif payment.p_category == 'schoolfee':36 # Create SFE access code37 pin, error = create_accesscode('SFE',0,student.student_id)38 if error:39 view.flash(_('Valid callback received. ${a}',40 mapping = {'a':error}))41 return42 payment.ac = pin43 elif payment.p_category == 'bed_allocation':44 # Create HOS access code45 pin, error = create_accesscode('HOS',0,student.student_id)46 if error:47 view.flash(_('Valid callback received. ${a}',48 mapping = {'a':error}))49 return50 payment.ac = pin51 view.flash(_('Valid callback received.'))52 return53 24 54 25 INT_PHONE_PREFIXES = [
Note: See TracChangeset for help on using the changeset viewer.