Untitled
unknown
plain_text
2 years ago
9.6 kB
3
Indexable
def federal_form_60_check( account_number: str = "", identification_type: str = "6", identify_number: str = "", agriculture_income: str = "", non_agriculture_income: str = "", remarks: str = "", panApplied: str = "", panDate: str = "", panAcknowledgement: str = "", uniqueid: str = "", ): api_name = "Form 60 Check" logger = Logger(api_name) result = None msg = "" if panAcknowledgement == True: panAck = "1" else: panAck = "2" if panApplied == True: panApp = "YES" else: panApp = "NO" date = datetime.datetime.strptime(panDate, "%m/%d/%Y") panDate = date.strftime("%d-%m-%Y") request_data = f"""<?xml version="1.0" encoding="UTF-8"?> <FIXML xsi:schemaLocation="http://www.finacle.com/fixml executeFinacleScript.xsd" xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <RequestHeader> <MessageKey> <RequestUUID>sdfmdsn3344</RequestUUID> <ServiceRequestId>executeFinacleScript</ServiceRequestId> <ServiceRequestVersion>10.2</ServiceRequestVersion> <ChannelId>COR</ChannelId> <LanguageId></LanguageId> </MessageKey> <RequestMessageInfo> <BankId>01</BankId> <TimeZone></TimeZone> <EntityId></EntityId> <EntityType></EntityType> <ArmCorrelationId></ArmCorrelationId> <MessageDateTime> 2019-10-10T14:12:57.569 </MessageDateTime> </RequestMessageInfo> <Security> <Token> <PasswordToken> <UserId></UserId> <Password></Password> </PasswordToken> </Token> <FICertToken></FICertToken> <RealUserLoginSessionId></RealUserLoginSessionId> <RealUser></RealUser> <RealUserPwd></RealUserPwd> <SSOTransferToken></SSOTransferToken> </Security> </RequestHeader> </Header> <Body> <executeFinacleScriptRequest> <ExecuteFinacleScriptInputVO> <requestId>FI_Form60_Add.scr</requestId> </ExecuteFinacleScriptInputVO> <executeFinacleScript_CustomData> <acctId>{account_number}</acctId> <idtfyType>{identification_type}</idtfyType> <idtfyNum>{identify_number}</idtfyNum> <agrIncme>{agriculture_income}</agrIncme> <nonagrIncme>{non_agriculture_income}</nonagrIncme> <rmrksVal>{remarks}</rmrksVal> <panApp>{panApp}</panApp> <panDat>{panDate}</panDat> <panAck>{panAck}</panAck> <trnstType>9</trnstType> <trnstMode>5</trnstMode> </executeFinacleScript_CustomData> </executeFinacleScriptRequest> </Body> </FIXML>""" print(request_data) api_url = "url" try: response = requests.post( api_url, data=request_data, headers={"Content-Type": "application/xml"}, cert=FDL_CERT_KEY_PAIR, verify=False, ) print(response) logger.info("API request COMPLETED with status_code: {0}", response.status_code) except Exception as e: logger.error( "API request FAILED! An exception of type {0} has occurred.", type(e) ) logger.exception(e) msg = "Internal server error" create_fed_api_execution_log( api_name, api_url, request_data, ex=e, msg=msg, cid=uniqueid, ) return (None, msg) if response.status_code == 200: raw_text = response.text status = get_xml_tag_value("ResultFlag", raw_text) message = get_xml_tag_value("Message", raw_text) logger.info('request SUCCESS for {0} with status "{1}"', account_number, status) if status == "S": logger.info(message) result, msg = (True, message) else: logger.info(message) logger.info("Response TEXT: \n{0}", response.text) result, msg = (False, message) else: logger.warning( 'request FAILED. Expected status 200, but got "{0}".', response.status_code ) logger.info("Response TEXT: \n{0}", response.text) result, msg = (None, "Bank API server failure (%s)" % response.status_code) create_fed_api_execution_log( api_name, api_url, request_data, response=response, msg=msg, cid=uniqueid, ) return result, msg def federal_fatca_check( customer_id : str = "", place_of_birth : str = "", country_of_birth :str = "", taxResident : str = "", taxId : str = "", taxDesc : str = "", taxIdnum : str = "", countryRes : str = "", uniqueid : str = "" ): api_name = api_name logger = Logger(api_name) result = None msg = "" current_datetime = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] timestamp = datetime.datetime.strptime(current_datetime, "%Y-%m-%dT%H:%M:%S.%f") todays_date = timestamp.strftime("%d-%m-%Y") print('here') request_data = f"""<?xml version="1.0" encoding="UTF-8"?> <FIXML xsi:schemaLocation="http://www.finacle.com/fixml executeFinacleScript.xsd" xmlns="http://www.finacle.com/fixml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <RequestHeader> <MessageKey> <RequestUUID>c_fatca_140318_023</RequestUUID> <ServiceRequestId>executeFinacleScript</ServiceRequestId> <ServiceRequestVersion>10.2</ServiceRequestVersion> <ChannelId>COR</ChannelId> <LanguageId></LanguageId> </MessageKey> <RequestMessageInfo> <BankId>01</BankId> <TimeZone></TimeZone> <EntityId></EntityId> <EntityType></EntityType> <ArmCorrelationId></ArmCorrelationId> <MessageDateTime>{current_datetime}</MessageDateTime> </RequestMessageInfo> <Security> <Token> <PasswordToken> <UserId></UserId> <Password></Password> </PasswordToken> </Token> <FICertToken></FICertToken> <RealUserLoginSessionId></RealUserLoginSessionId> <RealUser></RealUser> <RealUserPwd></RealUserPwd> <SSOTransferToken></SSOTransferToken> </Security> </RequestHeader> </Header> <Body> <executeFinacleScriptRequest> <ExecuteFinacleScriptInputVO> <requestId>FI_FATCA_Add.scr</requestId> </ExecuteFinacleScriptInputVO> <executeFinacleScript_CustomData> <custId>25326023</custId> <selfCert>Y</selfCert> <taxStat>NOT DOCUMENTED</taxStat> <placeOfBirth>{place_of_birth}</placeOfBirth> <countryOfBirth>{country_of_birth}</countryOfBirth> <addType>Residential</addType> <certDate>{todays_date}</certDate> <taxResident>{taxResident}</taxResident> <RecordCount>1</RecordCount> <Record_1> <taxId>{taxId}</taxId> <taxDesc>{taxDesc}</taxDesc> <taxIdNum>{taxIdnum}</taxIdNum> <countryRes>{countryRes}</countryRes> </Record_1> </executeFinacleScript_CustomData> </executeFinacleScriptRequest> </Body> </FIXML>""" print(request_data) api_url = "url" try: response = requests.post( api_url, data=request_data, headers={"Content-Type": "application/xml"}, cert=FDL_CERT_KEY_PAIR, verify=False, ) print(response) logger.info("API request COMPLETED with status_code: {0}", response.status_code) except Exception as e: logger.error( "API request FAILED! An exception of type {0} has occurred.", type(e) ) logger.exception(e) msg = "Internal server error" create_fed_api_execution_log( api_name, api_url, request_data, ex=e, msg=msg, cid=uniqueid, ) return (None, msg) if response.status_code == 200: raw_text = response.text status = get_xml_tag_value("ResultFlag", raw_text) message = get_xml_tag_value("Message", raw_text) logger.info('request SUCCESS for {0} with status "{1}"', customer_id, status) if status == "S": logger.info(message) result, msg = (True, message) else: logger.info(message) logger.info("Response TEXT: \n{0}", response.text) result, msg = (False, message) else: logger.warning( 'request FAILED. Expected status 200, but got "{0}".', response.status_code ) logger.info("Response TEXT: \n{0}", response.text) result, msg = (None, "Bank API server failure (%s)" % response.status_code) create_fed_api_execution_log( api_name, api_url, request_data, response=response, msg=msg, cid=uniqueid, ) return result, msg
Editor is loading...
Leave a Comment