Changeset 12510


Ignore:
Timestamp:
23 Jan 2015, 14:32:45 (10 years ago)
Author:
Henrik Bettermann
Message:

Configure CustomInterswitchPageApplicant?.

Go live.

File:
1 edited

Legend:

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

    r12478 r12510  
    2929from kofacustom.wdu.interfaces import MessageFactory as _
    3030
    31 PRODUCT_ID = '6207'
     31PRODUCT_ID = '5214'
    3232SITE_NAME = 'wdu.waeup.org'
    3333PROVIDER_ACCT = '0137712635'
     
    3838GATEWAY_AMT = 300.0
    3939
    40 POST_ACTION = 'https://stageserv.interswitchng.com/test_paydirect/pay'
    41 #POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
     40#POST_ACTION = 'https://stageserv.interswitchng.com/test_paydirect/pay'
     41POST_ACTION = 'https://webpay.interswitchng.com/paydirect/pay'
    4242
    43 #HOST = 'webpay.interswitchng.com'
    44 HOST = 'stageserv.interswitchng.com'
     43HOST = 'webpay.interswitchng.com'
     44#HOST = 'stageserv.interswitchng.com'
    4545HTTPS = True
    4646
    47 #URL = '/paydirect/services/TransactionQueryWs.asmx'
    48 URL = '/test_paydirect/services/TransactionQueryWS.asmx'
     47URL = '/paydirect/services/TransactionQueryWs.asmx'
     48#URL = '/test_paydirect/services/TransactionQueryWS.asmx'
    4949
    5050httplib.HTTPSConnection.debuglevel = 0
     
    5959    currency = CURRENCY
    6060    product_id = PRODUCT_ID
    61     mac = 'CEF793CBBE838AA0CBB29B74D571113B4EA6586D3BA77E7CFA0B95E278364EFC4526ED7BD255A366CDDE11F1F607F0F844B09D93B16F7CFE87563B2272007AB3'
     61    mac = '2EC91A15F6A0821A06DEC31CC4EF509FDB548A1ABF76BD6FCF620A4D3F1F80D06C362D26CA56D86DC91ADA85CD99B97A6E845B44C730D5749E2B9B339FDC7AF8'
    6262
    6363    def update(self):
    64         error = self.init_update()
    65         if error:
    66             self.flash(error, type='danger')
    67             self.redirect(self.url(self.context, '@@index'))
    68             return
     64        super(CustomInterswitchPageStudent, self).update()
    6965        student = self.student
    7066        xmldict = self.xmldict
     
    8884            institution_amt_2 = 150500.0 + 1000.0
    8985        xmldict['provider_amt'] = 100 * provider_amt
    90         xmldict['institution_item_name'] = self.category
     86        xmldict['institution_item_name'] = self.context.category
    9187        xmldict['institution_name'] = INSTITUTION_NAME
    9288        xmldict['institution_amt_1'] = 100 * (
     
    9490        xmldict['institution_amt_2'] = 100 * institution_amt_2
    9591
    96         # Interswitch amount is not part of the xml data
    9792        xmltext = """<payment_item_detail>
    9893<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s" department="%(department)s" faculty="%(faculty)s">
     
    10095<item_detail item_id="2" item_name="other charges and tech fee" item_amt="%(institution_amt_2)d" bank_id="%(institution_bank_id_2)s" acct_num="%(institution_acct_2)s" />
    10196<item_detail item_id="3" item_name="%(provider_item_name)s" item_amt="%(provider_amt)d" bank_id="%(provider_bank_id)s" acct_num="%(provider_acct)s" />
     97</item_details>
     98</payment_item_detail>""" % xmldict
     99        self.xml_data = """<input type="hidden" name="xml_data" value='%s'  />""" % xmltext
     100        self.context.provider_amt = provider_amt
     101        self.context.gateway_amt = GATEWAY_AMT
     102
     103        hashargs = (
     104            self.context.p_id +
     105            PRODUCT_ID +
     106            self.pay_item_id +
     107            str(int(self.amount_auth)) +
     108            self.site_redirect_url +
     109            self.mac)
     110        self.hashvalue = hashlib.sha512(hashargs).hexdigest()
     111        return
     112
     113
     114class CustomInterswitchPageApplicant(InterswitchPageApplicant):
     115    """ View which sends a POST request to the Interswitch
     116    CollegePAY payment gateway.
     117    """
     118    grok.context(ICustomApplicantOnlinePayment)
     119    action = POST_ACTION
     120    site_name = SITE_NAME
     121    currency = CURRENCY
     122    pay_item_id = '103'
     123    product_id = PRODUCT_ID
     124    mac = '2EC91A15F6A0821A06DEC31CC4EF509FDB548A1ABF76BD6FCF620A4D3F1F80D06C362D26CA56D86DC91ADA85CD99B97A6E845B44C730D5749E2B9B339FDC7AF8'
     125
     126    def update(self):
     127        super(CustomInterswitchPageApplicant, self).update()
     128        xmldict = {}
     129        provider_amt = 500.0
     130        xmldict['institution_acct'] = '0029688237'
     131        xmldict['institution_bank_id'] = '11'
     132        xmldict['detail_ref'] = self.context.p_id
     133        xmldict['provider_amt'] = 100 * provider_amt
     134        xmldict['provider_acct'] = PROVIDER_ACCT
     135        xmldict['provider_bank_id'] = PROVIDER_BANK_ID
     136        xmldict['provider_item_name'] = PROVIDER_ITEM_NAME
     137        xmldict['institution_amt'] = 100 * (self.context.amount_auth - provider_amt - GATEWAY_AMT)
     138        xmldict['institution_item_name'] = self.context.category
     139        xmldict['institution_name'] = INSTITUTION_NAME
     140        # Interswitch amount is not part of the xml data
     141        xmltext = """<payment_item_detail>
     142<item_details detail_ref="%(detail_ref)s" college="%(institution_name)s">
     143<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" />
     144<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" />
    102145</item_details>
    103146</payment_item_detail>""" % xmldict
Note: See TracChangeset for help on using the changeset viewer.