Example #1
0
def recipientInquiry_icici(user, agent, dialer, senderNumber):
    print "Starting ICICI recipient list inquiry"
    result = {}
    # Preparing the URL needed to make API Call with data,headers,and parameters.
    # Get All Recipients API is being used

    request_type = "GET"
    data = {}
    params = {'initiator_id':dialer}
    url = api_url+'/customers/mobile_number:'+str(senderNumber)+'/recipients'

    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_REGISTERED_RECIPIENT_INQUIRY)
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)
    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer, request_type, url, params, data, headers, extra_param)  
    recipient_list = []
    count = 0 
    sender_name = ""    
    sender_aadhaar = ""
    wallet_limit = ""
    remaining_wallet_limit=""
    bc_limit=""
    remaining_bc_limit=""
    aadhaar_status=""
    status = module_responsehandler_new.icici_recipient_list_inquiry_reponse(result_text)
    
    get_customer_url = api_url+'/customers/mobile_number:'+str(senderNumber)
    get_customer = module_apicaller.api_call(user, agent, transaction_type, dialer, request_type, get_customer_url, params, data, headers, extra_param)
    if 'status' in get_customer:
        get_customer_json = json.loads(get_customer)
        result['wallet_limit']= 10000
        result['remaining_wallet_limit'] = str(get_customer_json['data']['limit'][1]['remaining'])
        result['bc_limit']= 50000
        result['remaining_bc_limit'] = str(get_customer_json['data']['limit'][0]['remaining'])
        result['aadhaar_status']=aadhaar_status
        result['sender_name'] = str(get_customer_json['data']['name'])
        result['sender_aadhaar'] = ""
    else:
        response = get_customer
    if status != constants.UNKNOWN_STATUS:
            
        get_recipient_json = json.loads(result_text)

        if get_recipient_json['response_type_id'] == constants.NO_RECIPIENT:  #if response_type_id is 22 then there is no recipient
            result['recipients'] = recipient_list
            result['recipient_count'] = count  
        else:                                               # else recipients present and show the list of recipients
            result['recipients'] = get_recipient_json['data']['recipient_list']
            result['recipient_count'] = len(get_recipient_json['data']['recipient_list'])
    result['status'] = status
    if result['status'] != constants.UNKNOWN_STATUS :
        response = str(json.loads(result_text)['message']) 
    else:
        response = result_text    
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)
    return result
def transaction_search_by_tid(user, agent, dialer, transactionId):
    print "String Transaction Enquary"
    print ('Transaction id: ',transactionId)
    
    result = {}
    url = api_url + '/transactions/' + str(transactionId)
    params = {'initiator_id':'mobile_number:'+str(dialer)}
    data = {}
    request_type = 'GET'

    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_ENQ)
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)
    # Calling the api_call function and passing the necessary parameters 
    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer,request_type, url, params, data, headers, extra_param)
    
    if 'status' not in result_text:
        response = result_text
    else:     
        result_text_json = json.loads(result_text)
        if result_text_json['response_type_id'] == 70:
            response = module_responsehandler_new.get_formatted_response_data(result_text_json['data'])

        elif result_text_json['response_type_id'] == 69:
            response = result_text_json['invalid_params']['tid']
        else:
            response = result_text_json['message']    
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)
    return result
def customerenrolmentotpverification_ppi(user, agent, dialer, senderMobile,
                                         otp):
    print "Starting PPI customer enrolment OTP verification"

    result = {}
    data = {
        'id': senderMobile,
        'initiator_id': dialer,
        'id_type': 'mobile_number',
    }
    url = api_url + '/customers/verification/otp:' + str(otp)
    params = {}
    request_type = "PUT"

    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_SENDER_ENROLMENT_VERIFIC)
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    status = module_responsehandler_new.ppi_customerotpverification_response(
        result_text)
    result = module_responsehandler_new.get_basic_details(result_text, status)
    return result
def customerenrolment_icici(user, agent, dialer, senderMobile,
                            senderName):  # for the customer enrolemt
    print "Starting ICICI customer enrolment"
    # for customer enrolment "create customer API is used
    result = {}
    # data contains the additional information required
    data = {'name': senderName, 'initiator_id': dialer}
    # url is created for the create customer api
    url = api_url + '/customers/mobile_number:' + str(senderMobile)
    params = {}
    # put request is used in this api call
    request_type = "PUT"

    # obtain the transaction type from the Transaction_Type table in the database
    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_SENDER_ENROLMENT)
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    #result text store the data returned from the api
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    # obtaining the status from the responsehandler_new
    status = module_responsehandler_new.icici_enrolment_response(result_text)

    result = module_responsehandler_new.get_basic_details(result_text, status)
    # return the result to the html file
    return result
