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

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

first Version of scratch-cardpayment

  • Property svn:keywords set to Id
File size: 2.4 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 1274 2007-01-11 20:49:11Z joachim $
11"""
12pay online
13"""
14import logging
15from urllib import urlencode
16logger = logging.getLogger('EPayment.')
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 context.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)
29validate = request.has_key("cpsdocument_edit_button")
30res,psm,ds = lt.renderLayout(layout_id= 'student_schoolfee',
31                      schema_id= 'epayment',
32                      context=context,
33                      mapping=validate and REQUEST,
34                      ob={},
35                      layout_mode="create",
36                      formaction = "pay_by_sc",
37                      button = 'Pay'
38                      )
39if psm == 'invalid':
40    psm = 'Please correct your errors!'
41    return context.pay_by_sc_form(rendered = res,
42                                 psm = psm,
43                                 mode = 'edit',
44                                 ds = ds,
45                                 )
46elif psm == '':
47    return context.pay_by_sc_form(rendered = res,
48                                 psm = None,
49                                 mode = 'edit',
50                                 ds = ds,
51                                 )
52elif psm == 'valid':
53    pass
54if "payments" not in student.objectIds():
55    student.invokeFactory('PaymentsFolder','payments')
56    payments = getattr(student,'payments')
57    d = {}
58    d['Title'] = 'Payments'
59    payments.getContent().edit(mapping=d)
60    wftool.doActionFor(payments,'open')
61else:
62    payments = getattr(student,'payments')
63info = {}
64order_id = info['order_id'] = ds.get('payment_id')
65p_id = "p%s" % order_id
66now = DateTime.DateTime()
67info['date'] = now
68info['type_code'] = "schoolfee_%s"
69info['type_code'] = 'description'
70info['amount'] = amount
71payments.invokeFactory('Payment', p_id)
72payment = getattr(payments,p_id)
73#from Products.zdb import set_trace;set_trace()
74payment.getContent().edit(mapping=info)
75url = "%s/payments/%s" % (student.absolute_url(),p_id)
76request.RESPONSE.redirect(url)
77
Note: See TracBrowser for help on using the repository browser.