[5190] | 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 5264 2010-07-14 13:21:21Z 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 | |
---|
[5264] | 68 | #query_url = "http://testwebpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx" |
---|
| 69 | query_url = "http://webpay.interswitchng.com/CollegepayService/TransactionQueryURL.aspx" |
---|
[5190] | 70 | |
---|
| 71 | info['callback_url'] = "%s/payments/%s/interswitch_request_cb" % (student.absolute_url(),p_id) |
---|
| 72 | |
---|
| 73 | request_url = query_url |
---|
| 74 | request_url += '?redirectURL=%s' % info['callback_url'] |
---|
| 75 | request_url += '&productid=53' |
---|
| 76 | request_url += '&merchantref=ignore' |
---|
| 77 | request_url += '&custNumber=%s' % student_id |
---|
| 78 | request_url += '&session=%s' % info['session_str'] |
---|
| 79 | request_url += '&semester=Semester 1' |
---|
| 80 | |
---|
| 81 | info['request_url'] = request_url |
---|
| 82 | |
---|
| 83 | if "payments" not in student.objectIds(): |
---|
| 84 | student.invokeFactory('PaymentsFolder','payments') |
---|
| 85 | payments = getattr(student,'payments') |
---|
| 86 | d = {} |
---|
| 87 | d['Title'] = 'Payments' |
---|
| 88 | payments.getContent().edit(mapping=d) |
---|
| 89 | wftool.doActionFor(payments,'open') |
---|
| 90 | else: |
---|
| 91 | payments = getattr(student,'payments') |
---|
| 92 | |
---|
| 93 | payments.invokeFactory('Payment', p_id) |
---|
| 94 | payment = getattr(payments,p_id) |
---|
| 95 | wftool.doActionFor(payment,'open') |
---|
| 96 | d = {} |
---|
| 97 | d.update(info) |
---|
| 98 | payment.getContent().edit(mapping=d) |
---|
| 99 | |
---|
| 100 | logger.info('%(student_id)s initiated school fee payment request with order_id %(order_id)s and request url %(request_url)s' % info) |
---|
| 101 | |
---|
| 102 | return context.interswitch_request_form(info=info) |
---|