def customerenrolmentresendotp_ppi(user, agent, dialer, senderMobile):
    print "Starting PPI customer enrolment resend OTP request"

    result = {}
    data = {
        'initiator_id': dialer,
    }
    url = api_url + '/customers/mobile_number:' + str(senderMobile) + '/otp'
    request_type = "POST"
    params = {}

    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_SENDER_ENROLMENT_RESEND_OTP)
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    if 'status' not in result_text:
        response = result_text
    else:
        response = str(json.loads(result_text)['message'])
    result['responseText'] = module_responsehandler_new.get_formatted_response(
        response)

    return result
Example #6
0
def recipientregistration_icici(user, agent, dialer, senderNumber, recipientAccountNo, recipientIfsc, bankId, recipientName, recipientMobile):
    print "Starting ICICI recipient registration"

    result = {}
    # If customer doesnot enter IFSC code of the bank then it gets the code from database.
    
    if (recipientIfsc == None or recipientIfsc == '') and bankId != '-1':
        recipientIfsc = Bank_Detail.objects.get(bank_id = bankId).identifier
        
    # Preparing the URL needed to make API Call with data,headers,and parameters.
    # Add Recipient API is being used
    url = api_url + '/customers/mobile_number:' + str(senderNumber) +'/recipients/acc_ifsc:' + str(recipientAccountNo) + '_' + str(recipientIfsc).lower()
    request_type = 'PUT'
    params = {}
    data = {'recipient_name':recipientName,'initiator_id':dialer,'mobile':recipientMobile,'recipient_type':3}

    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_RECIPIENT_REG)
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)
    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer, request_type, url, params, data, headers, extra_param)
    #Using API Caller function to make request to server and get the response. 
    result['status'] = module_responsehandler_new.icici_recipient_registration_response(result_text)         
    
    if result['status'] != constants.UNKNOWN_STATUS: # for the purpose if the result hasn't come from the API then we show the whole result 
        response = str(json.loads(result_text)['message'])      # but if the result is come from the API then we show the message of the API response
        if 'Recipientid' in response:
            response = "Success Now select recipient and perform transaction"  
    else:
        response = result_text
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)
                
    return result
Example #7
0
def recipient_idividual_inquiry_icici(user, agent, dialer, senderNumber, account_code):
    print "Starting ICICI individual recipient inquiry"
    
    result = {}
    # Preparing the URL needed to make API Call with data,headers,and parameters.
    #Get Recipient API is being used.
    url = api_url + '/customers/mobile_number:' + str(senderNumber) + '/recipients/recipient_id:' +str(account_code)
    data = {}
    params = {'initiator_id':dialer}
    request_type = 'GET'
    response = ''
    
    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_RECIPIENT_INDIVIDUAL_INQUIRY)
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)

    #Using API Caller function to make request to server and get the response.

    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer, request_type, url,params, data, headers, extra_param)
    result['status'] = module_responsehandler_new.icici_recipient_individual_inquiry_reponse(result_text)  
    if result['status'] !=  constants.UNKNOWN_STATUS :
        response = 'Name: '+ str(json.loads(result_text)['data']['name']) +'\nAccount: ' + str(json.loads(result_text)['data']['account']) +'\nRecipient Id: '+str(json.loads(result_text)['data']['recipient_id']) 
    else:
        response = result_text    
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)
    return result
Example #8
0
def recipientVerifiaction_icici(user, agent, dialer, senderNumber, recipientAccountNo, recipientIfsc, bankId):
    print "Start ICICI recipient Verification"
    print bankId
    result = {}
    # If customer doesnot enter IFSC code of the bank then it gets the code from database.
    # Get Acc Name Info API is being used.
    if (recipientIfsc == None or recipientIfsc == '') and bankId != '-1':
        recipientIfsc = Bank_Detail.objects.get(bank_id = bankId).identifier
    # Preparing the URL needed to make API Call with data,headers,and parameters.
    url = api_url + '/banks/ifsc:' + str(recipientIfsc).lower() + '/accounts/' + str(recipientAccountNo)
    request_type = 'POST'
    data = {'initiator_id':dialer,'customer_id':senderNumber}
    params = {}

    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_RECIPIENT_REG)
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)
    
    #Using API Caller function to make request to server and get the response.

    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer,  request_type, url, params, data, headers, extra_param)
    result['status'] = module_responsehandler_new.recipient_verification_response(result_text)   
    if result['status'] != constants.UNKNOWN_STATUS :
        response = str(json.loads(result_text)['message']) 
    else:
        response = result_text    
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)
    
    if result['status'] == 'RECIPIENT_VERIFIED':
        result['rcpt_name'] = json.loads(result_text)['data']['recipient_name']
        return result
    else:
        return result
