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_online.py 1226 2007-01-07 16:48:21Z joachim $ |
---|
11 | """ |
---|
12 | pay online |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('EPayment.') |
---|
16 | import DateTime |
---|
17 | request = context.REQUEST |
---|
18 | students = context.portal_url.getPortalObject().campus.students |
---|
19 | |
---|
20 | student_id = context.getStudentId() |
---|
21 | if student_id is None: |
---|
22 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
23 | |
---|
24 | student = getattr(students,student_id) |
---|
25 | sbrain = context.students_catalog(id=student_id)[0] |
---|
26 | res = context.portal_catalog(portal_type="Certificate", |
---|
27 | id = sbrain.course) |
---|
28 | if not res: |
---|
29 | logger.info('"%s","certificate not found", "%s"' % (student_id,course)) |
---|
30 | sfc = "ART" |
---|
31 | else: |
---|
32 | sfc = res[0].getPath().split('/')[-4] |
---|
33 | info = {} |
---|
34 | info['amount'] = "75000" |
---|
35 | info['type_code'] = sfc |
---|
36 | info['type_description'] = "Schoolfee %s for 2006/2007 Session" % sfc |
---|
37 | info['pay_bill_to'] = sbrain.name |
---|
38 | info['pay_ship_to'] = "University of Benin" |
---|
39 | info['student_id'] = student_id |
---|
40 | info['student_name'] = sbrain.name |
---|
41 | info['student_email'] = sbrain.email |
---|
42 | now = DateTime.DateTime() |
---|
43 | info['pay_date'] = now.strftime("%d%m%y%H%M%S") |
---|
44 | order_id = info['order_id'] = "%d" % int(now.timeTime()*1000) |
---|
45 | info['order_id'] = "%s%s" % (student_id[1:],order_id) |
---|
46 | if "payments" not in student.objectIds(): |
---|
47 | student.invokeFactory('PaymentsFolder','payments') |
---|
48 | payments = getattr(student,'payments') |
---|
49 | d = {} |
---|
50 | d['Title'] = 'Online Payments' |
---|
51 | payments.getContent().edit(mapping=d) |
---|
52 | else: |
---|
53 | payments = getattr(student,'payments') |
---|
54 | p_id = "p%s" % order_id |
---|
55 | payments.invokeFactory('Payment', p_id) |
---|
56 | #from Products.zdb import set_trace;set_trace() |
---|
57 | payment = getattr(payments,p_id) |
---|
58 | d = {} |
---|
59 | d.update(info) |
---|
60 | d['Title'] = "%(type_description)s %(pay_date) %(amount)s N" % info |
---|
61 | payment.getContent().edit(mapping=d) |
---|
62 | info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id) |
---|
63 | logger.info('"%(student_id)s","%(type_description)s", "%(amount)s N"' % info) |
---|
64 | return context.wema_form(info=info) |
---|