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

Last change on this file since 7981 was 7901, checked in by Henrik Bettermann, 13 years ago

Implement eTranzact payment and restructure change school fee payment.

Session 2011/2012: eTranzact and Interswitch payments only
Previous sessions: scratch card payments only

  • Property svn:keywords set to Id
File size: 3.2 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 7901 2012-03-17 10:16:07Z 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['student'] = student_record
39info['payment_possible'] = False
40info['amount'] = '0'
41info['bank'] = ''
42info['type_description'] = ''
43info['pay_bill_to'] = ''
44fee_dict = context.getSchoolFee(student_record)
45#fulltime = student_record.mode.endswith('_ft')
46new = student_record.review_state == 'cleared_and_validated'
47returning = student_record.review_state == 'returning'
48if not fee_dict or not (new or returning) or not fee_dict['next_session_id'] in ('11','12','13'):
49    return context.etranzact_form(info=info)
50if new:
51    amount = info['amount'] = fee_dict['new']
52elif returning:
53    amount = info['amount'] = fee_dict['returning']
54info['surcharge'] = '0'  # Uniben doesn't show the surcharge on the slip
55info['payment_possible'] = True
56info['type_description'] = fee_dict['description']
57info['pay_bill_to'] = student_record.name
58info['pay_ship_to'] = "University of Benin"
59info['student_id'] = student_id
60info['student_name'] = student_record.name
61info['student_email'] = student_record.email
62#info['session_id'] = student_record.session   # this holds only for new students und must be replaced when also previous session students will pay online !!!!!!
63info['session_id'] = fee_dict['next_session_id']
64info['type'] = 'etranzact'
65info['status'] = 'started'
66info['item'] = student_record.course
67info['category'] = 'schoolfee'
68now = DateTime.DateTime()
69info['date'] = now
70timestamp = "%d" % int(now.timeTime()*1000)
71info['order_id'] = "%s%s" % (student_id[1:],timestamp)
72p_id = "p%s" % timestamp
73
74if student_id is None:
75    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
76
77if "payments" not in student.objectIds():
78    student.invokeFactory('PaymentsFolder','payments')
79    payments = getattr(student,'payments')
80    d = {}
81    d['Title'] = 'Payments'
82    payments.getContent().edit(mapping=d)
83    wftool.doActionFor(payments,'open')
84else:
85    payments = getattr(student,'payments')
86if request.has_key('epayment'):
87    return context.etranzact_form(info=info)
88
89payments.invokeFactory('Payment', p_id)
90payment = getattr(payments,p_id)
91wftool.doActionFor(payment,'open')
92d = {}
93d.update(info)
94payment.getContent().edit(mapping=d)
95logger.info('%(student_id)s initiated eTranzact school fee payment with order_id %(order_id)s' % info)
96
97return context.payments_view()
Note: See TracBrowser for help on using the repository browser.