def asset_compare(asset_base_record): # signup differences = {} try: purchaseid = asset_base_record['PurchaseID'] asset_live_record = db_agent.asset_full_record(purchaseid)[0] asset_live_record['PCID'] = None differences = bep.dictionary_compare(asset_base_record, asset_live_record) if len(differences) == 0: print(colored(f"Asset Record Compared => Pass ", 'green')) options.append_list("Asset Record Compared => Pass ") else: print( colored( f"********************* Asset MissMatch ****************", 'red')) for k, v in differences.items(): tmp = k + " " + v options.append_list(tmp) print(k, v) except Exception as ex: traceback.print_exc() print(f"{Exception}") pass return differences
def check_email_que(pricepoint_type, multitrans_base_record, action): transid = 0 check_email = 99 if pricepoint_type == 505: transid = multitrans_base_record['RelatedTransID'] else: transid = multitrans_base_record['TransID'] check_email = db_agent.check_email_que(transid) if check_email == 'noemail': return "Could not find the email or error" else: check_email = check_email[0] if action == 'signup': if check_email['EmailTypeID'] == 981: options.append_list('Email is in que => Pass') print(colored(f"Email is in que => Pass", 'green')) else: options.append_list("Could not find the email or error") return "Could not find the email or error"
def multitrans_compare(multitrans_base_record, live_record): differences = {} try: multitrans_live_record = live_record # [0] live_record['PCID'] = None multitrans_live_record['TransDate'] = multitrans_live_record[ 'TransDate'].date() differences = bep.dictionary_compare(multitrans_base_record, multitrans_live_record) if len(differences) == 0: print(colored(f"Mulitrans Record Compared => Pass", 'green')) options.append_list("Mulitrans Record Compared => Pass") else: print( colored( f"********************* Multitrans MissMatch ****************", 'red')) options.append_list( "********************* Multitrans MissMatch ****************") for k, v in differences.items(): tmp = k + " " + v options.append_list(tmp) print(k, v) # config.logging.info(k,v) except Exception as ex: traceback.print_exc() print(f"Exception {Exception} ") # config.logging.info(f"Exception {Exception} ") pass return differences
def verify_postback_url(action, package_id, trans_id): id = 0 actual_postback_status = '' expected_postback_status = '' errors_dictionary.clear() get_collect_user_info_code = get_collect_user_info( config.test_data['BillConfigID']) matched_postback_types = find_post_backs_received(package_id, trans_id) if matched_postback_types == None: print( "NO postbacks in Notification table. Skipping further verification" ) return 0 is_service_transaction = db_agent.get_trans_source(trans_id) trans_data = db_agent.execute_select_one_parameter( constants.GET_DATA_FROM_MULTITRANS_BY_TRANS_ID, trans_id) is_trans_authorized = trans_data['Authorized'] trans_type = trans_data['TransType'] data_from_3d_request = db_agent.execute_select_one_parameter( constants.IS_3DSAUTHENTICATED, trans_data['TRANSGUID']) if not data_from_3d_request: scarequired = 'no' is3dsauthenticated = 'no' else: if data_from_3d_request['AuthResponseData']: scarequired = 'yes' request = db_agent.decrypt_string( data_from_3d_request['AuthResponseData']) if '"PAResStatus":"A"' in request or '"PAResStatus":"Y"' in request: is3dsauthenticated = 'yes' else: is3dsauthenticated = 'no' else: scarequired = 'no' is3dsauthenticated = 'no' if action == "SignUp": purchase_id = trans_data['PurchaseID'] related_trans_data = db_agent.execute_select_one_parameter( constants.GET_DATA_FROM_MULTITRANS_BY_RELATED_TRANS_ID, trans_id) if is_service_transaction and is_trans_authorized: if get_collect_user_info_code == 0: compare_results("Collect user info", (1 not in matched_postback_types and 2 not in matched_postback_types), True) elif get_collect_user_info_code == 1: compare_results("Collect user info", (1 in matched_postback_types and 2 in matched_postback_types), True) elif get_collect_user_info_code == 2: compare_results("Collect user info", (1 not in matched_postback_types and 2 in matched_postback_types), True) matched_postback_ids = find_post_backs_ids(package_id, trans_id) for id in matched_postback_ids: postback_type = db_agent.get_postback_type_by_postback_id(id) if postback_type == 1: expected_action = "Probe" elif postback_type == 2: expected_action = "Enable" elif postback_type == 5: expected_action = "auth" actual_postback_status = db_agent.get_postback_status_by_id( id, trans_id) expected_postback_status = 863 expected_trantype = "sale" if trans_type == 506: expected_stage = "Instant Conversion" elif trans_type == 1011: related_purchase_id = related_trans_data['PurchaseID'] if purchase_id == related_purchase_id: expected_stage = 'rebill' else: expected_stage = 'initial' else: expected_stage = "initial" if trans_data['TransSource'] == 122: expected_stage = 'conversion' expected_payment_account_id = db_agent.get_payment_acct_id( trans_id) if expected_payment_account_id == None: expected_payment_account_id = "Wrong => Check MT values" elif action == "refund": data_from_multitrans = db_agent.execute_select_one_parameter( constants.GET_DATA_FROM_MULTITRANS_BY_TRANS_ID, trans_id) initial_trans_id = data_from_multitrans['RelatedTransID'] refund_type = db_agent.execute_select_one_parameter( constants.GET_DATA_FROM_TASKS, trans_id) if refund_type == 841: compare_results( "Collect user info", (3 in matched_postback_types and 4 in matched_postback_types), True) elif refund_type == 842: compare_results("Collect user info", (3 not in matched_postback_types and 4 in matched_postback_types), True) elif refund_type == 843: compare_results("Collect user info", (3 not in matched_postback_types and 4 not in matched_postback_types), True) matched_postback_ids = find_post_backs_ids(package_id, trans_id) for id in matched_postback_ids: initial_parsed_notif_url = parse_post_back_url( db_agent.get_url_from_notif(id, initial_trans_id)) parsed_notif_url = parse_post_back_url( db_agent.get_url_from_notif(id, trans_id)) postback_type = db_agent.get_postback_type_by_postback_id(id) if postback_type == 5: compare_results("Check scarequired", parsed_notif_url.get('scarequired'), initial_parsed_notif_url.get('scarequired')) compare_results( "Check is3dsauthenticated", parsed_notif_url.get('is3dsauthenticated'), initial_parsed_notif_url.get('is3dsauthenticated')) if postback_type == 3: expected_action = "Disable" elif postback_type == 4: expected_action = "Cancel" elif postback_type == 5: if trans_type == 102: expected_action = "auth" elif trans_type == 107: expected_action = "void" else: print("Trans type {} is no allowed for REFUND".format( trans_type)) actual_postback_status = db_agent.get_postback_status_by_id( id, trans_id) expected_postback_status = 863 if trans_type == 102: expected_trantype = "credit" elif trans_type == 107: expected_trantype = "sale" else: print("Trans type {} is no allowed for REFUND".format( trans_type)) expected_stage = "initial" expected_payment_account_id = db_agent.get_payment_acct_id( trans_id) if expected_payment_account_id == None: expected_payment_account_id = "Wrong => Check MT values" elif action == "rebill": matched_postback_ids = find_post_backs_ids(package_id, trans_id) is_first_rebill = (db_agent.execute_select_one_parameter( constants.GET_COUNT_OF_REBILLS_FROM_MULTITRANS, trans_id) == 1) for id in matched_postback_ids: postback_type = db_agent.get_postback_type_by_postback_id(id) expected_action = "auth" actual_postback_status = db_agent.get_postback_status_by_id( id, trans_id) expected_postback_status = 863 expected_trantype = "sale" if is_first_rebill: expected_stage = "conversion" else: expected_stage = "rebill" expected_payment_account_id = db_agent.get_payment_acct_id( trans_id) if expected_payment_account_id == None: expected_payment_account_id = "Wrong => Check MT values" elif action == "reactivation": compare_results( "Collect user info", (3 in matched_postback_types and 7 in matched_postback_types), True) matched_postback_ids = find_post_backs_ids(package_id, trans_id) for id in matched_postback_ids: postback_type = db_agent.get_postback_type_by_postback_id(id) expected_action = "auth" actual_postback_status = db_agent.get_postback_status_by_id( id, trans_id) expected_postback_status = 863 expected_trantype = "sale" expected_stage = "reactivation" expected_payment_account_id = db_agent.get_payment_acct_id( trans_id) if expected_payment_account_id == None: expected_payment_account_id = "Wrong => Check MT values" compare_results("Postback Status for {}".format(id), actual_postback_status, expected_postback_status) current_config_URL = db_agent.get_url_from_config(id) parsed_config_url = parse_post_back_url(current_config_URL) parsed_notif_url = parse_post_back_url( db_agent.get_url_from_notif(id, trans_id)) #print('----------------------------------------------------------------------------') # Printg of postbcack params #print(parsed_notif_url) config.logging.info('') config.logging.info(parsed_notif_url) config.logging.info('') # print('----------------------------------------------------------------------------') if not parsed_config_url: #print('Default postback config is used') compare_results("TranType {}".format(id), parsed_notif_url.get('trantype'), expected_trantype.lower()) compare_results("Action {}".format(id), parsed_notif_url.get('action'), expected_action.lower()) compare_results("Stage {}".format(id), parsed_notif_url.get('stage'), expected_stage.lower()) if postback_type == 5: compare_results("Check scarequired", parsed_notif_url.get('scarequired'), scarequired) compare_results("Check is3dsauthenticated", parsed_notif_url.get('is3dsauthenticated'), is3dsauthenticated) compare_results("Payment Account ID {}".format(id), parsed_notif_url.get('paymentaccountid'), expected_payment_account_id) else: add_to_number = 3 if postback_type == 5 else 0 compare_results( "Number of parameters for non-default postback {}".format(id), len(parsed_config_url) + add_to_number, len(parsed_notif_url)) compare_results( "Parameters keys for non-default postback {}".format(id), len(parsed_config_url), len(parsed_config_url.keys() & parsed_notif_url.keys())) if postback_type == 5: compare_results("Check is3dsauthenticated", parsed_notif_url.get('is3dsauthenticated'), is3dsauthenticated) compare_results("Check scarequired", parsed_notif_url.get('scarequired'), scarequired) for key, value in parsed_config_url.items(): temp = value[1:-1] if temp == "trantype": compare_results("TranType {}".format(id), parsed_notif_url.get(key), expected_trantype.lower()) if temp == "action": compare_results("Action {}".format(id), parsed_notif_url.get(key), expected_action.lower()) if temp == "stage": compare_results("Stage {}".format(id), parsed_notif_url.get(key), expected_stage.lower()) if temp == "paymentaccountid" and postback_type == 5: compare_results("Payment Account ID {}".format(id), parsed_notif_url.get(key), expected_payment_account_id) if not errors_dictionary: options.append_list( f"Postback Record Compared => Passed for collect user info: '{get_collect_user_info_code}' and postback types: {matched_postback_types}" ) print( colored( f"Postback Record Compared => Passed for collect user info: '{get_collect_user_info_code}' and postback types: {matched_postback_types}", 'green')) else: print( colored( f"********************* Postbacks MissMatch ****************", 'red')) options.append_list( "********************* Postbacks MissMatch ****************") for param, value in errors_dictionary.items(): tmp = param + " " + value options.append_list(tmp) print(param, value) return errors_dictionary
def sign_up_trans_web(): # Yan pass_fail = False current_transaction_record = {} aprove_or_decline = None if config.test_data['Merchant'] == 'EU': currencies = config.test_data['eu_available_currencies'] else: currencies = config.test_data['us_available_currencies'] for selected_language in config.available_languages: #dmc_currencies = [] config.test_data['lang'] = selected_language for dmc in currencies: config.test_data['dmc'] = dmc config.cnt = config.cnt + 1 try: selected_options = [dmc, selected_language] url_options = options.ref_variables() + options.refurl( ) + config.template config.test_data['url_options'] = url_options options.joinlink() report.scenario() current_transaction_record = web.create_transaction( config.test_data['Type'], config.test_data['eticket'], selected_options, config.test_data['MerchantID'], url_options, config.test_data['processor']) config.test_data[ 'transaction_to_check'] = current_transaction_record aprove_or_decline = options.aprove_decline( current_transaction_record['TransID']) print( colored( f"PurchaseID: {config.test_data['PurchaseID']} | TransId:{config.test_data['TransID']} | TransGuid: {config.test_data['transguid']}", 'yellow')) config.test_case['actual'] = [ f"PurchaseID: {config.test_data['PurchaseID']} | TransId:{config.test_data['TransID']} | TransGuid: {config.test_data['transguid']}" ] if current_transaction_record['full_record']['Authorized']: tmp = current_transaction_record['full_record'] config.oc_tokens[tmp['PurchaseID']] = [ config.test_data['Type'], tmp['MerchantCurrency'], tmp['Language'] ] result = current_transaction_record['full_record'] tmpstr = f"Transaction Aproved : AuthCode:{result['AuthCode']}" print(colored(tmpstr, 'cyan', attrs=['bold'])) else: result = current_transaction_record['full_record'] tmpstr = f"Transaction DECLINED : AuthCode:{result['AuthCode']}" print(colored(tmpstr, 'red', attrs=['bold'])) pass_fail = TransActionService.verify_signup_transaction( current_transaction_record) if pass_fail: pf = "Scenario completed: All Passed" print( colored(f"Scenario completed: All Passed", 'green', attrs=['bold', 'underline', 'dark'])) else: print( colored( f"Scenario had some issues: Failed | Re-Check Manually |", 'red', attrs=['bold', 'underline', 'dark'])) pf = "Scenario had some issues: Failed | Re-Check Manually |" options.append_list(tmpstr) options.append_list(pf) options.append_list('_____Finished Scenario_______') config.test_cases[ config.test_data['TransID']] = config.test_case config.test_case = {} print( colored( "___________________________________________________________Finished Scenario_______________________________________________________________________________________________________", 'grey', 'on_yellow', attrs=['bold', 'dark'])) print() print() except Exception as ex: traceback.print_exc() print(f"{Exception}") pass return current_transaction_record
def cardinal3dsrequests(transid): # card live_record = {} psd2_completed_mt = [] card = {} failed = {} sql = '' pid = 0 psd2_failed = [] item = '' try: visa_secure = config.test_data['visa_secure'] base_field = '' live_field = '' sql = f"select dbo.DecryptString(lookupresponsedata) as lookuprresponse,dbo.DecryptString(AuthResponseData) as authresponse " \ f" from Cardinal3dsRequests where transguid = (select Transguid from multitrans where transid = {transid})" if visa_secure == 0: # out of scope options.append_list( f"Card is Prepaid | No 3DS record | Out of Scope") print( colored( f"Card is Prepaid | No 3DS record | Out of Scope => Pass ", 'green')) if visa_secure == 1: # in scope options.append_list( f"Merchant EU | Not Configured for 3DS | Card EU | No record in Cardinal3dsRequests | In Scope | Should be declined" ) print( colored( f"Merchant EU | Not Configured for 3DS | Card EU | No record in Cardinal3dsRequests | In Scope | Should be declined ", 'red')) elif visa_secure in [2, 3]: if config.test_data['cc'] in config.cards_3ds: card = config.cards_3ds[config.test_data['cc']] try: if 'card' in card: del card['card'] del card['cmpi_authenticate response'] except Exception as ex: traceback.print_exc() print(f"Card is not in the dictionary") print(f"{Exception}") pass live_record = db_agent.execute_select_with_no_params(sql) if live_record == None: print(colored(f"No record recieved from Cardinal ", 'red')) print() else: if not live_record['authresponse'] == '': json_authresponse = json.loads( live_record['authresponse']) # auth_response = json_authresponse['Payload']['Payment']['ExtendedData'] auth_response = { **json_authresponse['Payload'], **json_authresponse['Payload']['Payment']['ExtendedData'] } for item in card: try: if item == 'cPAResStatus': base_field = card[item] live_field = auth_response['PAResStatus'] elif item == 'cSignatureVerification': base_field = card[item] live_field = auth_response[ 'SignatureVerification'] elif item == 'cCavv': base_field = 'value' live_field = auth_response['CAVV'] if live_field != '': live_field = 'value' elif item == 'cEciFlag': base_field = card[item] live_field = auth_response['ECIFlag'] elif item == 'cErrorNo': base_field = card[item] live_field = auth_response['ErrorNumber'] elif item == 'cErrorDesc': base_field = card[item] live_field = auth_response[ 'ErrorDescription'] if base_field == '<blank>' or base_field == '': base_field = {} if base_field == '<blank>' or base_field == '': base_field = {} if base_field != live_field: failed[ item] = f"{base_field}split{live_field} | SCA Required |" except Exception as ex: traceback.print_exc() failed[ item] = f"{base_field} split | Expected_Field is missing from Auth_response | SCA Required" # print(f"Expected_Field: | {item[1:]} | is missing from Auth_response") # print() pass xml_return_string_lookuprresponse = simplexml.loads( live_record['lookuprresponse']) response = xml_return_string_lookuprresponse['CardinalMPI'] for item in card: try: if item[0] != 'c': if item == 'Enrolled': base_field = card[item] live_field = response['Enrolled'] if base_field == '<blank>' or base_field == '': base_field = {} elif item == 'PAResStatus': base_field = card[item] live_field = response['PAResStatus'] if base_field == '<blank>' or base_field == '': base_field = {} elif item == 'SignatureVerification': base_field = card[item] live_field = response[ 'SignatureVerification'] if base_field == '<blank>' or base_field == '': base_field = {} elif item == 'Cavv': if card[item] == '': base_field = {} live_field = response['Cavv'] elif item == 'EciFlag': base_field = card[item] live_field = response['EciFlag'] if base_field == '<blank>' or base_field == '': base_field = {} elif item == 'ACSUrl': base_field = card[item] live_field = response['ACSUrl'] if base_field == '<blank>' or base_field == '': base_field = {} elif base_field == '<value>': base_field = 'https://0merchantacsstag.cardinalcommerce.com/MerchantACSWeb/creq.jsp' elif item == 'Payload': base_field = card[item] live_field = response['Payload'] if base_field == '<blank>' or base_field == '': base_field = {} elif base_field == '<value>': base_field = live_field elif item == 'ErrorNo': base_field = card[item] live_field = response['ErrorNo'] elif item == 'ErrorDesc': base_field = card[item] live_field = response['ErrorDesc'] if base_field == '<blank>' or base_field == '': base_field = {} if base_field != live_field: failed[ item] = f"{base_field}split{live_field}" except Exception as ex: traceback.print_exc() failed[ item] = f"{base_field} split | Expected_Field is missing from CardinalMPI |" # print(f"Expected_Field: | {item} | is missing from CardinalMPI") print() pass elif visa_secure == 4: live_record = db_agent.execute_select_with_no_params(sql) if live_record == None: options.append_list( f"No record found in Cardinal3dsRequests | TransID: {transid} | CC: {config.test_data['cc']} | PPID: {config.test_data['package'][0]['PrefProcessorID']}" ) print( colored( f"No record found in Cardinal3dsRequests | TransID: {transid} | CC: {config.test_data['cc']} | PPID: {config.test_data['package'][0]['PrefProcessorID']}", 'blue')) else: options.append_list( f"Response received from Cardinal | Out Of scope | card {config.test_data['cc']}" ) print( colored( f"Response received from Cardinal | Out Of scope | card {config.test_data['cc']} => Pass ", 'green')) # else: # live_record = db_agent.execute_select_with_no_params(sql) # if live_record == None: # options.append_list(f"Merchant Configured for PSD2 => No record found | TransID: {transid} | CC: {config.test_data['cc']} | PPID: {config.test_data['package'][0]['PrefProcessorID']}") # print(colored(f"Merchant Configured for PSD2 => No record found | TransID: {transid} | CC: {config.test_data['cc']} | PPID: {config.test_data['package'][0]['PrefProcessorID']}", 'blue')) # print() # else: # options.append_list(f"Response received from Cardinal - Not a cardinal test case card {config.test_data['cc']} => Pass") # print(colored(f"Response received from Cardinal - Not a cardinal test case card {config.test_data['cc']} => Pass ", 'green')) if len(failed) > 0: options.append_list( "********************* 3DS verification MissMatch *********************" ) print() print( colored( f"********************* 3DS verification MissMatch *********************", 'red')) for item in failed: tmp = failed[item].split('split') options.append_list( f"Field : {item} => Expected BaseField: {tmp[0]} | Actual : {tmp[1]} " ) print( f"Field : {item} => Expected BaseField: {tmp[0]} | Actual : {tmp[1]} " ) print() if len(failed) == 0 and live_record: options.append_list( f"Cardinal3dsRequests test_case: {config.test_data['cc']} Records Compared => Pass " ) print( colored( f"Cardinal3dsRequests test_case: {config.test_data['cc']} Records Compared => Pass ", 'green')) print() return failed print() except Exception as ex: traceback.print_exc() print(f"{Exception} Tid: {transid,} ") pass