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 | """
|
---|
12 | pay online
|
---|
13 | """
|
---|
14 | from urllib import urlencode
|
---|
15 | import logging
|
---|
16 | logger = logging.getLogger('Skins.pay_etranzact')
|
---|
17 | import DateTime
|
---|
18 |
|
---|
19 | if context.portal_membership.isAnonymousUser():
|
---|
20 | return None
|
---|
21 |
|
---|
22 | try:
|
---|
23 | from Products.zdb import set_trace
|
---|
24 | except:
|
---|
25 | def set_trace():
|
---|
26 | pass
|
---|
27 | request = context.REQUEST
|
---|
28 | wftool = context.portal_workflow
|
---|
29 | students = context.portal_url.getPortalObject().campus.students
|
---|
30 |
|
---|
31 |
|
---|
32 | student_id = context.getStudentId()
|
---|
33 | student = getattr(students,student_id)
|
---|
34 |
|
---|
35 | student_record = context.students_catalog.getRecordByKey(student_id)
|
---|
36 | #amount,description = context.getSchoolFee(student_record.faculty,student_record.session,student_record.course)
|
---|
37 | info = {}
|
---|
38 | info['action'] = 'pay_etranzact'
|
---|
39 | info['student'] = student_record
|
---|
40 | info['payment_possible'] = False
|
---|
41 | info['amount'] = '0'
|
---|
42 | info['bank'] = ''
|
---|
43 | info['type_description'] = ''
|
---|
44 | info['pay_bill_to'] = ''
|
---|
45 | fee_dict = context.getSchoolFee(student_record)
|
---|
46 | #fulltime = student_record.mode.endswith('_ft')
|
---|
47 | new = student_record.review_state == 'cleared_and_validated'
|
---|
48 | returning = student_record.review_state == 'returning'
|
---|
49 | if not fee_dict or not (new or returning):
|
---|
50 | return context.etranzact_form(info=info)
|
---|
51 | if new:
|
---|
52 | amount = info['amount'] = fee_dict['new']
|
---|
53 | elif returning:
|
---|
54 | amount = info['amount'] = fee_dict['returning']
|
---|
55 |
|
---|
56 | late_registration = False
|
---|
57 | if new and int(student_record.session) < 11 and student_record.mode.startswith('ug'):
|
---|
58 | late_registration = True
|
---|
59 | if returning and int(student_record.session) < 10 and student_record.mode.startswith('ug'):
|
---|
60 | late_registration = True
|
---|
61 | if new and int(student_record.session) < 10 and student_record.mode.startswith('pg'):
|
---|
62 | late_registration = True
|
---|
63 | if returning and int(student_record.session) < 9 and student_record.mode.startswith('pg'):
|
---|
64 | late_registration = True
|
---|
65 | if late_registration:
|
---|
66 | amount_int = int(amount)
|
---|
67 | amount_int += 5000
|
---|
68 | amount = info['amount'] = '%d' % (amount_int)
|
---|
69 |
|
---|
70 | info['surcharge'] = '0' # Uniben doesn't show the surcharge on the slip
|
---|
71 | info['payment_possible'] = True
|
---|
72 | info['type_description'] = fee_dict['description']
|
---|
73 | info['pay_bill_to'] = student_record.name
|
---|
74 | info['pay_ship_to'] = "University of Benin"
|
---|
75 | info['student_id'] = student_id
|
---|
76 | info['student_name'] = student_record.name
|
---|
77 | info['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 !!!!!!
|
---|
79 | info['session_id'] = fee_dict['next_session_id']
|
---|
80 | info['type'] = 'etranzact'
|
---|
81 | info['status'] = 'started'
|
---|
82 | info['item'] = student_record.course
|
---|
83 | info['category'] = 'schoolfee'
|
---|
84 | now = DateTime.DateTime()
|
---|
85 | info['date'] = now
|
---|
86 | timestamp = "%d" % int(now.timeTime()*1000)
|
---|
87 | info['order_id'] = "%s%s" % (student_id[1:],timestamp)
|
---|
88 | p_id = "p%s" % timestamp
|
---|
89 |
|
---|
90 | if student_id is None:
|
---|
91 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
|
---|
92 |
|
---|
93 | if "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')
|
---|
100 | else:
|
---|
101 | payments = getattr(student,'payments')
|
---|
102 | if request.has_key('epayment'):
|
---|
103 | return context.etranzact_form(info=info)
|
---|
104 |
|
---|
105 | payments.invokeFactory('Payment', p_id)
|
---|
106 | payment = getattr(payments,p_id)
|
---|
107 | wftool.doActionFor(payment,'open')
|
---|
108 | d = {}
|
---|
109 | d.update(info)
|
---|
110 | payment.getContent().edit(mapping=d)
|
---|
111 | logger.info('%(student_id)s initiated eTranzact school fee payment with order_id %(order_id)s' % info)
|
---|
112 |
|
---|
113 | return context.payments_view() |
---|