Ignore:
Timestamp:
2 Nov 2015, 09:07:39 (9 years ago)
Author:
Henrik Bettermann
Message:

Distinguish the two products.

File:
1 edited

Legend:

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

    r13378 r13379  
    3131from waeup.aaue.interfaces import MessageFactory as _
    3232
    33 PRODUCT_ID = '5040'
     33PRODUCT_ID_PT = '5040'
     34PRODUCT_ID_REGULAR = '5845'
    3435SITE_NAME = 'aaue.waeup.org'
    3536PROVIDER_ACCT = '1010764827'
     
    4748httplib.HTTPSConnection.debuglevel = 0
    4849
     50
     51def school(student):
     52    if student.current_mode == 'found' or student.current_mode.endswith('_pt'):
     53        return 'pt'
     54    return 'regular'
     55
    4956class CustomInterswitchPageApplicant(InterswitchPageApplicant):
    5057    """ View which sends a POST request to the Interswitch
    5158    CollegePAY payment gateway.
     59
     60    So far only PT application has been configured.
    5261    """
    5362    grok.context(ICustomApplicantOnlinePayment)
     
    5665    currency = CURRENCY
    5766    pay_item_id = '101'
    58     product_id = PRODUCT_ID
     67    product_id = PRODUCT_ID_PT
    5968    mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
    6069
     
    91100        hashargs = (
    92101            self.context.p_id +
    93             PRODUCT_ID +
     102            PRODUCT_ID_PT +
    94103            self.pay_item_id +
    95104            str(int(self.amount_auth)) +
     
    108117    site_name = SITE_NAME
    109118    currency = CURRENCY
    110     product_id = PRODUCT_ID
    111119    pay_item_id = '101'
    112120    mac = '74424F1DFECD6058F153148255CDD55E16724B4F380ADB2C63C5D1D7A5675759010C8153DCB930AAF2D38903CBF7CE32B8A6BA2C16BBC46721DF2E3F3E4548E3'
     
    156164        xmldict['institution_name'] = INSTITUTION_NAME
    157165
    158         if self.context.p_category == 'schoolfee':
    159             xmldict['institution_bank_id'] = '7'
    160             xmldict['institution_acct'] = '1014847058'
    161             if student.current_mode == 'found':
    162                 self.pay_item_id = '103'
    163             else:
    164                 self.pay_item_id = '105'
    165             provider_amt = 1900.0
    166             joint_venture_amt = 1100.0
    167             aaue_share_amt = 1000.0
    168             student_union_due_amt = 1000.0
    169             student_welfare_assurance_amt = 500.0
    170             xmldict['provider_amt'] = 100 * provider_amt
    171             xmldict['joint_venture_amt'] = 100 * joint_venture_amt
    172             xmldict['aaue_share_amt'] = 100 * aaue_share_amt
    173             xmldict['student_union_due_amt'] = 100 * student_union_due_amt
    174             xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
    175             xmldict['institution_amt'] = 100 * (
    176                 self.context.amount_auth
    177                 - provider_amt
    178                 - joint_venture_amt
    179                 - aaue_share_amt
    180                 - student_union_due_amt
    181                 - student_welfare_assurance_amt
    182                 - GATEWAY_AMT)
    183             xmltext = """<payment_item_detail>
     166        # PT
     167
     168        if school(student) == 'pt':
     169            product_id = PRODUCT_ID_PT
     170            if self.context.p_category == 'schoolfee':
     171                xmldict['institution_bank_id'] = '7'
     172                xmldict['institution_acct'] = '1014847058'
     173                if student.current_mode == 'found':
     174                    self.pay_item_id = '103'
     175                else:
     176                    self.pay_item_id = '105'
     177                provider_amt = 1900.0
     178                joint_venture_amt = 1100.0
     179                aaue_share_amt = 1000.0
     180                student_union_due_amt = 1000.0
     181                student_welfare_assurance_amt = 500.0
     182                xmldict['provider_amt'] = 100 * provider_amt
     183                xmldict['joint_venture_amt'] = 100 * joint_venture_amt
     184                xmldict['aaue_share_amt'] = 100 * aaue_share_amt
     185                xmldict['student_union_due_amt'] = 100 * student_union_due_amt
     186                xmldict['student_welfare_assurance_amt'] = 100 * student_welfare_assurance_amt
     187                xmldict['institution_amt'] = 100 * (
     188                    self.context.amount_auth
     189                    - provider_amt
     190                    - joint_venture_amt
     191                    - aaue_share_amt
     192                    - student_union_due_amt
     193                    - student_welfare_assurance_amt
     194                    - GATEWAY_AMT)
     195                xmltext = """<payment_item_detail>
    184196<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
    185197<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" />
     
    191203</item_details>
    192204</payment_item_detail>""" % xmldict
    193         elif self.context.p_category == 'clearance':
    194             if student.current_mode == 'found':
    195                 self.pay_item_id = '102'
    196             else:
    197                 self.pay_item_id = '104'
    198             xmldict['institution_acct'] = '1014066976'
    199             xmldict['institution_bank_id'] = '117'
    200             provider_amt = 0.0
    201             gown_fee_amt = 2000.0
    202             aaue_fl_fee_amt = 800.0
    203             xmldict['gown_fee_amt'] = 100 * gown_fee_amt
    204             xmldict['aaue_fl_fee_amt'] = 100 * aaue_fl_fee_amt
    205             xmldict['institution_amt'] = 100 * (
    206                 self.context.amount_auth
    207                 - gown_fee_amt
    208                 - aaue_fl_fee_amt
    209                 - GATEWAY_AMT)
    210             xmltext = """<payment_item_detail>
     205            elif self.context.p_category == 'clearance':
     206                if student.current_mode == 'found':
     207                    self.pay_item_id = '102'
     208                else:
     209                    self.pay_item_id = '104'
     210                xmldict['institution_acct'] = '1014066976'
     211                xmldict['institution_bank_id'] = '117'
     212                provider_amt = 0.0
     213                gown_fee_amt = 2000.0
     214                aaue_fl_fee_amt = 800.0
     215                xmldict['gown_fee_amt'] = 100 * gown_fee_amt
     216                xmldict['aaue_fl_fee_amt'] = 100 * aaue_fl_fee_amt
     217                xmldict['institution_amt'] = 100 * (
     218                    self.context.amount_auth
     219                    - gown_fee_amt
     220                    - aaue_fl_fee_amt
     221                    - GATEWAY_AMT)
     222                xmltext = """<payment_item_detail>
    211223<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
    212224<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" />
     
    216228</payment_item_detail>""" % xmldict
    217229
     230        # REGULAR
     231
     232        else:
     233            pass
     234
    218235
    219236        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
     
    222239        hashargs = (
    223240            self.context.p_id +
    224             PRODUCT_ID +
     241            product_id +
    225242            self.pay_item_id +
    226243            str(int(self.amount_auth)) +
     
    234251    InterswitchPaymentRequestWebservicePageApplicant):
    235252    """ Request webservice view for the CollegePAY gateway
     253
     254    So far only PT application has been configured.
    236255    """
    237256    grok.context(ICustomApplicantOnlinePayment)
    238     product_id = PRODUCT_ID
     257    product_id = PRODUCT_ID_PT
    239258    gateway_host = HOST
    240259    gateway_url = URL
     
    246265    """
    247266    grok.context(ICustomStudentOnlinePayment)
    248     product_id = PRODUCT_ID
    249267    gateway_host = HOST
    250268    gateway_url = URL
    251269    https = HTTPS
     270
     271    @property
     272    def product_id(self):
     273        if school(self.context.student) == 'pt':
     274            return PRODUCT_ID_PT
     275        return PRODUCT_ID_REGULAR
Note: See TracChangeset for help on using the changeset viewer.