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: request_interswitch.py 5190 2010-05-13 10:20:33Z henrik $ |
---|
11 | """ |
---|
12 | pay online |
---|
13 | """ |
---|
14 | from urllib import urlencode |
---|
15 | import logging |
---|
16 | logger = logging.getLogger('Skins.request_interswitch') |
---|
17 | import DateTime |
---|
18 | |
---|
19 | if context.portal_membership.isAnonymousUser(): |
---|
20 | return None |
---|
21 | |
---|
22 | try: |
---|
23 | from Products.zdb import set_trace |
---|
24 | except: |
---|
25 | def set_trace(): |
---|
26 | pass |
---|
27 | request = context.REQUEST |
---|
28 | wftool = context.portal_workflow |
---|
29 | students = context.portal_url.getPortalObject().campus.students |
---|
30 | |
---|
31 | |
---|
32 | student_id = context.getStudentId() |
---|
33 | student = getattr(students,student_id) |
---|
34 | |
---|
35 | student_record = context.students_catalog.getRecordByKey(student_id) |
---|
36 | info = {} |
---|
37 | info['student'] = student_record |
---|
38 | info['payment_possible'] = False |
---|
39 | fee_dict = context.getSchoolFeeForRequest(student_record) |
---|
40 | fulltime = student_record.mode.endswith('_ft') |
---|
41 | |
---|
42 | if not fee_dict: |
---|
43 | return context.interswitch_form(info=info) |
---|
44 | |
---|
45 | info['payment_possible'] = True |
---|
46 | info['type_description'] = fee_dict['description'] |
---|
47 | info['student_id'] = student_id |
---|
48 | info['reg_no'] = student_record.jamb_reg_no |
---|
49 | info['matric_no'] = student_record.matric_no |
---|
50 | info['student_name'] = student_record.name |
---|
51 | info['type'] = 'request' |
---|
52 | info['status'] = 'started' |
---|
53 | info['session_id'] = fee_dict['next_session_id'] |
---|
54 | info['session_str'] = fee_dict['next_session_str'] |
---|
55 | info['item'] = student_record.course |
---|
56 | info['category'] = 'schoolfee' |
---|
57 | info['student_email'] = student_record.email |
---|
58 | now = DateTime.DateTime() |
---|
59 | info['date'] = now |
---|
60 | info['pay_ship_to'] = "Ambrose Alli University Ekpoma" |
---|
61 | timestamp = "%d" % int(now.timeTime()*1000) |
---|
62 | info['order_id'] = "%s%s" % (student_id[1:],timestamp) |
---|
63 | p_id = "p%s" % timestamp |
---|
64 | |
---|
65 | if student_id is None: |
---|
66 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
67 | |
---|
68 | query_url = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx" |
---|
69 | |
---|
70 | info['callback_url'] = "%s/payments/%s/interswitch_request_cb" % (student.absolute_url(),p_id) |
---|
71 | |
---|
72 | request_url = query_url |
---|
73 | request_url += '?redirectURL=%s' % info['callback_url'] |
---|
74 | request_url += '&productid=53' |
---|
75 | request_url += '&merchantref=ignore' |
---|
76 | request_url += '&custNumber=%s' % student_id |
---|
77 | request_url += '&session=%s' % info['session_str'] |
---|
78 | request_url += '&semester=Semester 1' |
---|
79 | |
---|
80 | info['request_url'] = request_url |
---|
81 | |
---|
82 | if "payments" not in student.objectIds(): |
---|
83 | student.invokeFactory('PaymentsFolder','payments') |
---|
84 | payments = getattr(student,'payments') |
---|
85 | d = {} |
---|
86 | d['Title'] = 'Payments' |
---|
87 | payments.getContent().edit(mapping=d) |
---|
88 | wftool.doActionFor(payments,'open') |
---|
89 | else: |
---|
90 | payments = getattr(student,'payments') |
---|
91 | |
---|
92 | payments.invokeFactory('Payment', p_id) |
---|
93 | payment = getattr(payments,p_id) |
---|
94 | wftool.doActionFor(payment,'open') |
---|
95 | d = {} |
---|
96 | d.update(info) |
---|
97 | payment.getContent().edit(mapping=d) |
---|
98 | |
---|
99 | logger.info('%(student_id)s initiated school fee payment request with order_id %(order_id)s and request url %(request_url)s' % info) |
---|
100 | |
---|
101 | return context.interswitch_request_form(info=info) |
---|