source: WAeUP_SRP/trunk/skins/waeup_uniben/pay_etranzact.py @ 16589

Last change on this file since 16589 was 8679, checked in by Henrik Bettermann, 12 years ago

Add penalty fee which is different for pg and ug students.

  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1##Script (Python) "pay_online"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: pay_etranzact.py 8679 2012-06-11 11:28:03Z henrik $
11"""
12pay online
13"""
14from urllib import urlencode
15import logging
16logger = logging.getLogger('Skins.pay_etranzact')
17import DateTime
18
19if context.portal_membership.isAnonymousUser():
20    return None
21
22try:
23    from Products.zdb import set_trace
24except:
25    def set_trace():
26        pass
27request = context.REQUEST
28wftool = context.portal_workflow
29students = context.portal_url.getPortalObject().campus.students
30
31
32student_id = context.getStudentId()
33student = getattr(students,student_id)
34
35student_record = context.students_catalog.getRecordByKey(student_id)
36#amount,description = context.getSchoolFee(student_record.faculty,student_record.session,student_record.course)
37info = {}
38info['action'] = 'pay_etranzact'
39info['student'] = student_record
40info['payment_possible'] = False
41info['amount'] = '0'
42info['bank'] = ''
43info['type_description'] = ''
44info['pay_bill_to'] = ''
45fee_dict = context.getSchoolFee(student_record)
46#fulltime = student_record.mode.endswith('_ft')
47new = student_record.review_state == 'cleared_and_validated'
48returning = student_record.review_state == 'returning'
49if not fee_dict or not (new or returning):
50    return context.etranzact_form(info=info)
51if new:
52    amount = info['amount'] = fee_dict['new']
53elif returning:
54    amount = info['amount'] = fee_dict['returning']
55
56late_registration = False
57if new and int(student_record.session) < 11 and student_record.mode.startswith('ug'):
58    late_registration = True
59if returning and int(student_record.session) < 10 and student_record.mode.startswith('ug'):
60    late_registration = True
61if new and int(student_record.session) < 10 and student_record.mode.startswith('pg'):
62    late_registration = True
63if returning and int(student_record.session) < 9 and student_record.mode.startswith('pg'):
64    late_registration = True
65if late_registration:
66    amount_int = int(amount)
67    amount_int += 5000
68    amount = info['amount'] = '%d' % (amount_int)
69
70info['surcharge'] = '0'  # Uniben doesn't show the surcharge on the slip
71info['payment_possible'] = True
72info['type_description'] = fee_dict['description']
73info['pay_bill_to'] = student_record.name
74info['pay_ship_to'] = "University of Benin"
75info['student_id'] = student_id
76info['student_name'] = student_record.name
77info['student_email'] = student_record.email
78#info['session_id'] = student_record.session   # this holds only for new students und must be replaced when also previous session students will pay online !!!!!!
79info['session_id'] = fee_dict['next_session_id']
80info['type'] = 'etranzact'
81info['status'] = 'started'
82info['item'] = student_record.course
83info['category'] = 'schoolfee'
84now = DateTime.DateTime()
85info['date'] = now
86timestamp = "%d" % int(now.timeTime()*1000)
87info['order_id'] = "%s%s" % (student_id[1:],timestamp)
88p_id = "p%s" % timestamp
89
90if student_id is None:
91    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
92
93if "payments" not in student.objectIds():
94    student.invokeFactory('PaymentsFolder','payments')
95    payments = getattr(student,'payments')
96    d = {}
97    d['Title'] = 'Payments'
98    payments.getContent().edit(mapping=d)
99    wftool.doActionFor(payments,'open')
100else:
101    payments = getattr(student,'payments')
102if request.has_key('epayment'):
103    return context.etranzact_form(info=info)
104
105payments.invokeFactory('Payment', p_id)
106payment = getattr(payments,p_id)
107wftool.doActionFor(payment,'open')
108d = {}
109d.update(info)
110payment.getContent().edit(mapping=d)
111logger.info('%(student_id)s initiated eTranzact school fee payment with order_id %(order_id)s' % info)
112
113return context.payments_view()
Note: See TracBrowser for help on using the repository browser.