Changeset 13381 for main


Ignore:
Timestamp:
2 Nov 2015, 13:42:10 (9 years ago)
Author:
Henrik Bettermann
Message:

Implement 2-product-id payments. Rewrite tests.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/interswitch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/interswitch/browser.py

    r13379 r13381  
    118118    currency = CURRENCY
    119119    pay_item_id = '101'
    120     mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
     120    #mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
     121    mac = '9718FA00B0F5070B388A9896ADCED9B2FB02D30F71E12E68BDADC63F6852A3496FF97D8A0F9DA9F753B911A49BB09BB87B55FD02046BD325C74C46C0123CF023'
    121122
    122123    def update(self):
     
    124125
    125126        ######################################
    126         error = 'Sorry, Interswitch payments are temporarily disabled.'
     127        #error = 'Sorry, Interswitch payments are temporarily disabled.'
    127128        ######################################
    128129
     
    163164        xmldict['institution_item_name'] = self.category
    164165        xmldict['institution_name'] = INSTITUTION_NAME
     166        provider_amt = 0.0
    165167
    166168        # PT
    167 
    168169        if school(student) == 'pt':
    169170            product_id = PRODUCT_ID_PT
     
    210211                xmldict['institution_acct'] = '1014066976'
    211212                xmldict['institution_bank_id'] = '117'
    212                 provider_amt = 0.0
    213213                gown_fee_amt = 2000.0
    214214                aaue_fl_fee_amt = 800.0
     
    227227</item_details>
    228228</payment_item_detail>""" % xmldict
     229            else:
     230                self.flash('Not applicable', type='danger')
     231                self.redirect(self.url(self.context, '@@index'))
     232                return
    229233
    230234        # REGULAR
    231 
    232235        else:
    233             pass
    234 
     236            product_id = PRODUCT_ID_REGULAR
     237            if self.context.p_category == 'schoolfee':
     238                self.pay_item_id = '101'
     239                xmldict['institution_bank_id'] = '117'
     240                xmldict['institution_acct'] = '1010827641'
     241                provider_amt = 1500.0
     242                xmldict['provider_amt'] = 100 * provider_amt
     243                aaue_share_amt = 1500.0
     244                xmldict['aaue_share_amt'] = 100 * aaue_share_amt
     245                joint_venture_amt = 1000.0
     246                xmldict['joint_venture_amt'] = 100 * joint_venture_amt
     247                xmldict['institution_amt'] = 100 * (
     248                    self.context.amount_auth
     249                    - provider_amt
     250                    - joint_venture_amt
     251                    - aaue_share_amt
     252                    - GATEWAY_AMT)
     253                xmltext = """<payment_item_detail>
     254<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     255<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" />
     256<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" />
     257<item_detail item_id="3" item_name="Joint Venture" item_amt="%(joint_venture_amt)d" bank_id="117" acct_num="1014066969" />
     258<item_detail item_id="4" item_name="AAUE Share" item_amt="%(aaue_share_amt)d" bank_id="11" acct_num="0030656377" />
     259</item_details>
     260</payment_item_detail>""" % xmldict
     261
     262            elif self.context.p_category == 'clearance':
     263                self.pay_item_id = '102'
     264                xmldict['institution_acct'] = '1010827641'
     265                xmldict['institution_bank_id'] = '117'
     266                xmldict['institution_amt'] = 100 * (
     267                    self.context.amount_auth - GATEWAY_AMT)
     268                xmltext = """<payment_item_detail>
     269<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     270<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" />
     271</item_details>
     272</payment_item_detail>""" % xmldict
     273
     274            elif self.context.p_category == 'union':
     275                self.pay_item_id = '103'
     276                xmldict['institution_acct'] = '1006360118'
     277                xmldict['institution_bank_id'] = '123'
     278                xmldict['institution_amt'] = 100 * (
     279                    self.context.amount_auth - GATEWAY_AMT)
     280                xmltext = """<payment_item_detail>
     281<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     282<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" />
     283</item_details>
     284</payment_item_detail>""" % xmldict
     285
     286            elif self.context.p_category == 'lapel':
     287                self.pay_item_id = '104'
     288                xmldict['institution_acct'] = '4010660109'
     289                xmldict['institution_bank_id'] = '51'
     290                xmldict['institution_amt'] = 100 * (
     291                    self.context.amount_auth - GATEWAY_AMT)
     292                xmltext = """<payment_item_detail>
     293<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     294<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" />
     295</item_details>
     296</payment_item_detail>""" % xmldict
     297
     298            elif self.context.p_category == 'welfare':
     299                self.pay_item_id = '105'
     300                xmldict['institution_acct'] = '1006407792'
     301                xmldict['institution_bank_id'] = '123'
     302                xmldict['institution_amt'] = 100 * (
     303                    self.context.amount_auth - GATEWAY_AMT)
     304                xmltext = """<payment_item_detail>
     305<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     306<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" />
     307</item_details>
     308</payment_item_detail>""" % xmldict
     309
     310            elif self.context.p_category == 'matric_gown':
     311                self.pay_item_id = '106'
     312                xmldict['institution_acct'] = '5060023429'
     313                xmldict['institution_bank_id'] = '51'
     314                xmldict['institution_amt'] = 100 * (
     315                    self.context.amount_auth - GATEWAY_AMT)
     316                xmltext = """<payment_item_detail>
     317<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     318<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" />
     319</item_details>
     320</payment_item_detail>""" % xmldict
     321
     322            elif self.context.p_category == 'concessional':
     323                self.pay_item_id = '107'
     324                xmldict['institution_acct'] = '1010835352'
     325                xmldict['institution_bank_id'] = '117'
     326                xmldict['institution_amt'] = 100 * (
     327                    self.context.amount_auth - GATEWAY_AMT)
     328                xmltext = """<payment_item_detail>
     329<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     330<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" />
     331</item_details>
     332</payment_item_detail>""" % xmldict
    235333
    236334        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
  • main/waeup.aaue/trunk/src/waeup/aaue/interswitch/tests.py

    r13379 r13381  
    6464        self.browser.getControl("Save").click()
    6565        self.browser.getControl("Add online").click()
    66         self.assertMatches('...ticket created...',
    67                            self.browser.contents)
     66        self.assertTrue('ticket created' in self.browser.contents)
    6867        #self.browser.getLink(value).click()
    69         self.assertMatches('...Amount Authorized...',
    70                            self.browser.contents)
    71         self.assertMatches(
    72             '...<span>1000.0</span>...',
    73             self.browser.contents)
     68        self.assertTrue('Amount Authorized' in self.browser.contents)
     69        self.assertTrue('<span>1000.0</span>' in self.browser.contents)
    7470        self.payment_url = self.browser.url
    7571
     
    7773        # Manager can access InterswitchForm
    7874        self.browser.getLink("CollegePAY", index=0).click()
    79         self.assertMatches('...Total Amount Authorized:...',
    80                            self.browser.contents)
    81         self.assertMatches(
    82             '...<input type="hidden" name="amount" value="100000" />...',
    83             self.browser.contents)
     75        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
     76        self.assertTrue(
     77            '<input type="hidden" name="amount" value="100000" />'
     78            in self.browser.contents)
    8479        delta = timedelta(days=8)
    8580        self.applicant.values()[0].creation_date -= delta
    8681        self.browser.open(self.payment_url)
    8782        self.browser.getLink("CollegePAY", index=0).click()
    88         self.assertMatches(
    89             '...This payment ticket is too old. Please create a new ticket...',
    90             self.browser.contents)
     83        self.assertTrue(
     84            'This payment ticket is too old. Please create a new ticket'
     85            in self.browser.contents)
    9186
    9287    @external_test
     
    9489
    9590        self.browser.open(self.payment_url + '/request_webservice')
    96         self.assertMatches('...Unsuccessful callback...',
    97                           self.browser.contents)
     91        self.assertTrue('Unsuccessful callback' in self.browser.contents)
    9892        # The payment is now in state failed
    99         self.assertMatches('...<span>Failed</span>...',
    100                           self.browser.contents)
     93        self.assertTrue('<span>Failed</span>' in self.browser.contents)
    10194
    10295class InterswitchTestsStudents(StudentsFullSetup):
     
    121114        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    122115        self.browser.getControl("Create ticket").click()
    123         self.assertMatches('...ticket created...',
    124                            self.browser.contents)
    125         ctrl = self.browser.getControl(name='val_id')
    126         self.value = ctrl.options[0]
    127         self.browser.getLink(self.value).click()
    128         self.assertMatches('...Amount Authorized...',
    129                            self.browser.contents)
    130         self.assertMatches(
    131             '...<span>51750.0</span>...',
    132             self.browser.contents)
     116        self.assertTrue('ticket created' in self.browser.contents)
     117        ctrl = self.browser.getControl(name='val_id')
     118        self.value = ctrl.options[0]
     119        self.browser.getLink(self.value).click()
     120        self.assertTrue('Amount Authorized' in self.browser.contents)
     121        self.assertTrue('<span>51750.0</span>' in self.browser.contents)
    133122        self.payment_url = self.browser.url
    134123        self.browser.getLink("CollegePAY", index=0).click()
     
    140129        self.student['payments']['xyz'] = acc_payment
    141130        self.browser.getLink("CollegePAY", index=0).click()
    142         self.assertMatches('...<input type="hidden" name="pay_item_id" value="105" />...',
     131        self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />'
     132                        in self.browser.contents)
     133        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
     134        self.assertEqual(self.student.current_mode, 'ug_pt')
     135        self.assertTrue(
     136            '<input type="hidden" name="amount" value="5175000" />'
     137            in self.browser.contents)
     138        self.assertTrue(
     139            'item_name="School Fee" item_amt="4600000" bank_id="7" '
     140            'acct_num="1014847058"' in self.browser.contents)
     141
     142    def test_interswitch_form_regular_school_fees(self):
     143        self.certificate.study_mode = 'ug_ft'
     144        self.student['studycourse'].entry_session = 2013
     145        self.student['studycourse'].certificate.school_fee_1 = 51750.0
     146        # Manager can access InterswitchForm
     147        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     148        self.browser.open(self.payments_path)
     149        IWorkflowState(self.student).setState('cleared')
     150        self.student.nationality = u'NG'
     151        self.browser.open(self.payments_path + '/addop')
     152        self.browser.getControl(name="form.p_category").value = ['schoolfee']
     153        self.browser.getControl("Create ticket").click()
     154        self.assertTrue('ticket created' in
    143155                           self.browser.contents)
    144         self.assertMatches('...Total Amount Authorized:...',
     156        ctrl = self.browser.getControl(name='val_id')
     157        self.value = ctrl.options[0]
     158        self.browser.getLink(self.value).click()
     159        self.assertTrue('Amount Authorized' in
    145160                           self.browser.contents)
    146         self.assertEqual(self.student.current_mode, 'ug_pt')
    147         self.assertMatches(
    148             '...<input type="hidden" name="amount" value="5175000" />...',
    149             self.browser.contents)
    150         self.assertMatches(
    151             '...item_name="School Fee" item_amt="4600000" bank_id="7" acct_num="1014847058"...',
    152             self.browser.contents)
     161        self.assertTrue('<span>51750.0</span>' in self.browser.contents)
     162        self.payment_url = self.browser.url
     163        self.browser.getLink("CollegePAY", index=0).click()
     164        self.assertTrue(
     165            'Please pay acceptance fee first' in self.browser.contents)
     166        acc_payment = createObject('waeup.StudentOnlinePayment')
     167        acc_payment.p_state = 'paid'
     168        acc_payment.p_category = 'clearance'
     169        self.student['payments']['xyz'] = acc_payment
     170        self.browser.getLink("CollegePAY", index=0).click()
     171        self.assertTrue('<input type="hidden" name="pay_item_id" value="101" />'
     172                        in self.browser.contents)
     173        self.assertTrue('Total Amount Authorized:'
     174                        in self.browser.contents)
     175        self.assertEqual(self.student.current_mode, 'ug_ft')
     176        self.assertTrue(
     177            '<input type="hidden" name="amount" value="5175000" />'
     178            in self.browser.contents)
     179        self.assertTrue(
     180            'item_name="School Fee" item_amt="4750000" bank_id="117" '
     181            'acct_num="1010827641"' in self.browser.contents)
    153182
    154183
     
    164193        self.browser.getControl(name="form.p_category").value = ['clearance']
    165194        self.browser.getControl("Create ticket").click()
    166         self.assertMatches('...ticket created...',
     195        self.assertTrue('ticket created' in  self.browser.contents)
     196        ctrl = self.browser.getControl(name='val_id')
     197        self.value = ctrl.options[0]
     198        self.browser.getLink(self.value).click()
     199        self.assertTrue('Amount Authorized' in self.browser.contents)
     200        self.assertTrue('<span>43050.0</span>' in  self.browser.contents)
     201        self.payment_url = self.browser.url
     202        self.browser.getLink("CollegePAY", index=0).click()
     203        self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />' in
    167204                           self.browser.contents)
    168         ctrl = self.browser.getControl(name='val_id')
    169         self.value = ctrl.options[0]
    170         self.browser.getLink(self.value).click()
    171         self.assertMatches('...Amount Authorized...',
    172                            self.browser.contents)
    173         self.assertMatches(
    174             '...<span>43050.0</span>...',
    175             self.browser.contents)
    176         self.payment_url = self.browser.url
    177         self.browser.getLink("CollegePAY", index=0).click()
    178         self.assertMatches('...<input type="hidden" name="pay_item_id" value="104" />...',
    179                            self.browser.contents)
    180         self.assertMatches('...Total Amount Authorized:...',
    181                            self.browser.contents)
    182         self.assertMatches(
    183             '...<input type="hidden" name="amount" value="5175000" />...',
    184             self.browser.contents)
    185         self.assertMatches(
    186             '...item_name="Acceptance Fee" item_amt="4280000" bank_id="117" acct_num="1014066976"...',
    187             self.browser.contents)
     205        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
     206        self.assertTrue(
     207            '<input type="hidden" name="amount" value="4305000" />'
     208            in self.browser.contents)
     209        self.assertTrue(
     210            'item_name="Acceptance Fee" item_amt="4000000" bank_id="117" '
     211            'acct_num="1014066976"' in self.browser.contents)
     212
     213    def test_interswitch_form_regular_acceptance_fees(self):
     214        self.certificate.study_mode = 'ug_ft'
     215        self.app['configuration']['2004'].clearance_fee = 43050.0
     216        # Manager can access InterswitchForm
     217        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     218        self.browser.open(self.payments_path)
     219        IWorkflowState(self.student).setState('admitted')
     220        self.student.nationality = u'NG'
     221        self.browser.open(self.payments_path + '/addop')
     222        self.browser.getControl(name="form.p_category").value = ['clearance']
     223        self.browser.getControl("Create ticket").click()
     224        self.assertTrue('ticket created' in self.browser.contents)
     225        ctrl = self.browser.getControl(name='val_id')
     226        self.value = ctrl.options[0]
     227        self.browser.getLink(self.value).click()
     228        self.assertTrue('Amount Authorized' in self.browser.contents)
     229        self.assertTrue('<span>43050.0</span>' in self.browser.contents)
     230        self.payment_url = self.browser.url
     231        self.browser.getLink("CollegePAY", index=0).click()
     232        self.assertTrue('<input type="hidden" name="pay_item_id" value="102" />'
     233                        in self.browser.contents)
     234        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
     235        self.assertTrue(
     236            '<input type="hidden" name="amount" value="4305000" />'
     237            in self.browser.contents)
     238        self.assertTrue(
     239            'item_name="Acceptance Fee" item_amt="4280000" bank_id="117" '
     240            'acct_num="1010827641"' in self.browser.contents)
     241
     242    def test_interswitch_form_welfare_fees(self):
     243        self.certificate.study_mode = 'ug_pt'
     244        self.app['configuration']['2004'].welfare_fee = 1567.0
     245        # Manager can access InterswitchForm
     246        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     247        self.browser.open(self.payments_path)
     248        IWorkflowState(self.student).setState('admitted')
     249        self.student.nationality = u'NG'
     250        self.browser.open(self.payments_path + '/addop')
     251        self.browser.getControl(name="form.p_category").value = ['welfare']
     252        self.browser.getControl("Create ticket").click()
     253        self.assertTrue('ticket created' in  self.browser.contents)
     254        ctrl = self.browser.getControl(name='val_id')
     255        self.value = ctrl.options[0]
     256        self.browser.getLink(self.value).click()
     257        self.assertTrue('Amount Authorized' in self.browser.contents)
     258        self.assertTrue(
     259            '<span>1567.0</span>' in self.browser.contents)
     260        self.payment_url = self.browser.url
     261        self.browser.getLink("CollegePAY", index=0).click()
     262        self.assertTrue('<div class="alert alert-danger">Not applicable</div>'
     263                        in self.browser.contents)
     264        self.certificate.study_mode = 'ug_ft'
     265        self.browser.getLink("CollegePAY", index=0).click()
     266        self.assertTrue('<input type="hidden" name="pay_item_id" value="105" />'
     267                           in self.browser.contents)
     268        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
     269        self.assertTrue(
     270            '<input type="hidden" name="amount" value="156700" />'
     271            in self.browser.contents)
     272        self.assertTrue(
     273            'item_name="AAU Student Welfare Assurance Fee" item_amt="131700" '
     274            'bank_id="123" acct_num="1006407792"'
     275            in self.browser.contents)
    188276
    189277    def test_interswitch_form_ticket_expired(self):
     
    199287        self.browser.open(self.payments_path + '/xyz')
    200288        self.browser.getLink("CollegePAY", index=0).click()
    201         self.assertMatches('...<input type="hidden" name="pay_item_id" value="104" />...',
    202                            self.browser.contents)
    203         self.assertMatches('...Total Amount Authorized:...',
    204                            self.browser.contents)
     289        self.assertTrue('<input type="hidden" name="pay_item_id" value="104" />'
     290                        in self.browser.contents)
     291        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
    205292        self.assertEqual(self.student.current_mode, 'ug_pt')
    206         self.assertMatches(
    207             '...<input type="hidden" name="amount" value="87600" />...',
    208             self.browser.contents)
     293        self.assertTrue(
     294            '<input type="hidden" name="amount" value="87600" />'
     295            in self.browser.contents)
    209296        delta = timedelta(days=8)
    210297        acc_payment.creation_date -= delta
    211298        self.browser.open(self.payments_path + '/xyz')
    212299        self.browser.getLink("CollegePAY", index=0).click()
    213         self.assertMatches(
    214             '...This payment ticket is too old. Please create a new ticket...',
    215             self.browser.contents)
     300        self.assertTrue(
     301            'This payment ticket is too old. Please create a new ticket'
     302            in self.browser.contents)
    216303        delta = timedelta(days=2)
    217304        acc_payment.creation_date += delta
    218305        self.browser.open(self.payments_path + '/xyz')
    219306        self.browser.getLink("CollegePAY", index=0).click()
    220         self.assertMatches('...Total Amount Authorized:...',
    221                            self.browser.contents)
     307        self.assertTrue('Total Amount Authorized:' in self.browser.contents)
    222308
    223309    @external_test
     
    230316        self.browser.getControl(name="form.p_category").value = ['schoolfee']
    231317        self.browser.getControl("Create ticket").click()
    232         self.assertMatches('...ticket created...',
    233                            self.browser.contents)
     318        self.assertTrue('ticket created' in self.browser.contents)
    234319        ctrl = self.browser.getControl(name='val_id')
    235320        self.value = ctrl.options[0]
     
    241326        # Now we can call the webservice
    242327        self.browser.open(self.payment_url + '/request_webservice')
    243         self.assertMatches('...Unsuccessful callback...',
    244                           self.browser.contents)
     328        self.assertTrue('Unsuccessful callback' in self.browser.contents)
    245329        # The payment is now in state failed ...
    246         self.assertMatches('...<span>Failed</span>...',
    247                           self.browser.contents)
     330        self.assertTrue('<span>Failed</span>' in self.browser.contents)
    248331        # ... and the catalog has been updated
    249332        cat = getUtility(ICatalog, name='payments_catalog')
     
    261344        payment.p_id = 'p3547789850240'
    262345        self.browser.open(self.payment_url + '/request_webservice')
    263         self.assertMatches('...Callback amount does not match...',
     346        self.assertTrue('Callback amount does not match' in
    264347                          self.browser.contents)
    265348        # The payment is now in state failed ...
    266         self.assertMatches('...<span>Failed</span>...',
    267                           self.browser.contents)
     349        self.assertTrue('<span>Failed</span>' in self.browser.contents)
    268350        # Let's replace the amount autorized with the amount of the
    269351        # live system payment
    270352        payment.amount_auth = payment.r_amount_approved
    271353        self.browser.open(self.payment_url + '/request_webservice')
    272         self.assertMatches('...Successful payment...',
     354        self.assertTrue('Successful payment' in
    273355                          self.browser.contents)
    274356        # The payment is now in state paid ...
    275         self.assertMatches('...<span>Paid</span>...',
    276                           self.browser.contents)
     357        self.assertTrue('<span>Paid</span>' in self.browser.contents)
    277358        # ... and the catalog has been updated
    278359        cat = getUtility(ICatalog, name='payments_catalog')
Note: See TracChangeset for help on using the changeset viewer.