Ignore:
Timestamp:
13 Dec 2022, 18:46:57 (2 years ago)
Author:
Henrik Bettermann
Message:

Remove LPNG parameters.

Add first test.

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

Legend:

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

    r17219 r17221  
    414414        return False, msg, log
    415415
    416     # A typical JSON response ?????????????????
    417 
    418     #payRef  "FBN|WEB|MX76823|13-12-2022|935097929|608001"
    419     #txnref  "p6709347986663"
    420     #amount  "10000"
    421     #apprAmt "10000"
    422     #resp    "00"
    423     #desc    "Approved+by+Financial+Institution"
    424     #retRef  "814212374638"
    425     #cardNum ""
    426     #mac ""
     416    # A typical JSON response (test payment of Hector)
     417
     418    #{u'SplitAccounts': [],
     419    #u'RemittanceAmount': 0,
     420    #u'MerchantReference': u'p6709347986663',
     421    #u'PaymentReference': u'FBN|WEB|MX76823|13-12-2022|935097929|608001',
     422    #u'TransactionDate': u'2022-12-13T01:34:21',
     423    #u'RetrievalReferenceNumber': u'814212374638',
     424    #u'ResponseDescription': u'Approved by Financial Institution',
     425    #u'Amount': 10000,
     426    #u'CardNumber': u'',
     427    #u'ResponseCode': u'00',
     428    #u'BankCode': u'011'}
    427429
    428430    if not 'ResponseCode' in jr.keys() \
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/tests.py

    r16910 r17221  
    3030from kofacustom.nigeria.interswitch.helpers import (
    3131    query_interswitch, get_SOAP_response_paydirect, SOAP_post,
    32     create_paydirect_booking
     32    create_paydirect_booking,
     33    confirm_transaction
    3334    )
    3435from kofacustom.nigeria.testing import FunctionalLayer
     
    3738#   If you enable this, please make sure the external services
    3839#   do exist really and are not bothered by being spammed by a test programme.
    39 EXTERNAL_TESTS_1 = True
    40 EXTERNAL_TESTS_2 = True
     40EXTERNAL_TESTS_1 = False
     41EXTERNAL_TESTS_2 = False
     42EXTERNAL_TESTS_3 = True
    4143
    4244PAYDIRECT_HOST = 'sandbox.interswitchng.com'
     
    5658def external_test_2(func):
    5759    if not EXTERNAL_TESTS_2:
     60        myself = __file__
     61        if myself.endswith('.pyc'):
     62            myself = myself[:-1]
     63        print "WARNING: external tests are skipped!"
     64        print "WARNING: edit %s to enable them." % myself
     65        return
     66    return func
     67
     68def external_test_3(func):
     69    if not EXTERNAL_TESTS_3:
    5870        myself = __file__
    5971        if myself.endswith('.pyc'):
     
    401413        self.assertMatches('...Total Amount Authorized:...',
    402414                           self.browser.contents)
     415
     416# WebCheckout tests
     417
     418
     419    # https://webpay.interswitchng.com/collections/api/v1/gettransaction.json?merchantcode=MX76823&transactionreference=p6709347986663&amount=100
     420
     421    @external_test_3
     422    def test_confirm_transaction(self):
     423        host = 'webpay.interswitchng.com'
     424        url = '/collections/api/v1/gettransaction.json'
     425        https = True
     426        merchant_code = 'MX76823'
     427        payment = StudentOnlinePayment()
     428        payment.p_id ='p4465649308559'
     429        success, msg, log = confirm_transaction(
     430            payment, merchant_code, host, url, https)
     431        self.assertFalse(success)
     432        self.assertTrue('Unsuccessful callback:' in msg)
     433        self.assertTrue('Transaction not Found' in log)
     434
     435        payment.p_id ='p6709347986663'
     436        payment.amount_auth = 1.0
     437        success, msg, log = confirm_transaction(
     438            payment, merchant_code, host, url, https)
     439        self.assertTrue('Amount Inconsistency' in log)
     440        payment.amount_auth = 100.0
     441        success, msg, log = confirm_transaction(
     442            payment, merchant_code, host, url, https)
     443        self.assertEqual('Successful callback received', msg)
     444        self.assertTrue(success)
     445        self.assertTrue(
     446            "{u'SplitAccounts': [], "
     447            "u'RemittanceAmount': 0, "
     448            "u'MerchantReference': u'p6709347986663', "
     449            "u'PaymentReference': u'FBN|WEB|MX76823|13-12-2022|935097929|608001', "
     450            "u'TransactionDate': u'2022-12-13T01:34:21', "
     451            "u'RetrievalReferenceNumber': u'814212374638', "
     452            "u'ResponseDescription': u'Approved by Financial Institution', "
     453            "u'Amount': 10000, "
     454            "u'CardNumber': u'', "
     455            "u'ResponseCode': u'00', "
     456            "u'BankCode': u'011'}" in log)
     457
  • main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/interswitch/webcheckoutbrowser.py

    r17215 r17221  
    205205    submit_button = _('Submit')
    206206
    207     action = 'https://newwebpay.interswitchng.com/collections/w/pay'
    208     currency = '566'
    209     pay_item_id = 'Default_Payable_MX76823'
    210     merchant_code = 'MX76823'
     207    action = None
     208    currency = None
     209    pay_item_id = None
     210    merchant_code = None
    211211    gateway_amt = GATEWAY_AMT
    212212
     
    261261    grok.require('waeup.payApplicant')
    262262
    263     merchant_code = 'MX76823'
    264     gateway_host = 'webpay.interswitchng.com'
    265     gateway_url = '/collections/api/v1/gettransaction.json'
     263    merchant_code = None
     264    gateway_host = None
     265    gateway_url = None
    266266    https = True
    267267
     
    295295        return
    296296
    297 class WebCheckoutConfirmTransactionRequestPageStudent(UtilityView, grok.View):
     297class WebCheckoutConfirmTransactionPageStudent(UtilityView, grok.View):
    298298    """ Request webservice view for the WebCheckout gateway
    299299    """
     
    302302    grok.require('waeup.payStudent')
    303303
    304     merchant_code = 'MX76823'
    305     gateway_host = 'webpay.interswitchng.com'
    306     gateway_url = '/collections/api/v1/gettransaction.json'
     304    merchant_code = None
     305    gateway_host = None
     306    gateway_url = None
    307307    https = True
    308308
Note: See TracChangeset for help on using the changeset viewer.