Ignore:
Timestamp:
6 Jul 2021, 05:52:21 (3 years ago)
Author:
Henrik Bettermann
Message:

Use IPayer adapter.

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

Legend:

Unmodified
Added
Removed
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/helpers.py

    r16515 r16528  
    361361        notify(grok.ObjectModifiedEvent(payment))
    362362        return False, msg, log
    363     if payment.r_amount_approved != payment.amount_auth:
    364         msg = _('Callback amount does not match.')
     363    if payment.r_amount_approved != payment.net_amt:
     364        msg = _('Callback amount does not match net amount.')
    365365        log = 'unsuccessful callback for %s payment %s: callback amount %s does not match' % (
    366366            payment.p_category, payment.p_id, amount)
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/paydirectbrowser.py

    r16496 r16528  
    2626from waeup.kofa.browser.layout import UtilityView, KofaPage, KofaFormPage, action
    2727from waeup.kofa.browser.viewlets import ManageActionButton
     28from waeup.kofa.payments.interfaces import IPayer
    2829from waeup.kofa.students.interfaces import IStudentsUtils
    2930from waeup.kofa.students.browser import OnlinePaymentDisplayFormPage as OPDPStudent
     
    117118                self.gateway_url, True)
    118119            if result_xml.startswith('Connection error'):
     120                IPayer(self.context).payer.writeLogMessage(self, result_xml)
    119121                return result_xml
    120122            doc=parseString(result_xml)
    121123            if not doc.getElementsByTagName('ResponseCode'):
     124                IPayer(self.context).payer.writeLogMessage(self, 'invalid callback')
    122125                return _('Invalid callback from Interswitch')
    123126            rc = doc.getElementsByTagName('ResponseCode')[0].firstChild.data
     127            IPayer(self.context).payer.writeLogMessage(self, 'response code: %s' % rc)
    124128            if rc not in ('100', '108'):
    125129                return 'Error response code from Interswitch: %s' % rc
     
    148152    @action('Requery now', style='primary')
    149153    def fetch(self):
    150         student = self.context.student
    151154        success, msg, log = fetch_booking_details(
    152155            self.context, self.merchant_id, self.gateway_host,
    153156            self.gateway_url, self.https)
    154         student.writeLogMessage(self, log)
     157        IPayer(self.context).payer.writeLogMessage(self, log)
    155158        if not success:
    156159            self.flash(msg, type='warning')
    157160            self.redirect(self.url(self.context, '@@index'))
    158161            return
    159         write_payments_log(student.student_id, self.context)
    160         flashtype, msg, log = self.context.doAfterStudentPayment()
     162        write_payments_log(IPayer(self.context).id, self.context)
     163        flashtype, msg, log = IPayer(self.context).doAfterPayment()
    161164        if log is not None:
    162             student.writeLogMessage(self, log)
     165            IPayer(self.context).payer.writeLogMessage(self, log)
    163166        self.flash(msg, type=flashtype)
    164         self.redirect(self.url(self.context, '@@index'))
    165167        return
    166168
     
    192194            self.context.gateway_amt = self.gateway_amt
    193195            self.context.r_company = u'interswitch'
    194         return
    195 
    196     @action('Requery now', style='primary')
    197     def fetch(self):
    198         applicant = self.context.__parent__
    199         success, msg, log = fetch_booking_details(
    200             self.context, self.merchant_id, self.gateway_host,
    201             self.gateway_url, self.https)
    202         applicant.writeLogMessage(self, log)
    203         if not success:
    204             self.flash(msg, type='warning')
    205             self.redirect(self.url(self.context, '@@index'))
    206             return
    207         write_payments_log(applicant.applicant_id, self.context)
    208         flashtype, msg, log = self.context.doAfterApplicantPayment()
    209         if log is not None:
    210             applicant.writeLogMessage(self, log)
    211         self.flash(msg, type=flashtype)
    212196        return
    213197
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py

    r16514 r16528  
    303303        payment.p_session = self.student.current_session
    304304        payment.p_item = u'My Certificate'
    305         # p6214352306153 has been manuylly set completed by Interswitch
     305        # p6214352306153 has been manually set completed by Interswitch
    306306        payment.p_id = u'p6214352306153'
    307         payment.amount_auth = 700.0 # 300 will be added
     307        payment.amount_auth = 10.0 # 300 will be added
    308308        self.student['payments'][payment.p_id] = payment
    309309        result_xml = get_SOAP_response_paydirect(
     
    314314        amount=float(doc.getElementsByTagName('Amount')[0].firstChild.data)
    315315        self.assertEqual(status, 'Completed')
    316         self.assertEqual(amount, payment.amount_auth + 300)
     316        self.assertEqual(amount, 1000)
    317317        self.assertEqual(refnumber, '60336214352306153')
    318318        # Now we login and check what will happen with the student after payment
     
    321321        self.browser.getLink("Pay via Interswitch PAYDirect").click()
    322322        # 300 has been added
    323         self.assertEqual(payment.amount_auth, 1000)
     323        self.assertEqual(payment.amount_auth, 310)
     324        self.assertEqual(payment.net_amt, 10)
    324325        # Reference number has been saved
    325326        self.browser.getControl("Requery").click()
Note: See TracChangeset for help on using the changeset viewer.