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 | """ |
---|
12 | pay online |
---|
13 | """ |
---|
14 | import logging |
---|
15 | logger = logging.getLogger('EPayment.') |
---|
16 | import DateTime |
---|
17 | request = context.REQUEST |
---|
18 | students = context.portal_url.getPortalObject().campus.students |
---|
19 | |
---|
20 | student_id = context.getStudentId() |
---|
21 | if student_id is None: |
---|
22 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
23 | |
---|
24 | student = getattr(students,student_id) |
---|
25 | sbrain = context.students_catalog(id=student_id)[0] |
---|
26 | amount,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] |
---|
35 | info = {} |
---|
36 | info['amount'] = amount |
---|
37 | info['type_code'] = sbrain.faculty |
---|
38 | info['type_description'] = description |
---|
39 | info['pay_bill_to'] = sbrain.name |
---|
40 | info['pay_ship_to'] = "University of Benin" |
---|
41 | info['student_id'] = student_id |
---|
42 | info['student_name'] = sbrain.name |
---|
43 | info['student_email'] = sbrain.email |
---|
44 | now = DateTime.DateTime() |
---|
45 | info['date'] = now |
---|
46 | order_id = info['order_id'] = "%d" % int(now.timeTime()*1000) |
---|
47 | info['order_id'] = "%s%s" % (student_id[1:],order_id) |
---|
48 | if "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') |
---|
55 | else: |
---|
56 | payments = getattr(student,'payments') |
---|
57 | p_id = "p%s" % order_id |
---|
58 | payments.invokeFactory('Payment', p_id) |
---|
59 | payment = getattr(payments,p_id) |
---|
60 | d = {} |
---|
61 | d.update(info) |
---|
62 | #from Products.zdb import set_trace;set_trace() |
---|
63 | payment.getContent().edit(mapping=d) |
---|
64 | info['callback_url'] = "%s/payments/%s/epayment_cb" % (student.absolute_url(),p_id) |
---|
65 | if 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" |
---|
68 | else: |
---|
69 | info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id) |
---|
70 | logger.info('"%(student_id)s","%(type_description)s", "%(amount)s N"' % info) |
---|
71 | return context.wema_form(info=info) |
---|