## Script (Python) "getPaymentsFolderInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: getPaymentsFolderInfo.py 2761 2007-11-26 09:45:58Z henrik $ """ Info for the PaymentsFolder try: from Products.zdb import set_trace except: def set_trace(): pass """ mtool = context.portal_membership wftool = context.portal_workflow member = mtool.getAuthenticatedMember() if mtool.isAnonymousUser(): return None #import logging #logger = logging.getLogger('Skins.getPaymentsFolderInfo') def cmp_id(a,b): s1 = "%(id)s" % a s2 = "%(id)s" % b if s1 == s2: return 0 if s1 > s2: return 1 return -1 import DateTime request = context.REQUEST students = context.portal_url.getPortalObject().campus.students student_id = context.getStudentId() if student_id is None: return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) student = getattr(students,student_id) student_record = context.students_catalog.getRecordByKey(student_id) #context['updatePayments']() payments = [] info = {} is_so = info['is_so'] = context.isSectionOfficer() is_student = info['is_student'] = context.isStudent() info['student_name'] = student_record.name info['query_url'] = "https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx" review_state = info['review_state'] = student_record.review_state parttime = student_record.mode and student_record.mode.endswith('_pt') fulltime = student_record.mode and student_record.mode.endswith('_ft') #if review_state == 'cleared_and_validated' or (parttime and review_state == 'returning'): # online_payment = True #elif fulltime and review_state == 'returning': # sc_payment = True session = student_record.session next_info = context.getNextInfo(student_record) info['next_session'] = next_info['next_session_id'] info['next_session_str'] = next_info['next_session_str'] info['payment_method'] = "" info['reasons'] = next_info['reasons'] if review_state == 'cleared_and_validated' and session != '07': info['payment_method'] = "online_payment" #elif review_state == 'cleared_and_validated' and session == '07': # info['payment_method'] = "sc_payment" elif review_state == 'returning' and info['next_session'] != session: info['payment_method'] = "sc_payment" info['prod_id'] = '61' info['student_name'] = student_record.name info['is_so'] = is_so for payment_id,payment in context.objectItems(): row = {} row['id'] = payment_id row['title'] = payment.Title() url = row['url'] = payment.absolute_url() payment_doc = payment.getContent() row['type'] = payment_doc.portal_type review_state = row['review_state'] = wftool.getInfoFor(payment,'review_state',None) if payment_doc.type_description.startswith('School Fee'): row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated' else: row['is_approvable'] = is_so and (review_state == "opened") row['is_requeryable'] = False #set_trace() row['resp_desc'] = getattr(payment_doc,'resp_desc','no response') row['trans_ref'] = getattr(payment_doc,'order_id','') if payment_doc.type_description.startswith('School Fee'): if (review_state == 'opened' and info['review_state'] in ('cleared_and_validated',) and \ hasattr(payment_doc, 'order_id') and not payment_doc.resp_code) or str(member) in ('admin',): row['is_requeryable'] = True row['callback_url'] = "%(url)s/interswitch_cb" % row href = '%(query_url)s' % info href += '?transRef=%(trans_ref)s' % row href += '&prodID=%(prod_id)s' % info href += '&redirectURL=%(callback_url)s' % row row['href'] = href if (review_state == "closed") and payment_doc.resp_code in ('SC','00','AP','IP',): row['confirmed'] = 'active' else: row['confirmed'] = 'unsuccessful' row['is_editable'] = is_so and (row['confirmed'] == 'active') payments.append(row) payments.sort(cmp_id) info['payments'] = payments return info