source: WAeUP_SRP/trunk/skins/waeup_aaue/pay_interswitch.py @ 7042

Last change on this file since 7042 was 5255, checked in by Henrik Bettermann, 14 years ago

pay_interswitch.py: remove duplicate xml data

apply_admission.py: change year for pume and pde screening

File size: 5.5 KB
RevLine 
[3841]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_interswitch.py 2619 2007-11-10 17:39:36Z henrik $
11"""
12pay online
13"""
14from urllib import urlencode
15import logging
16logger = logging.getLogger('Skins.pay_interswitch')
17import DateTime
18
19if context.portal_membership.isAnonymousUser():
20    return None
21
22try:
23    from Products.zdb import set_trace
24except:
25    def set_trace():
26        pass
27request = context.REQUEST
28wftool = context.portal_workflow
29students = context.portal_url.getPortalObject().campus.students
30
31
32student_id = context.getStudentId()
33student = getattr(students,student_id)
34
35student_record = context.students_catalog.getRecordByKey(student_id)
36info = {}
37info['student'] = student_record
38info['payment_possible'] = False
39info['amount'] = '0'
40info['bank'] = ''
41info['type_description'] = ''
42info['pay_bill_to'] = ''
43fee_dict = context.getSchoolFee(student_record)
44fulltime = student_record.mode.endswith('_ft')
45
46if not fee_dict:
47    return context.interswitch_form(info=info)
48
[3898]49info['site_id'] = '119'
[3841]50info['currency_id'] = '566'
[3872]51pay_item_id = "11900"
[3841]52
53#info['type_code'] = sbrain.course  #type_code is redundant and will be removed soon
54info['bank'] = ''
55info['payment_possible'] = True
56info['type_description'] = fee_dict['description']
57info['pay_bill_to'] = student_record.name
58info['student_id'] = student_id
59info['student_name'] = student_record.name
60info['type'] = 'online'
61info['status'] = 'started'
62info['session_id'] = fee_dict['next_session_id']
63info['item'] = student_record.course
64info['category'] = 'schoolfee'
65info['student_email'] = student_record.email
66now = DateTime.DateTime()
67info['date'] = now
[3872]68info['pay_ship_to'] = "Ambrose Alli University Ekpoma"
[3841]69timestamp = "%d" % int(now.timeTime()*1000)
70info['order_id'] = "%s%s" % (student_id[1:],timestamp)
71p_id = "p%s" % timestamp
[3872]72info['surcharge'] = interswitch_amount = 300
[3898]73amount = fee_dict['all']
[3841]74
[3898]75bt_amount = 4000
76aaue_split = 1000
77info['amount'] = amount + bt_amount + aaue_split   
78
[3841]79if student_id is None:
80    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
81
82if True:
[3906]83    info['action'] = "https://webpay.interswitchng.com/paydirect/webpay/pay.aspx"
[3841]84else:
85    #pass
86    #return None
87    info['action'] = "%s/payments/%s/simulate_callback" % (student.absolute_url(),p_id)
88
89
90if "payments" not in student.objectIds():
91    student.invokeFactory('PaymentsFolder','payments')
92    payments = getattr(student,'payments')
93    d = {}
94    d['Title'] = 'Payments'
95    payments.getContent().edit(mapping=d)
96    wftool.doActionFor(payments,'open')
97else:
98    payments = getattr(student,'payments')
99if request.has_key('epayment'):
100    return context.interswitch_form(info=info)
101
102
103payments.invokeFactory('Payment', p_id)
104payment = getattr(payments,p_id)
105wftool.doActionFor(payment,'open')
106d = {}
107d.update(info)
108payment.getContent().edit(mapping=d)
109
110
111info['callback_url'] = "%s/payments/%s/interswitch_cb?echo=%s" % (student.absolute_url(),
112                                                                  p_id,
113                                                                  p_id)
[3872]114                                                                 
[3841]115
[3872]116                                                         
117
[3841]118logger.info('%(student_id)s initiated online school fee payment with order_id %(order_id)s and callback url %(callback_url)s' % info)
119payment_fields = (('product_id','site_id'),
120                  ('site_redirect_url','callback_url'),
121                  ('Currency','currency_id'),
122                  ('cust_id','student_id'),
123                  ('cust_id_desc','type_description'),
124                  ('cust_name','student_name'),
125                  ('txn_ref','order_id'),
126                  ('Amount','amount'),
127                  )
128args = {}
129for arg,field in payment_fields:
130    args[arg] = info[field]
131
132
[3898]133
[3872]134#getSchoolFee provides pure school fee, the other fees have to be added
[3898]135total_amount = 100* (amount + interswitch_amount + bt_amount + aaue_split)   
[3872]136
137
[3898]138
[3841]139xmldict = {}
140xmldict['detail_ref'] = args['txn_ref']
141xmldict['department'] = student_record.department
142xmldict['faculty'] = student_record.faculty
[3872]143xmldict['amount'] = "%d" % int(100*amount)
[3841]144xmldict['bt_amount'] = "%d" % int(100*bt_amount)
[3872]145
[4021]146if student_record.mode in ('ug_ft','ug_pt','pg_ft','pgd_ft'):
[3872]147    xmldict['aaue_acct'] = "6020008887"
148    xmldict['bank_id'] = '123'
[3841]149else:
[3872]150    xmldict['aaue_acct'] = "0000000000000"
151    xmldict['bank_id'] = '0'
[3841]152
[3872]153xmldict['aaue_split'] = "%d" % int(100*aaue_split)
[3841]154
155xmltext = """<payment_item_detail>
[3872]156<item_details detail_ref="%(detail_ref)s" college="aaue" department="%(department)s" faculty="%(faculty)s" >
157<item_detail item_id="1" item_name="AAUE School Fee" item_amt="%(amount)s" bank_id="123" acct_num="6020008887" />
158<item_detail item_id="2" item_name="AAUE Split" item_amt="%(aaue_split)s" bank_id="123" acct_num="6020008887" />
[4014]159<item_detail item_id="3" item_name="BT" item_amt="%(bt_amount)s" bank_id="117" acct_num="6012015294" />
[3841]160</item_details>
161</payment_item_detail>""" % xmldict
162
163info['xml_data'] = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
164
165args['Amount'] = "%d" % (total_amount)
166args['site_name'] = "aaue.waeup.org"
167args['cust_name_desc'] = "Student Name"
168args['pay_item_id'] = pay_item_id
[3872]169args['pay_item_name'] = "Ambrose Alli University Ekpoma Tuition Payments"
[3841]170args['payment_params'] = 'college_split'
171#args['xml_data'] = ''
[5255]172#args['xml_data'] = xmltext   # info['xml_data']can be used instead
[3841]173info['args'] = args
174
[4021]175return context.goto_interswitch_form(info=info)
Note: See TracBrowser for help on using the repository browser.