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

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

more fixes

  • Property svn:keywords set to Id
File size: 2.3 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 1243 2007-01-08 17:39:17Z 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]
26amount,description = context.getSchoolFee(sbrain.faculty)
27##res = context.portal_catalog(portal_type="Certificate",
28##                                     id = sbrain.course)
29##
30##if not res:
31##    logger.info('"%s","certificate not found", "%s"' % (student_id,course))
32##    sfc = "ART"
33##else:   
34##    sfc = res[0].getPath().split('/')[-4]
35info = {}
36info['amount'] = amount
37info['type_code'] = sbrain.faculty
38info['type_description'] = description
39info['pay_bill_to'] = sbrain.name
40info['pay_ship_to'] = "University of Benin"
41info['student_id'] = student_id
42info['student_name'] = sbrain.name
43info['student_email'] = sbrain.email
44now = DateTime.DateTime()
45info['date'] = now
46order_id = info['order_id'] = "%d" % int(now.timeTime()*1000)
47info['order_id'] = "%s%s" % (student_id[1:],order_id)
48if "payments" not in student.objectIds():
49    student.invokeFactory('PaymentsFolder','payments')
50    payments = getattr(student,'payments')
51    d = {}
52    d['Title'] = 'Payments'
53    payments.getContent().edit(mapping=d)
54    wftool.doActionFor(payments,'open')
55else:
56    payments = getattr(student,'payments')
57p_id = "p%s" % order_id
58payments.invokeFactory('Payment', p_id)
59payment = getattr(payments,p_id)
60d = {}
61d.update(info)
62#from Products.zdb import set_trace;set_trace()
63payment.getContent().edit(mapping=d)
64info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id)
65if context.portal_url().find('uniben-demo.waeup.org') >-1 or\
66   context.portal_url().find('uniben.waeup.org') >-1:
67    info['action'] = "http://www.wemaonlinepayments.biz/payment.aspx"
68else:
69    info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id)
70logger.info('"%(student_id)s","%(type_description)s", "%(amount)s N"' % info)
71return context.wema_form(info=info)
Note: See TracBrowser for help on using the repository browser.