def transaction_search_by_tid(user, agent, dialer, transactionId):
    print "String Transaction Enquary"
    print('Transaction id: ', transactionId)

    result = {}
    url = api_url + '/transactions/' + str(transactionId)
    params = {'initiator_id': 'mobile_number:' + str(dialer)}
    data = {}
    request_type = 'GET'

    transaction_type = Transaction_Type.objects.get(id=constants.TRXN_ENQ)
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    # Calling the api_call function and passing the necessary parameters
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)

    if 'status' not in result_text:
        response = result_text
    else:
        result_text_json = json.loads(result_text)
        if result_text_json['response_type_id'] == 70:
            response = module_responsehandler_new.get_formatted_response_data(
                result_text_json['data'])

        elif result_text_json['response_type_id'] == 69:
            response = result_text_json['invalid_params']['tid']
        else:
            response = result_text_json['message']
    result['responseText'] = module_responsehandler_new.get_formatted_response(
        response)
    return result
def bank_config_inquiry(user, agent, dialer, bank_id):
    print 'Starting bank config inquiry'
    result = {}

    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_BANK_CONFIG_INQUIRY)
    bank_identifier = Bank_Detail.objects.get(bank_id = bank_id).identifier
    url = api_url + '/banks'
    data = {}
    params = {'bank_code':bank_identifier,'initiator_id':"mobile_number:"+str(dialer)}
    request_type = 'GET'

    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, agent.official_detail.bank.id)
    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer,request_type, url, params, data, headers, extra_param)
    result['status'] = module_responsehandler_new.bank_config_inquiry_response(result_text)
    
    # FRom ifsc status and isverification flag we can show the next form to the user
    if result['status'] == constants.BANK_CONFIG_INQUIRY_SUCCESS_STATUS:
        response = str(json.loads(result_text)['message']) 
        result['ifsc_status'] = json.loads(result_text)['data']['ifsc_status']
        result['isverificationavailable'] = json.loads(result_text)['data']['isverificationavailable']
    else:
        
        response = result_text
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)        

    return result
def moneytransfer_icici(user, agent, dialer, recipientAccountCode, senderNumber, amount, transactionMode, ifscTransaction):
    print "Starting ICICI money transfer"
    
    
    result = {}
    url = api_url + '/transactions'
    # preparing the data required for the transaction
    data={ 'recipient_id':recipientAccountCode,
            'amount':amount,
            'currency':'INR',
            'customer_id':senderNumber,
            'initiator_id':dialer,
            'client_ref_id':str(datetime.datetime.now().strftime("%I:%M:%S %p")),
            'state':1,
            # 'pintwin':okekey,
            'channel':transactionMode
      
            }
            
    request_type='POST'        
    params = {}

    # Obtaining the transaction type from the Transaction_Type table in the database
    transaction_type = Transaction_Type.objects.get(id = constants.TRXN_MONEY_TRANSFER)
    # Preparing the extra praameters required for making the logs
    extra_param = module_helper.prepare_extra_transaction_param(transaction_type, constants.BANK_ICICI)
    # API call is made through api_call function present in the module_apicaller
    result_text = module_apicaller.api_call(user, agent, transaction_type, dialer,request_type, url, params, data, headers,extra_param)
    # logs are added
    
    response = ''
    
    result['status'] = module_responsehandler_new.icici_moneytransfer_response(result_text)
    
    if result['status'] == constants.UNKNOWN_STATUS: # this is for the purpose if the response doesnot come from the API due to any reason
        response = result_text
    else:
        # if the 'status' is 'incorrect pin' then we have to show him the last okkey
        # we set the value of okkey in the result dictionary and send it to the html file in which it is shown on the frontend
        if result['status'] == constants.INCORRECT_PIN_STATUS:
            result['okekey'] = str(json.loads(result_text)['data']['last_used_okekey'])
            response = str(json.loads(result_text)['message'])
        elif result['status'] == constants.SUCCESS_DISP:
            # if the 'status' is 'success' the we have to show him the 'amount' and the 'transaction id'
            result['amount'] = str(json.loads(result_text)['data']['amount'])
            result['okekey'] = str(json.loads(result_text)['data']['last_used_okekey'])
            result['balance'] = str(json.loads(result_text)['data']['balance'])+'0'
            response = response = str(json.loads(result_text)['message'])+'\nTid: '+ str(json.loads(result_text)['data']['tid']) +'\nLast Okkey Used: ' + str(json.loads(result_text)['data']['last_used_okekey']) 
        else:
            response = str(json.loads(result_text)['message'])
            
        # we format the response through 'get_formatted_response' function 
    result['responseText'] = module_responsehandler_new.get_formatted_response(response)    
    result['timestamp'] = str(datetime.datetime.now().strftime("%I:%M:%S %p"))
    return result
