Changeset 13581 for main


Ignore:
Timestamp:
10 Jan 2016, 22:06:10 (9 years ago)
Author:
Henrik Bettermann
Message:

Add buttons and pages to verify CollegePay? payments.

Location:
main/kofacustom.nigeria/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/CHANGES.txt

    r13387 r13581  
    441.3.dev0 (unreleased)
    55=====================
     6
     7- Add buttons and pages to verify CollegePay payments.
    68
    79- Implement Interswitch JSON transaction query. This webservice is
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/browser.py

    r13580 r13581  
    3434from kofacustom.nigeria.interfaces import MessageFactory as _
    3535
     36# Buttons
     37
    3638class InterswitchActionButtonStudent(ManageActionButton):
    3739    grok.order(1)
     
    7375    grok.require('waeup.payApplicant')
    7476
     77class InterswitchVerifyWebserviceActionButtonStudent(ManageActionButton):
     78    grok.order(3)
     79    grok.context(INigeriaOnlinePayment)
     80    grok.view(OPDPStudent)
     81    grok.require('waeup.manageStudent')
     82    icon = 'actionicon_call.png'
     83    text = _('Verify Payment')
     84    target = 'verify_payment'
     85
     86    @property
     87    def target_url(self):
     88        if self.context.p_state != 'paid':
     89            return ''
     90        return self.view.url(self.view.context, self.target)
     91
     92class InterswitchVerifyWebserviceActionButtonApplicant(
     93    InterswitchVerifyWebserviceActionButtonStudent):
     94    grok.view(OPDPApplicant)
     95    grok.require('waeup.manageApplication')
     96
     97
     98# Webservice request views
     99
    75100class InterswitchPaymentRequestWebservicePageStudent(UtilityView, grok.View):
    76101    """ Request webservice view for the CollegePAY gateway
     
    146171        self.redirect(self.url(self.context, '@@index'))
    147172        return
     173
     174class InterswitchPaymentVerifyWebservicePageStudent(UtilityView, grok.View):
     175    """ Verify payment view for the CollegePAY gateway
     176    """
     177    grok.context(INigeriaStudentOnlinePayment)
     178    grok.name('verify_payment')
     179    grok.require('waeup.manageStudent')
     180
     181    product_id = None
     182    gateway_host = None
     183    gateway_url = None
     184    https = True
     185    mac = None
     186
     187    def update(self):
     188        if self.context.p_state  != 'paid':
     189            self.flash(_('This ticket has not been paid.'), type='danger')
     190            return
     191        student = self.context.student
     192        success, msg, log = query_interswitch(
     193            self.context, self.product_id,
     194            self.gateway_host, self.gateway_url,
     195            self.https, self.mac)
     196        student.writeLogMessage(self, log)
     197        if not success:
     198            self.flash(msg, type='danger')
     199            return
     200        self.flash(msg)
     201        return
     202
     203    def render(self):
     204        self.redirect(self.url(self.context, '@@index'))
     205        return
     206
     207class InterswitchPaymentVerifyWebservicePageApplicant(UtilityView, grok.View):
     208    """ Verify payment view for the CollegePAY gateway
     209    """
     210    grok.context(INigeriaApplicantOnlinePayment)
     211    grok.name('verify_payment')
     212    grok.require('waeup.manageApplication')
     213
     214    product_id = None
     215    gateway_host = None
     216    gateway_url = None
     217    https = True
     218    mac = None
     219
     220    def update(self):
     221        if self.context.p_state != 'paid':
     222            self.flash(_('This ticket has not been paid.'), type='danger')
     223            return
     224        applicant = self.context.__parent__
     225        success, msg, log = query_interswitch(
     226            self.context, self.product_id,
     227            self.gateway_host, self.gateway_url,
     228            self.https, self.mac)
     229        applicant.writeLogMessage(self, log)
     230        if not success:
     231            self.flash(msg, type='danger')
     232            return
     233        self.flash(msg)
     234        return
     235
     236    def render(self):
     237        self.redirect(self.url(self.context, '@@index'))
     238        return
     239
     240# Forwarding pages
    148241
    149242class InterswitchPageStudent(KofaPage):
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py

    r13387 r13581  
    133133    payment.p_state = 'paid'
    134134    payment.payment_date = datetime.utcnow()
    135     msg = _('Successful callback received')
     135    msg = _('Successful callback received.')
    136136    log = 'valid callback for %s payment %s: %s' % (
    137137        payment.p_category, payment.p_id, sr)
Note: See TracChangeset for help on using the changeset viewer.