Changeset 16193


Ignore:
Timestamp:
11 Aug 2020, 09:15:16 (4 years ago)
Author:
Henrik Bettermann
Message:

Implement webservice get_payment.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r16190 r16193  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Implement webservice `get_payment`.
    68
    79* `year` (Year of Entrance) is no longer required when creating
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_webservices.py

    r16192 r16193  
    799799                                   )
    800800        self.assertEqual(xmlout, response)
     801        return
     802
     803    def test_get_payment(self):
     804        payment1 = StudentOnlinePayment()
     805        payment1.p_id = 'my-id1'
     806        payment1.p_session = 2012
     807        payment1.amount_auth = 12.12
     808        payment1.p_state = u'failed'
     809        payment1.p_category = u'schoolfee'
     810        payment1.r_company = u'xyz'
     811        self.student['payments']['my-payment1'] = payment1
     812        server = ServerProxy('http://mgr:mgrpw@localhost/app', allow_none=True)
     813        results = server.get_payment()
     814        self.assertEqual(results, None)
     815        results = server.get_payment('nonsense')
     816        self.assertEqual(results, None)
     817        results = server.get_payment('my-id1')
     818        self.assertEqual(
     819            results,
     820                {'display_item': None,
     821                'p_id': 'my-id1',
     822                'p_category': 'schoolfee',
     823                'amount_auth': 12.12, 'p_session': 2012,
     824                'p_state': 'failed',
     825                'r_company': 'xyz',
     826                'fullname': 'Anna Tester',
     827                'id': 'K1000000',
     828                'matric_number': '234'}
     829                )
     830
     831        REQUEST_XML = """\
     832<?xml version="1.0"?>
     833<methodCall>
     834<methodName>get_payment</methodName>
     835<params>
     836<param>
     837<value><string>my-id1</string></value>
     838</param>
     839</params>
     840</methodCall>"""
     841        RESPONSE_XML = """\
     842<?xml version='1.0'?>
     843<methodResponse>
     844<params>
     845<param>
     846<value><struct>
     847<member>
     848<name>display_item</name>
     849<value><nil/></value></member>
     850<member>
     851<name>amount_auth</name>
     852<value><double>12.12</double></value>
     853</member>
     854<member>
     855<name>p_id</name>
     856<value><string>my-id1</string></value>
     857</member>
     858<member>
     859<name>r_company</name>
     860<value><string>xyz</string></value>
     861</member>
     862<member>
     863<name>matric_number</name>
     864<value><string>234</string></value>
     865</member>
     866<member>
     867<name>p_category</name>
     868<value><string>schoolfee</string></value>
     869</member>
     870<member>
     871<name>fullname</name>
     872<value><string>Anna Tester</string></value>
     873</member>
     874<member>
     875<name>p_state</name>
     876<value><string>failed</string></value>
     877</member>
     878<member>
     879<name>p_session</name>
     880<value><int>2012</int></value>
     881</member>
     882<member>
     883<name>id</name>
     884<value><string>K1000000</string></value>
     885</member>
     886</struct></value>
     887</param>
     888</params>
     889</methodResponse>
     890"""
     891        xmlout = self.XMLRPC_post(REQUEST_XML)
     892        self.assertEqual(xmlout, RESPONSE_XML)
    801893        return
    802894
  • main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py

    r16192 r16193  
    420420
    421421    @grok.require('waeup.xmlrpc')
     422    def get_payment(self, p_id='non_existent'):
     423        """Returns payment and payer data of payment tickets with specific p_id.
     424        """
     425        cat = getUtility(ICatalog, name='payments_catalog')
     426        result = list(cat.searchResults(p_id=(p_id, p_id)))
     427        if not len(result):
     428            return None
     429        payment =  result[0]
     430        return dict(
     431                p_id=payment.p_id,
     432                amount_auth=payment.amount_auth,
     433                p_category=payment.p_category,
     434                display_item=payment.display_item,
     435                p_session=payment.p_session,
     436                p_state=payment.p_state,
     437                r_company=getattr(payment, 'r_company', None),
     438                id = IPayer(payment).id,
     439                matric_number = IPayer(payment).matric_number,
     440                fullname = IPayer(payment).display_fullname,
     441                )
     442
     443    @grok.require('waeup.xmlrpc')
    422444    def get_unpaid_payments(self, days=3, company=None):
    423         """Returns the p_ids of unpaid payment tickets which have
    424         been created during the past days.
     445        """Returns the payment and payer data of unpaid payment
     446        tickets which have been created during the past days.
    425447        """
    426448        days_in_seconds = 86400 * int(days)
Note: See TracChangeset for help on using the changeset viewer.