def senderInquiry_ppi(user, agent, dialer, senderNumber):
    print "Starting PPI sender inquiry"

    request_text = senderNumber
    url = api_url + '/customers/mobile_number:' + str(
        request_text)  # required url
    params = {'initiator_id': dialer}
    data = {}
    request_type = "GET"

    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_SENDER_INQUIRY)
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    result = module_responsehandler_new.extract_response_and_other_config(
        result_text)
    return result
Example #13
0
def bank_config_inquiry(user, agent, dialer, bank_id):
    print 'Starting bank config inquiry'
    result = {}

    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_BANK_CONFIG_INQUIRY)
    bank_identifier = Bank_Detail.objects.get(bank_id=bank_id).identifier
    url = api_url + '/banks'
    data = {}
    params = {
        'bank_code': bank_identifier,
        'initiator_id': "mobile_number:" + str(dialer)
    }
    request_type = 'GET'

    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, agent.official_detail.bank.id)
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    result['status'] = module_responsehandler_new.bank_config_inquiry_response(
        result_text)

    # FRom ifsc status and isverification flag we can show the next form to the user
    if result['status'] == constants.BANK_CONFIG_INQUIRY_SUCCESS_STATUS:
        response = str(json.loads(result_text)['message'])
        result['ifsc_status'] = json.loads(result_text)['data']['ifsc_status']
        result['isverificationavailable'] = json.loads(
            result_text)['data']['isverificationavailable']
    else:

        response = result_text
    result['responseText'] = module_responsehandler_new.get_formatted_response(
        response)

    return result
def moneytransfer_icici(user, agent, dialer, recipientAccountCode,
                        senderNumber, amount, transactionMode,
                        ifscTransaction):
    print "Starting ICICI money transfer"

    result = {}
    url = api_url + '/transactions'
    # preparing the data required for the transaction
    data = {
        'recipient_id': recipientAccountCode,
        'amount': amount,
        'currency': 'INR',
        'customer_id': senderNumber,
        'initiator_id': dialer,
        'client_ref_id': str(datetime.datetime.now().strftime("%I:%M:%S %p")),
        'state': 1,
        # 'pintwin':okekey,
        'channel': transactionMode
    }

    request_type = 'POST'
    params = {}

    # Obtaining the transaction type from the Transaction_Type table in the database
    transaction_type = Transaction_Type.objects.get(
        id=constants.TRXN_MONEY_TRANSFER)
    # Preparing the extra praameters required for making the logs
    extra_param = module_helper.prepare_extra_transaction_param(
        transaction_type, constants.BANK_ICICI)
    # API call is made through api_call function present in the module_apicaller
    result_text = module_apicaller.api_call(user, agent, transaction_type,
                                            dialer, request_type, url, params,
                                            data, headers, extra_param)
    # logs are added

    response = ''

    result['status'] = module_responsehandler_new.icici_moneytransfer_response(
        result_text)

    if result[
            'status'] == constants.UNKNOWN_STATUS:  # this is for the purpose if the response doesnot come from the API due to any reason
        response = result_text
    else:
        # if the 'status' is 'incorrect pin' then we have to show him the last okkey
        # we set the value of okkey in the result dictionary and send it to the html file in which it is shown on the frontend
        if result['status'] == constants.INCORRECT_PIN_STATUS:
            result['okekey'] = str(
                json.loads(result_text)['data']['last_used_okekey'])
            response = str(json.loads(result_text)['message'])
        elif result['status'] == constants.SUCCESS_DISP:
            # if the 'status' is 'success' the we have to show him the 'amount' and the 'transaction id'
            result['amount'] = str(json.loads(result_text)['data']['amount'])
            result['okekey'] = str(
                json.loads(result_text)['data']['last_used_okekey'])
            result['balance'] = str(
                json.loads(result_text)['data']['balance']) + '0'
            response = response = str(
                json.loads(result_text)['message']) + '\nTid: ' + str(
                    json.loads(result_text)['data']
                    ['tid']) + '\nLast Okkey Used: ' + str(
                        json.loads(result_text)['data']['last_used_okekey'])
        else:
            response = str(json.loads(result_text)['message'])

        # we format the response through 'get_formatted_response' function
    result['responseText'] = module_responsehandler_new.get_formatted_response(
        response)
    result['timestamp'] = str(datetime.datetime.now().strftime("%I:%M:%S %p"))
    return result