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

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

Add late registration fee for students in session <11.

  • Property svn:keywords set to Id
File size: 3.3 KB
RevLine 
[7901]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 8296 2012-04-27 10:54:30Z 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 = {}
[8028]38info['action'] = 'pay_etranzact'
[7901]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'
[8005]49if not fee_dict or not (new or returning):
[7901]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']
[8296]55
56if int(student_record.session) < 11:
57    amount_int = int(amount)
58    info['amount'] = '%d' % (amount_int + 5000)
59
[7901]60info['surcharge'] = '0'  # Uniben doesn't show the surcharge on the slip
61info['payment_possible'] = True
62info['type_description'] = fee_dict['description']
63info['pay_bill_to'] = student_record.name
64info['pay_ship_to'] = "University of Benin"
65info['student_id'] = student_id
66info['student_name'] = student_record.name
67info['student_email'] = student_record.email
68#info['session_id'] = student_record.session   # this holds only for new students und must be replaced when also previous session students will pay online !!!!!!
69info['session_id'] = fee_dict['next_session_id']
70info['type'] = 'etranzact'
71info['status'] = 'started'
72info['item'] = student_record.course
73info['category'] = 'schoolfee'
74now = DateTime.DateTime()
75info['date'] = now
76timestamp = "%d" % int(now.timeTime()*1000)
77info['order_id'] = "%s%s" % (student_id[1:],timestamp)
78p_id = "p%s" % timestamp
79
80if student_id is None:
81    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
82
83if "payments" not in student.objectIds():
84    student.invokeFactory('PaymentsFolder','payments')
85    payments = getattr(student,'payments')
86    d = {}
87    d['Title'] = 'Payments'
88    payments.getContent().edit(mapping=d)
89    wftool.doActionFor(payments,'open')
90else:
91    payments = getattr(student,'payments')
92if request.has_key('epayment'):
93    return context.etranzact_form(info=info)
94
95payments.invokeFactory('Payment', p_id)
96payment = getattr(payments,p_id)
97wftool.doActionFor(payment,'open')
98d = {}
99d.update(info)
100payment.getContent().edit(mapping=d)
101logger.info('%(student_id)s initiated eTranzact school fee payment with order_id %(order_id)s' % info)
102
103return context.payments_view()
Note: See TracBrowser for help on using the repository browser.