source: main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py @ 11846

Last change on this file since 11846 was 11846, checked in by Henrik Bettermann, 10 years ago

Add interswitch module.

Disable clearance payments.

File size: 4.7 KB
Line 
1## $Id: browser.py 11797 2014-09-19 16:00:43Z henrik $
2##
3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18import httplib
19import hashlib
20import grok
21from zope.interface import Interface
22from zope.component import queryAdapter
23from kofacustom.nigeria.interswitch.browser import (
24    InterswitchPaymentRequestWebservicePageStudent,
25    InterswitchPaymentRequestWebservicePageApplicant,
26    InterswitchPageStudent, InterswitchPageApplicant,
27    )
28from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
29from waeup.aaue.applicants.interfaces import ICustomApplicantOnlinePayment
30from waeup.aaue.interfaces import MessageFactory as _
31
32PRODUCT_ID = '119'
33SITE_NAME = 'aaue.waeup.org'
34PROVIDER_ACCT = '1010764827'
35PROVIDER_BANK_ID = '117'
36PROVIDER_ITEM_NAME = 'BT Education'
37INSTITUTION_NAME = 'AAU Ekpoma'
38CURRENCY = '566'
39GATEWAY_AMT = 250.0
40#QUERY_URL = 'https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx'
41#QUERY_URL = 'https://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryURL.aspx'
42
43POST_ACTION = 'https://webpay.interswitchng.com/paydirect/webpay/pay.aspx'
44#POST_ACTION = 'https://testwebpay.interswitchng.com/test_paydirect/webpay/pay.aspx'
45
46HOST = 'webpay.interswitchng.com'
47#HOST = 'testwebpay.interswitchng.com'
48
49URL = '/paydirect/services/TransactionQueryWs.asmx'
50#URL = '/test_paydirect/services/TransactionQueryWs.asmx'
51httplib.HTTPConnection.debuglevel = 0
52
53
54class CustomInterswitchPageApplicant(InterswitchPageApplicant):
55    """ View which sends a POST request to the Interswitch
56    CollegePAY payment gateway.
57    """
58    grok.context(ICustomApplicantOnlinePayment)
59    grok.template('applicant_goto_interswitch')
60    action = POST_ACTION
61    site_name = SITE_NAME
62    currency = CURRENCY
63    pay_item_id = '11900'
64    product_id = PRODUCT_ID
65    mac = 'E6BA6CBBA9AF2871EE25C32C8D57C98895B9B001DC5B9CB2C463E2A9BDA44A3F1260C8A364F33789CDF74CB3EE7E6EF5D94F48D3AF7B727E75D97F07618DFA6D'
66
67    def interswitch_img_url(self):
68        return interswitch_img_url(self)
69
70    def update(self):
71
72        super(CustomInterswitchPageApplicant, self).update()
73        xmldict = {}
74        provider_amt = 1000.0
75        xmldict['institution_acct'] = '1010835352'
76        xmldict['institution_bank_id'] = '117'
77        xmldict['detail_ref'] = self.context.p_id
78        xmldict['provider_amt'] = 100 * provider_amt
79        xmldict['provider_acct'] = PROVIDER_ACCT
80        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
81        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
82        xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT)
83        xmldict['institution_item_name'] = self.context.p_category
84        xmldict['institution_name'] = INSTITUTION_NAME
85        # Interswitch amount is not part of the xml data
86        xmltext = """<payment_item_detail>
87<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
88<item_detail item_id="1" item_name="%(institution_item_name)s" item_amt="%(institution_amt)d" bank_id="%(institution_bank_id)s" acct_num="%(institution_acct)s" />
89<item_detail item_id="2" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
90</item_details>
91</payment_item_detail>""" % xmldict
92        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
93        self.context.provider_amt = provider_amt
94        self.context.gateway_amt = GATEWAY_AMT
95
96        hashargs = (
97            self.context.p_id +
98            PRODUCT_ID +
99            self.pay_item_id +
100            str(int(self.amount_auth)) +
101            self.site_redirect_url +
102            self.mac)
103        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
104
105        return
106
107
108class CustomInterswitchPaymentRequestWebservicePageApplicant(
109    InterswitchPaymentRequestWebservicePageApplicant):
110    """ Request webservice view for the CollegePAY gateway
111    """
112    grok.context(ICustomApplicantOnlinePayment)
113    product_id = PRODUCT_ID
114    gateway_host = HOST
115    gateway_url = URL
Note: See TracBrowser for help on using the repository browser.