Ignore:
Timestamp:
14 Mar 2012, 09:41:09 (13 years ago)
Author:
Henrik Bettermann
Message:

Add InterswitchPage? which generates POST requests for the Interswitch CollegePAY gateway (moved from trunk).

Location:
main/waeup.custom/trunk/src/waeup/custom/students
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.custom/trunk/src/waeup/custom/students/browser.py

    r7822 r7879  
    2121    FriendlyDateWidget, FriendlyDateDisplayWidget
    2222    )
    23 from waeup.custom.students.interfaces import (
    24     IStudent, IStudentPersonal, IStudentClearance, IStudentClearanceEdit
    25     )
     23from waeup.kofa.browser.layout import KofaPage
     24from waeup.kofa.students.interfaces import IStudentOnlinePayment
    2625from waeup.kofa.students.browser import (
    2726    StudentPersonalDisplayFormPage, StudentPersonalManageFormPage,
     
    2928    StudentClearanceDisplayFormPage
    3029    )
     30from waeup.kofa.students.viewlets import RequestCallbackActionButton
     31from waeup.custom.students.interfaces import (
     32    IStudent, IStudentPersonal, IStudentClearance, IStudentClearanceEdit
     33    )
     34from waeup.custom.interfaces import MessageFactory as _
    3135
    3236class StudentPersonalDisplayFormPage(StudentPersonalDisplayFormPage):
     
    6569    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    6670
     71class InterswitchActionButton(RequestCallbackActionButton):
     72    grok.order(2)
     73    icon = 'actionicon_pay.png'
     74    text = _('CollegePAY')
     75    target = 'goto_interswitch'
    6776
     77class RequestCallbackActionButton(RequestCallbackActionButton):
     78    grok.order(3)
     79    icon = 'actionicon_call.png'
     80    text = _('Request CollegePAY callback')
     81    target = 'callback'
     82
     83class InterswitchPage(KofaPage):
     84    """ View which sends a POST request to the Interswitch
     85    CollegePAY payment gateway.
     86    """
     87    grok.context(IStudentOnlinePayment)
     88    grok.name('goto_interswitch')
     89    grok.template('goto_interswitch')
     90    grok.require('waeup.payStudent')
     91
     92    label = _('Submit data to CollegePAY (Interswitch Payment Gateway)')
     93    submit_button = _('Submit')
     94
     95    # Uniben product data (to be removed later)
     96    product_id = '57'
     97    currency = '566'
     98    pay_item_id = '5700'
     99
     100    action = 'https://testwebpay.interswitchng.com/test_paydirect/webpay/pay.aspx'
     101    site_redirect_url = 'http://localhost?echo='
     102    site_name = 'xyz.waeup.org'
     103    provider_acct = '2345'
     104    provider_bank_id = '8'
     105    provider_item_name = 'Kofa Provider Fee'
     106    institution_acct = '1234'
     107    institution_bank_id = '9'
     108    institution_name = 'Sample University'
     109
     110    def update(self):
     111        if self.context.p_state != 'unpaid':
     112            self.flash(_("Payment ticket can't be re-send to CollegePAY."))
     113            self.redirect(self.url(self.context, '@@index'))
     114            return
     115        xmldict = {}
     116        self.student = self.context.getStudent()
     117        self.amount = (self.context.amount_auth + self.context.surcharge_1 +
     118            self.context.surcharge_2 + self.context.surcharge_3)
     119        self.local_date_time = str(self.context.creation_date)
     120        certificate = getattr(self.student['studycourse'],'certificate',None)
     121        if certificate is not None:
     122            xmldict['department'] = certificate.__parent__.__parent__.code
     123            xmldict['faculty'] = certificate.__parent__.__parent__.__parent__.code
     124        else:
     125            xmldict['department'] = None
     126            xmldict['faculty'] = None
     127        xmldict['detail_ref'] = self.context.p_id
     128        xmldict['provider_amt'] = self.context.surcharge_1
     129        xmldict['provider_acct'] = self.provider_acct
     130        xmldict['provider_bank_id'] = self.provider_bank_id
     131        xmldict['provider_item_name'] = self.provider_item_name
     132        xmldict['institution_amt'] = self.amount
     133        xmldict['institution_acct'] = self.institution_acct
     134        xmldict['institution_bank_id'] = self.institution_bank_id
     135        xmldict['institution_item_name'] = self.context.p_category
     136        xmldict['institution_name'] = self.institution_name
     137        xmltext = """<payment_item_detail>
     138<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     139<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" />
     140<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" />
     141</item_details>
     142</payment_item_detail>""" % xmldict
     143        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
     144        return
  • main/waeup.custom/trunk/src/waeup/custom/students/tests.py

    r7822 r7879  
    128128        #payment_url = self.browser.url
    129129        #self.browser.open(payment_url)
    130         self.browser.getLink("Request callback").click()
     130        self.browser.getLink("Request CollegePAY callback").click()
    131131        self.assertMatches('...Valid callback received...',
    132132                          self.browser.contents)
  • main/waeup.custom/trunk/src/waeup/custom/students/utils.py

    r7845 r7879  
    2020from waeup.kofa.students.utils import StudentsUtils
    2121from waeup.kofa.students.interfaces import IStudentsUtils
     22from waeup.custom.interfaces import MessageFactory as _
    2223
    2324def get_school_fee(student, surcharge):
     
    6768            academic_session = grok.getSite()['configuration'][session]
    6869        except KeyError:
    69             d['error'] = u'Session configuration object is not available.'
     70            d['error'] = _(u'Session configuration object is not available.')
    7071            return d
    7172        if category == 'transfer':
     
    8889            d['p_session'] += 1
    8990        if d['amount'] == 0:
    90             d['error'] = u'Amount could not be determined.'
     91            d['error'] = _(u'Amount could not be determined.')
    9192        return d
    9293
Note: See TracChangeset for help on using the changeset viewer.