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

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

Implementation of acceptance fee payment via eTranzact.

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