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_accept.py 8028 2012-04-03 15:31:13Z henrik $
|
---|
11 | """
|
---|
12 | pay online
|
---|
13 | """
|
---|
14 | from urllib import urlencode
|
---|
15 | import logging
|
---|
16 | logger = logging.getLogger('Skins.pay_etranzact_accept')
|
---|
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_accept'
|
---|
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 |
|
---|
46 | amount = info['amount'] = 34000
|
---|
47 |
|
---|
48 |
|
---|
49 | info['surcharge'] = '0' # Uniben doesn't show the surcharge on the slip
|
---|
50 | info['payment_possible'] = True
|
---|
51 | info['type_description'] = 'Acceptance Fee'
|
---|
52 | info['pay_bill_to'] = student_record.name
|
---|
53 | info['pay_ship_to'] = "University of Benin"
|
---|
54 | info['student_id'] = student_id
|
---|
55 | info['student_name'] = student_record.name
|
---|
56 | info['student_email'] = student_record.email
|
---|
57 | #info['session_id'] = student_record.session # this holds only for new students und must be replaced when also previous session students will pay online !!!!!!
|
---|
58 | info['session_id'] = student_record.session
|
---|
59 | info['type'] = 'etranzact'
|
---|
60 | info['status'] = 'started'
|
---|
61 | info['item'] = student_record.course
|
---|
62 | info['category'] = 'acceptance'
|
---|
63 | now = DateTime.DateTime()
|
---|
64 | info['date'] = now
|
---|
65 | timestamp = "%d" % int(now.timeTime()*1000)
|
---|
66 | info['order_id'] = "%s%s" % (student_id[1:],timestamp)
|
---|
67 | p_id = "p%s" % timestamp
|
---|
68 |
|
---|
69 | if student_id is None:
|
---|
70 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
|
---|
71 |
|
---|
72 | if "payments" not in student.objectIds():
|
---|
73 | student.invokeFactory('PaymentsFolder','payments')
|
---|
74 | payments = getattr(student,'payments')
|
---|
75 | d = {}
|
---|
76 | d['Title'] = 'Payments'
|
---|
77 | payments.getContent().edit(mapping=d)
|
---|
78 | wftool.doActionFor(payments,'open')
|
---|
79 | else:
|
---|
80 | payments = getattr(student,'payments')
|
---|
81 | if request.has_key('epayment'):
|
---|
82 | return context.etranzact_form(info=info)
|
---|
83 |
|
---|
84 | payments.invokeFactory('Payment', p_id)
|
---|
85 | payment = getattr(payments,p_id)
|
---|
86 | wftool.doActionFor(payment,'open')
|
---|
87 | d = {}
|
---|
88 | d.update(info)
|
---|
89 | payment.getContent().edit(mapping=d)
|
---|
90 | logger.info('%(student_id)s initiated eTranzact acceptance fee payment with order_id %(order_id)s' % info)
|
---|
91 |
|
---|
92 | return context.payments_view() |
---|