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