[7901] | 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_etranzact.py 7901 2012-03-17 10:16:07Z henrik $
|
---|
| 11 | """
|
---|
| 12 | pay online
|
---|
| 13 | """
|
---|
| 14 | from urllib import urlencode
|
---|
| 15 | import logging
|
---|
| 16 | logger = logging.getLogger('Skins.pay_etranzact')
|
---|
| 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 | #amount,description = context.getSchoolFee(student_record.faculty,student_record.session,student_record.course)
|
---|
| 37 | info = {}
|
---|
| 38 | info['student'] = student_record
|
---|
| 39 | info['payment_possible'] = False
|
---|
| 40 | info['amount'] = '0'
|
---|
| 41 | info['bank'] = ''
|
---|
| 42 | info['type_description'] = ''
|
---|
| 43 | info['pay_bill_to'] = ''
|
---|
| 44 | fee_dict = context.getSchoolFee(student_record)
|
---|
| 45 | #fulltime = student_record.mode.endswith('_ft')
|
---|
| 46 | new = student_record.review_state == 'cleared_and_validated'
|
---|
| 47 | returning = student_record.review_state == 'returning'
|
---|
| 48 | if not fee_dict or not (new or returning) or not fee_dict['next_session_id'] in ('11','12','13'):
|
---|
| 49 | return context.etranzact_form(info=info)
|
---|
| 50 | if new:
|
---|
| 51 | amount = info['amount'] = fee_dict['new']
|
---|
| 52 | elif returning:
|
---|
| 53 | amount = info['amount'] = fee_dict['returning']
|
---|
| 54 | info['surcharge'] = '0' # Uniben doesn't show the surcharge on the slip
|
---|
| 55 | info['payment_possible'] = True
|
---|
| 56 | info['type_description'] = fee_dict['description']
|
---|
| 57 | info['pay_bill_to'] = student_record.name
|
---|
| 58 | info['pay_ship_to'] = "University of Benin"
|
---|
| 59 | info['student_id'] = student_id
|
---|
| 60 | info['student_name'] = student_record.name
|
---|
| 61 | info['student_email'] = student_record.email
|
---|
| 62 | #info['session_id'] = student_record.session # this holds only for new students und must be replaced when also previous session students will pay online !!!!!!
|
---|
| 63 | info['session_id'] = fee_dict['next_session_id']
|
---|
| 64 | info['type'] = 'etranzact'
|
---|
| 65 | info['status'] = 'started'
|
---|
| 66 | info['item'] = student_record.course
|
---|
| 67 | info['category'] = 'schoolfee'
|
---|
| 68 | now = DateTime.DateTime()
|
---|
| 69 | info['date'] = now
|
---|
| 70 | timestamp = "%d" % int(now.timeTime()*1000)
|
---|
| 71 | info['order_id'] = "%s%s" % (student_id[1:],timestamp)
|
---|
| 72 | p_id = "p%s" % timestamp
|
---|
| 73 |
|
---|
| 74 | if student_id is None:
|
---|
| 75 | return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
|
---|
| 76 |
|
---|
| 77 | if "payments" not in student.objectIds():
|
---|
| 78 | student.invokeFactory('PaymentsFolder','payments')
|
---|
| 79 | payments = getattr(student,'payments')
|
---|
| 80 | d = {}
|
---|
| 81 | d['Title'] = 'Payments'
|
---|
| 82 | payments.getContent().edit(mapping=d)
|
---|
| 83 | wftool.doActionFor(payments,'open')
|
---|
| 84 | else:
|
---|
| 85 | payments = getattr(student,'payments')
|
---|
| 86 | if request.has_key('epayment'):
|
---|
| 87 | return context.etranzact_form(info=info)
|
---|
| 88 |
|
---|
| 89 | payments.invokeFactory('Payment', p_id)
|
---|
| 90 | payment = getattr(payments,p_id)
|
---|
| 91 | wftool.doActionFor(payment,'open')
|
---|
| 92 | d = {}
|
---|
| 93 | d.update(info)
|
---|
| 94 | payment.getContent().edit(mapping=d)
|
---|
| 95 | logger.info('%(student_id)s initiated eTranzact school fee payment with order_id %(order_id)s' % info)
|
---|
| 96 |
|
---|
| 97 | return context.payments_view() |
---|