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