Ignore:
Timestamp:
7 Dec 2012, 08:59:30 (12 years ago)
Author:
Henrik Bettermann
Message:

Changes according to r9775.

Use classes defined in kofacustom.nigeria.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.futminna/trunk/src/waeup/futminna/interswitch/browser.py

    r9750 r9785  
    1919import grok
    2020from zope.component import getUtility
    21 from kofacustom.nigeria.interswitch.helpers import query_interswitch
    22 from waeup.kofa.browser.layout import KofaPage, UtilityView
     21from kofacustom.nigeria.interswitch.browser import (
     22    InterswitchPaymentRequestWebservicePageStudent
     23    )
     24from waeup.kofa.browser.layout import KofaPage
    2325from waeup.kofa.interfaces import RETURNING, CLEARED, IKofaUtils
    2426from waeup.kofa.utils.helpers import to_timezone
    25 from waeup.kofa.students.viewlets import ApprovePaymentActionButton as APABStudent
    2627from waeup.futminna.students.interfaces import ICustomStudentOnlinePayment
    2728from waeup.futminna.interfaces import MessageFactory as _
     
    3435INSTITUTION_NAME = 'FUTMinna'
    3536CURRENCY = '566'
     37GATEWAY_AMT = 300.0
    3638#QUERY_URL = 'https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx'
    3739#QUERY_URL = 'https://testwebpay.interswitchng.com/test_paydirect/services/TransactionQueryURL.aspx'
     
    4446#URL = '/test_paydirect/services/TransactionQueryWs.asmx'
    4547httplib.HTTPConnection.debuglevel = 0
    46 
    47 class InterswitchActionButtonStudent(APABStudent):
    48     grok.order(1)
    49     grok.context(ICustomStudentOnlinePayment)
    50     grok.require('waeup.payStudent')
    51     icon = 'actionicon_pay.png'
    52     text = _('CollegePAY')
    53     target = 'goto_interswitch'
    54 
    55     @property
    56     def target_url(self):
    57         if self.context.p_state != 'unpaid':
    58             return ''
    59         return self.view.url(self.view.context, self.target)
    60 
    61 class InterswitchRequestWebserviceActionButtonStudent(APABStudent):
    62     grok.order(2)
    63     grok.context(ICustomStudentOnlinePayment)
    64     grok.require('waeup.payStudent')
    65     icon = 'actionicon_call.png'
    66     text = _('Requery CollegePAY')
    67     target = 'request_webservice'
    6848
    6949class InterswitchPageStudent(KofaPage):
     
    11191        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
    11292        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
    113         provider_amt = 1500
     93        provider_amt = 1500.0
    11494        xmldict['provider_amt'] = 100 * provider_amt
    11595
     
    124104        if self.context.p_category == 'schoolfee':
    125105            xmldict['institution_amt'] = 100 * (
    126                 self.context.amount_auth - provider_amt - 300)
     106                self.context.amount_auth - provider_amt - GATEWAY_AMT)
    127107            if self.context.student.current_mode in ('pg_ft'):
    128108                self.pay_item_id = "11703"
     
    183163        elif self.context.p_category == 'clearance':
    184164            xmldict['institution_amt'] = 100 * (
    185                 self.context.amount_auth - 300)
     165                self.context.amount_auth - GATEWAY_AMT)
    186166            xmldict['institution_acct'] = "1750005063"
    187167            xmldict['institution_bank_id'] = '120'
    188168            self.pay_item_id = "11706"
     169            provider_amt = 0.0
    189170
    190171        elif 'maintenance' in self.context.p_category:
    191172            xmldict['institution_amt'] = 100 * (
    192                 self.context.amount_auth - 300)
     173                self.context.amount_auth - GATEWAY_AMT)
    193174            xmldict['institution_acct'] = "2018856637"
    194175            xmldict['institution_bank_id'] = '8'
    195176            self.pay_item_id = "11705"
     177            provider_amt = 0.0
    196178
    197179        # Interswitch amount is not part of the xml data
     
    220202
    221203        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
     204        self.context.provider_amt = provider_amt
     205        self.context.gateway_amt = GATEWAY_AMT
    222206        return
    223207
    224 class InterswitchPaymentRequestWebservicePageStudent(UtilityView, grok.View):
     208class InterswitchPaymentRequestWebservicePageStudent(
     209    InterswitchPaymentRequestWebservicePageStudent):
    225210    """ Request webservice view for the CollegePAY gateway
    226211    """
    227212    grok.context(ICustomStudentOnlinePayment)
    228     grok.name('request_webservice')
    229     grok.require('waeup.payStudent')
    230 
    231     def update(self):
    232         if self.context.p_state == 'paid':
    233             self.flash(_('This ticket has already been paid.'))
    234             return
    235         student = self.context.student
    236         success, msg, log = query_interswitch(
    237             self.context, PRODUCT_ID, HOST, URL)
    238         student.writeLogMessage(self, log)
    239         if not success:
    240             self.flash(msg)
    241             return
    242         success, msg, log = self.context.doAfterStudentPayment()
    243         if log is not None:
    244             student.writeLogMessage(self, log)
    245         self.flash(msg)
    246         return
    247 
    248     def render(self):
    249         self.redirect(self.url(self.context, '@@index'))
    250         return
     213    product_id = PRODUCT_ID
     214    gateway_host = HOST
     215    gateway_url = URL
Note: See TracChangeset for help on using the changeset viewer.