source: WAeUP_SRP/trunk/skins/waeup_epayment/pay_by_sc.py @ 1358

Last change on this file since 1358 was 1358, checked in by Henrik Bettermann, 18 years ago

Logging info corrected

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## Script (Python) "pay_by_sc"
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_by_sc.py 1358 2007-01-26 08:16:41Z henrik $
11"""
12pay online
13"""
14import logging
15from urllib import urlencode
16logger = logging.getLogger('EPayment.PayBySC')
17import DateTime
18lt = context.portal_layouts
19request = context.REQUEST
20students = context.portal_url.getPortalObject().campus.students
21
22student_id = context.getStudentId()
23if student_id is None:
24    return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
25
26student = getattr(students,student_id)
27sbrain = context.students_catalog(id=student_id)[0]
28amount,description = context.getSchoolFee(sbrain.faculty)
29res = context.portal_catalog(portal_type="Certificate",
30                                     id = sbrain.course)
31if not res:
32    logger.info('"%s","certificate not found", "%s"' % (student_id,sbrain.course))
33    prefix = ""
34else:
35    prefix = res[0].getObject().getContent().school_fee_code
36    if not prefix or prefix == 'none':
37        prefix = res[0].getPath().split('/')[-4]
38
39validate = request.has_key("cpsdocument_create_button")
40res,psm,ds = lt.renderLayout(layout_id= 'student_schoolfee',
41                      schema_id= 'epayment',
42                      context=context,
43                      mapping=validate and request,
44                      ob={},
45                      layout_mode="create",
46                      formaction = "pay_by_sc",
47                      button = 'Pay'
48                      )
49if psm == 'invalid':
50    psm = 'Please correct your errors!'
51    return context.pay_by_sc_form(rendered = res,
52                                 psm = psm,
53                                 mode = 'edit',
54                                 ds = ds,
55                                 )
56elif psm == '':
57    return context.pay_by_sc_form(rendered = res,
58                                 psm = None,
59                                 mode = 'edit',
60                                 ds = ds,
61                                 )
62elif psm == 'valid':
63    pass
64if "payments" not in student.objectIds():
65    student.invokeFactory('PaymentsFolder','payments')
66    payments = getattr(student,'payments')
67    d = {}
68    d['Title'] = 'Payments'
69    payments.getContent().edit(mapping=d)
70    wftool.doActionFor(payments,'open')
71else:
72    payments = getattr(student,'payments')
73#from Products.zdb import set_trace; set_trace()
74info = {}
75order_id = ds.get('pin_n')
76p_id = "p%s" % order_id
77now = DateTime.DateTime()
78info['date'] = now
79info['amount'] = "n/a"
80pin = info['order_id'] = ds.get('pin')
81info['type_code'] = "%s" % pin
82info['type_description'] = 'School Fee SC %s' % pin
83payments.invokeFactory('Payment', p_id)
84payment = getattr(payments,p_id)
85wftool = context.portal_workflow
86wftool.doActionFor(payment,'open')
87payment.getContent().edit(mapping=info)
88wftool.doActionFor(payment,'close')
89wftool.doActionFor(student,'pay_school_fee')
90logger.info('"%s", "paid school fee by scratch card"' % student_id)
91url = "%s/payments" % (student.absolute_url())
92request.RESPONSE.redirect(url)
93
Note: See TracBrowser for help on using the repository browser.