source: WAeUP_SRP/trunk/skins/waeup_epayment/pay_online.py @ 1231

Last change on this file since 1231 was 1226, checked in by joachim, 18 years ago

modifications

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