Ignore:
Timestamp:
3 Aug 2017, 04:00:00 (7 years ago)
Author:
Henrik Bettermann
Message:

Add requery view and button.

Location:
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/browser.py

    r14750 r14753  
    6161        return self.view.url(self.view.context, self.target)
    6262
     63class RemitaRequestPaymentStatusActionButtonStudent(ManageActionButton):
     64    grok.order(2)
     65    grok.context(INigeriaOnlinePayment)
     66    grok.view(OPDPStudent)
     67    grok.require('waeup.payStudent')
     68    icon = 'actionicon_call.png'
     69    text = _('Requery Remita Payment Status')
     70    target = 'request_payment_status'
     71
     72    @property
     73    def target_url(self):
     74        if not module_activated(self.context.student.current_session):
     75            return ''
     76        if self.context.p_state in ('paid', 'waived'):
     77            return ''
     78        return self.view.url(self.view.context, self.target)
     79
     80
     81class RemitaVerifyPaymentStatusActionButtonStudent(ManageActionButton):
     82    grok.order(3)
     83    grok.context(INigeriaOnlinePayment)
     84    grok.view(OPDPStudent)
     85    grok.require('waeup.manageStudent')
     86    icon = 'actionicon_call.png'
     87    text = _('Verify Remita Payment Status')
     88    target = 'verify_payment_status'
     89
     90    @property
     91    def target_url(self):
     92        if not module_activated(self.context.student.current_session):
     93            return ''
     94        if self.context.p_state != 'paid' \
     95            or self.context.r_company != u'remita':
     96            return ''
     97        return self.view.url(self.view.context, self.target)
     98
    6399# Webservice request views
    64100
    65 class RemitaPaymentRequestWebservicePageStudent(UtilityView, grok.View):
     101class RemitaRequestPaymentStatusPageStudent(UtilityView, grok.View):
    66102    """ Request webservice view for the Remita gateway.
    67103    """
     
    118154        self.redirect(self.url(self.context, '@@index'))
    119155        return
     156
     157class RemitaVerifyPaymentStatusPageStudent(UtilityView, grok.View):
     158    """ Request webservice view for the Remita gateway.
     159    """
     160    grok.context(INigeriaStudentOnlinePayment)
     161    grok.name('verify_payment_status')
     162    grok.require('waeup.payStudent')
     163
     164    # Here we use Remita test portal data
     165    merchantId = '2547916'
     166    host = 'www.remitademo.net'
     167    https = False
     168    api_key = '1946'
     169
     170    def update(self):
     171        if not module_activated(self.context.student.current_session):
     172            return
     173        if self.context.p_state  != 'paid' \
     174            or self.context.r_company != u'remita':
     175            self.flash(_('This ticket has not been paid.'), type='danger')
     176            return
     177        student = self.context.student
     178        RRR = self.context.r_pay_reference
     179        if not RRR:
     180            self.flash(_('Remita Retrieval Reference not found.'), type='danger')
     181            return
     182
     183        # Remita sends a POST request which may contain more information
     184        # if a payment was not successful.
     185        resp = self.request.form
     186        if resp and resp.get('statuscode') not in (None, '025', '00', '01'):
     187            self.flash('Transaction status message from Remita: %s'
     188                % resp.get('status'), type='warning')
     189
     190        success, msg, log = query_remita(
     191            self.context,
     192            self.merchantId,
     193            self.api_key,
     194            RRR,
     195            self.host,
     196            self.https,
     197            True)
     198
     199        student.writeLogMessage(self, log)
     200        if not success:
     201            self.flash(msg, type='danger')
     202            return
     203        write_payments_log(student.student_id, self.context)
     204        flashtype, msg, log = self.context.doAfterStudentPayment()
     205        if log is not None:
     206            student.writeLogMessage(self, log)
     207        self.flash(msg, type=flashtype)
     208        return
     209
     210    def render(self):
     211        self.redirect(self.url(self.context, '@@index'))
     212        return
     213
    120214
    121215# Forwarding pages
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/remita/helpers.py

    r14743 r14753  
    3030        merchantId, serviceTypeId, api_key, orderId,
    3131        amount, responseurl, host, url, https, fullname, email, lineitems):
    32     hashargs =  merchantId + serviceTypeId + orderId + amount + responseurl + api_key
     32    hashargs =  merchantId + serviceTypeId + orderId + str(amount) + responseurl + api_key
    3333    hashvalue = hashlib.sha512(hashargs).hexdigest()
    3434    headers={
Note: See TracChangeset for help on using the changeset viewer.