Ignore:
Timestamp:
21 May 2015, 11:00:24 (10 years ago)
Author:
Henrik Bettermann
Message:

Tickets must not be submitted to Interswitch if they are older than 1 day.

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

Legend:

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

    r12509 r12973  
    1717##
    1818import grok
     19from datetime import datetime, timedelta
    1920from zope.component import getUtility
    2021from waeup.kofa.interfaces import IKofaUtils
     
    165166        if self.context.p_state == 'paid':
    166167            return _("Payment ticket can't be re-sent to CollegePAY.")
     168        tz = getUtility(IKofaUtils).tzinfo
     169        time_delta = datetime.utcnow() - self.context.creation_date
     170        if time_delta.seconds > 3600:
     171            return _("This payment ticket is too old. Please create a new ticket.")
    167172        student = self.context.student
    168173        certificate = getattr(student['studycourse'],'certificate',None)
     
    224229            return _("Payment ticket can't be send to CollegePAY. "
    225230                     "Application period has expired.")
     231        tz = getUtility(IKofaUtils).tzinfo
     232        time_delta = datetime.utcnow() - self.context.creation_date
     233        if time_delta.seconds > 3600:
     234            return _("This payment ticket is too old. Please create a new ticket.")
    226235        self.applicant = self.context.__parent__
    227236        self.amount_auth = int(100 * self.context.amount_auth)
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py

    r11767 r12973  
    1717##
    1818import os
    19 from datetime import datetime
     19from datetime import datetime, timedelta, date
    2020from zope.component import createObject, getUtility
    2121from zope.catalog.interfaces import ICatalog
     
    5252            self.browser.contents)
    5353        self.payment_url = self.browser.url
     54        self.payment = self.student['payments'][self.value]
    5455
    5556    def test_interswitch_form(self):
     
    9495            self.browser.contents)
    9596
     97    def test_interswitch_form_ticket_expired(self):
     98        # Manager can access InterswitchForm
     99        self.browser.getLink("CollegePAY", index=0).click()
     100        self.assertMatches('...<input type="hidden" name="pay_item_id" />...',
     101                           self.browser.contents)
     102        self.assertMatches('...Total Amount Authorized:...',
     103                           self.browser.contents)
     104        self.assertEqual(self.student.current_mode, 'ug_ft')
     105        self.assertMatches(
     106            '...<input type="hidden" name="amount" value="4000000" />...',
     107            self.browser.contents)
     108        delta = timedelta(minutes=61)
     109        self.payment.creation_date -= delta
     110        self.browser.open(self.payment_url)
     111        self.browser.getLink("CollegePAY", index=0).click()
     112        self.assertMatches(
     113            '...This payment ticket is too old. Please create a new ticket...',
     114            self.browser.contents)
     115        delta = timedelta(minutes=2)
     116        self.payment.creation_date += delta
     117        self.browser.open(self.payment_url)
     118        self.browser.getLink("CollegePAY", index=0).click()
     119        self.assertMatches('...Total Amount Authorized:...',
     120                           self.browser.contents)
     121
    96122class InterswitchTestsApplicants(ApplicantsFullSetup):
    97123    """Tests for the Interswitch payment gateway.
     
    116142        self.assertMatches('...ticket created...',
    117143                           self.browser.contents)
    118         #ctrl = self.browser.getControl(name='val_id')
    119         #value = ctrl.options[0]
    120         #self.browser.getLink(value).click()
     144        self.payment = self.applicant.values()[0]
    121145        self.payment_url = self.browser.url
    122146
     
    134158            '...<input type="hidden" name="amount" value="100000" />...',
    135159            self.browser.contents)
     160        delta = timedelta(minutes=61)
     161        self.payment.creation_date -= delta
     162        self.browser.open(self.payment_url)
     163        self.browser.getLink("CollegePAY", index=0).click()
     164        self.assertMatches(
     165            '...This payment ticket is too old. Please create a new ticket...',
     166            self.browser.contents)
     167        delta = timedelta(minutes=2)
     168        self.payment.creation_date += delta
     169        self.browser.getLink("CollegePAY", index=0).click()
     170        self.assertMatches('...Total Amount Authorized:...',
     171                           self.browser.contents)
    136172
Note: See TracChangeset for help on using the changeset viewer.