var globalErrorMessage = "Temporary network communication issues prevented us from reaching your contact. Please try again...";
var siteProtocol = "https:";
function showLoginScreen(){
}
function clearErrors(){
$('.errors').css('display', 'none');
$('.errors').html('');
}
function displayErrors(error){
$('.errors').css('display', 'block');
$('.errors').html(error);
}
function updateContent(html){
showHideLoader(false);
if(html=='invalid'){
displayErrors("Invalid session data, please try again.");
}
else{
clearErrors();
$('#content').html(html);
}
}
function getFormDataSerialized(formid)
{
return $(formid).serialize();
}
function edit_resend_email() {
/// don't do this is the PROFILE_EMAIL_ADDRESS is set
if(!window.PROFILE_EMAIL_ADDRESS)
{
$("#inputEmail").prop('disabled', false);
$("#inputEmail").val("");
}
$("#PIN_VERIFICATION_FIELD").html('');
var tmp_button_text = "Click to Continue...";
$("#display_submit_bitton").html('');
}
/*
var xmlDoc;
// For IE based browsers (tested under IE6 and IE7):
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
// Turn off asynchronus download.
// Load the entire file before trying to do anything with it.
xmlDoc.async=false;
//load the country/state XML file windows only
xmlDoc.load("country_state.xml");
}
// For other browsers (Netsacpe/Firefox/Chrome):
else if (document.implementation && document.implementation.createDocument)
{
//Removed line to fix Google Chrome bug (26/01/2009):- xmlDoc = document.implementation.createDocument("","doc",null);
//Replaced with below script
var xmlhttp = new window.XMLHttpRequest();
//load the country/state XML file other browsers
xmlhttp.open("GET","country_state.xml",false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML.documentElement;
}
else
{
// The 'something fails' alert!
alert('Your browser is unable to handle this script');
}
*/
// Populate selected dropdown list with data from XML file
// ()
// Function used for both Country Fill and State Fill
function fillList(selectbox,text,value, is_selected)
{
if(empty(selectbox)) return;
is_selected = typeof is_selected !== 'undefined' ? is_selected : false;
var optionValue = document.createElement("option");
optionValue.text = text;
optionValue.value = value;
optionValue.selected = is_selected;
selectbox.options.add(optionValue);
}
// Populate Country list on page load
// Requires:
on HTML page
function fillCountryList (id, selected_country)
{
selected_country = typeof selected_country !== 'undefined' ? selected_country : "";
// Get country element ID
var countryList = document.getElementById(id);
// Clear any current values in select box
// If JavaScript isn't working existing text will remain
if(!empty(countryList)){
for (var x = countryList.options.length-1; x >-1; x--)
{
countryList.options[x] = null;
}
}
// Fill Country name Array from XML file
var countryNames = xmlDoc.getElementsByTagName("country");
// Gets total Number of countries in XML file
var numberOfCountries = countryNames.length;
// Loop through Country name Array and populate country select
for (var i=0; i -1; x--)
{
stateList.options[x] = null;
}
// Get currently selected ID from country element ID
var countryListSelected = document.getElementById(countryID).selectedIndex;
// Get number of states for current selected Country (populates Array)
var numberStates = xmlDoc.getElementsByTagName("country")[countryListSelected].getElementsByTagName("state").length;
// Loop through States/Province Array and populate State/Province selection for current Country
for (var i=0; i < numberStates; i++)
{
if(!empty(xmlDoc.getElementsByTagName("country")[countryListSelected].getElementsByTagName("state")[i].firstChild)){
var currentState = xmlDoc.getElementsByTagName("country")[countryListSelected].getElementsByTagName("state")[i].firstChild.nodeValue;
var is_selected = false;
if(currentState==selected_state)
is_selected = true;
fillList(stateList,currentState,currentState,is_selected);
}
}
}
var countryStatesXml = null;
function loadCountryStateList(){
$.ajax({
type: "GET",
url: "business_registered_region.xml",
dataType: "xml",
success: function(xml) {
countryStatesXml = xml;
fillCountryStateList();
} //sucess close
});
}
function fillCountryStateList(){
if(!empty(countryStatesXml)){
console.log('countryStatesXml State', $('#verification_region option:selected').text());
var verification_region = $('#verification_region').val(); //$('#verification_region option:selected').text(); //'United States'; //$('#verification_region').val();
var states = $(countryStatesXml).find('country[name="' + verification_region + '"]');
//fillSelectOptions('#business_registered_region', states);
//$('#business_registered_region').html('');
$('#business_registered_region').html("");
//$.each(states, function(i, val){
$(states).find('state').each(function(){
//var value = $(this).attr('value');
var label = $(this).text();
if(!empty(label)){
$('#business_registered_region').append("");
}
});
//});
}
}
function validateText(field, callerEvent) {
if(field.value) {
var fieldValue = field.value.trim();
}
if(typeof(callerEvent) != 'undefined') {
if(callerEvent.toUpperCase() == "ONFOCUS") {
showEmptyImg(field);
return;
}
}
if(typeof(callerEvent) != 'undefined') {
if(callerEvent.toUpperCase() == "ONKEYUP") {
if( (fieldValue == "") || (fieldValue == null) || (!fieldValue) ) {
showErrorImg(field);
return;
} else {
showValidImg(field);
return;
}
}
}
if(typeof(callerEvent) != 'undefined') {
if(callerEvent.toUpperCase() == "ONCHANGE") {
if( (fieldValue == "") || (fieldValue == null) || (!fieldValue) ) {
showErrorImg(field);
return;
} else {
showValidImg(field);
return;
}
}
}
if(typeof(callerEvent) != 'undefined') {
if(callerEvent.toUpperCase() == "ONBLUR") {
if( (fieldValue == "") || (fieldValue == null) || (!fieldValue) || (fieldValue=='Select a country...') || (fieldValue=='Select One...') ) {
showErrorImg(field);
return;
} else {
showValidImg(field);
return;
}
}
}
// if(callerEvent.toUpperCase() == "ONLOAD") {
// if((fieldValue == "") || (fieldValue == null)) {
// showErrorImg(field);
// return;
// } else {
// showValidImg(field);
// return;
// }
// }
//
}
function validateCheckbox(field) {
if($(field).prop("checked")){
showValidImg(field);
}
else{
showErrorImg(field);
}
return;
}
function validateSelectDOB(field) {
// validateBirthdate(this,'');
var prefix = "";
var birthdateStatus = checkBirthdateCompletion(prefix);
//if(callerEvent != "onfocus") alert(birthdateStatus);
if(birthdateStatus == "none") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "some") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "all") {
//alert('window.regPaymeBirthdate: ' + window.regPaymeBirthdate);
showBirthdateValidImg(prefix);
//checkAccountBasics();
//toggleVoiceAuth();
//alert(window.regBDAY);
return;
}
}
function validateTSYSDOB(field) {
// validateBirthdate(this,'');
var prefix = "tsys_";
var birthdateStatus = checkBirthdateCompletion(prefix);
//if(callerEvent != "onfocus") alert(birthdateStatus);
if(birthdateStatus == "none") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "some") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "all") {
//alert('window.regPaymeBirthdate: ' + window.regPaymeBirthdate);
showBirthdateValidImg(prefix);
//checkAccountBasics();
//toggleVoiceAuth();
//alert(window.regBDAY);
return;
}
}
function validateTSYSUSDirectDOB(field) {
// validateBirthdate(this,'');
var prefix = "tsys_us_direct_";
var birthdateStatus = checkBirthdateCompletion(prefix);
//if(callerEvent != "onfocus") alert(birthdateStatus);
if(birthdateStatus == "none") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "some") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "all") {
//alert('window.regPaymeBirthdate: ' + window.regPaymeBirthdate);
showBirthdateValidImg(prefix);
//checkAccountBasics();
//toggleVoiceAuth();
//alert(window.regBDAY);
return;
}
}
function validateOfficialDOB(field) {
// validateBirthdate(this,'');
var prefix = "official_";
var birthdateStatus = checkBirthdateCompletion(prefix);
//if(callerEvent != "onfocus") alert(birthdateStatus);
if(birthdateStatus == "none") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "some") {
showBirthdateWaitingImg(prefix);
return;
} else if(birthdateStatus == "all") {
//alert('window.regPaymeBirthdate: ' + window.regPaymeBirthdate);
showBirthdateValidImg(prefix);
//checkAccountBasics();
//toggleVoiceAuth();
//alert(window.regBDAY);
return;
}
}
function checkBirthdateCompletion(prefix) { // had and removed "personalRegistration2" as a variable???
var validBirthday = new Array();
validBirthday[0] = true;
validBirthday[1] = true;
validBirthday[2] = true;
validBirthday[3] = true;
var selectFields = new Array();
selectFields[1] = prefix + "birth_year";
selectFields[2] = prefix + "birth_month";
selectFields[3] = prefix + "birth_day";
for (var i=1; i < selectFields.length; i++) {
//alert('i: ' + i);
//alert(document.bangkForm[selectFields[i]].value);
if (document.frmPayment[selectFields[i]].value.trim() == '') {
validBirthday[0] = false;
validBirthday[i] = false;
} else {
validBirthday[i] = document.frmPayment[selectFields[i]].value;
}
}
if((validBirthday[1] != false) && (validBirthday[2] != false) && (validBirthday[3] != false)) {
window.confirmBirthDay = validBirthday[3];
window.confirmBirthMonth = validBirthday[2];
window.confirmBirthYear = validBirthday[1];
return "all";
} else if((validBirthday[1] == false) && (validBirthday[2] == false) && (validBirthday[3] == false)) {
return "none";
} else {
return "some";
}
}
function displayTheirFee(field) {
//payme function?
//alert("field.value: "+field.value);
var amountToPay = parseFloat(field.value).toFixed(2);
//alert("amountToPay: "+amountToPay);
var thierFeePercentage = "0.000";
//alert("thierFeePercentage: "+thierFeePercentage);
// THEIR ACTUAL FEE
var theirfee = parseFloat(amountToPay * thierFeePercentage).toFixed(2);
//alert("0. theirfee: "+theirfee);
if ( isNaN(theirfee) ) {
theirfee = "0.00";
}
//alert("1. theirfee: "+theirfee);
/// transactionFeeTheir
if(
(typeof document.getElementById('transactionFeeTheir') != 'undefined') &&
(document.getElementById('transactionFeeTheir') != null)
) {
document.getElementById('transactionFeeTheir').innerHTML = theirfee;
}
/// printCurrency0fee
if(
(typeof document.getElementById('printCurrency0fee') != 'undefined') &&
(document.getElementById('printCurrency0fee') != null)
) {
document.getElementById('printCurrency0fee').innerHTML = theirfee;
}
//alert(theirfee);
//alert(amountToPay);
var theirtotal = parseFloat(amountToPay) + parseFloat(theirfee);
//alert(theirtotal);
if (
(isNaN(theirtotal)) ||
(theirtotal == null)
) {
theirtotal = "0";
}
if(
(typeof document.getElementById('theirTotalCharge') != 'undefined') &&
(document.getElementById('theirTotalCharge') != null)
) {
document.getElementById('theirTotalCharge').innerHTML = theirtotal.toFixed(2);
}
if(
(typeof document.getElementById('printCurrency0total') != 'undefined') &&
(document.getElementById('printCurrency0total') != null)
) {
document.getElementById('printCurrency0total').innerHTML = theirtotal.toFixed(2);
}
}
function displayPersonalIdentity(e, id){
//console.log('id, value', id , $(e).val());
if(id=='#lbl_personal_identity_date_of_bith'){
var prefix = "tsys_";
var birthdateStatus = checkBirthdateCompletion(prefix);
if(birthdateStatus == "all") {
$(id).html(window.confirmBirthYear + '-' + window.confirmBirthMonth + '-' + window.confirmBirthDay);
}
}
else if(id == '#tsys_us_direct_business_name'){
//if(empty($('#tsys_us_direct_business_name').val())){
//var full_name = $.trim($('#tsys_us_direct_first_name').val() + ' ' + $('#tsys_us_direct_last_name').val());
var b_name = decodeURIComponent($('#tsys_us_direct_business_name').val());
var b_type = decodeURIComponent($('#tsys_us_direct_business_type').val());
$('.display_business_name').html(b_name);
var unregistered_business_type = b_type.indexOf("unregistered");
if( (unregistered_business_type == -1) || (b_type == null) ) {
var insert_b_type = " " + b_type;
} else {
var insert_b_type = "";
}
if(b_type.indexOf("SOLE PROPRIATOR") > -1) { insert_b_type = ""; }
if(insert_b_type == " " + null) { insert_b_type = ""; } // WAHETVER!!!! f'ing hate js
//alert("b_type: "+b_type);
//alert("insert_b_type: "+insert_b_type);
$('.display_business_type').html(insert_b_type);
//}
}
else if(id == '#tsys_us_direct_business_website'){
if(empty($('#tsys_us_direct_business_website').val())){
document.configureAccount3['is_advertise_website'].checked = false;
}
}
else{
$(id).html($(e).val());
}
}
function TOGGLE_BUSINESS_BANKING(e){
$('.PERSONAL_business_type_block').css('display', 'none');
$('.BUSINESS_business_type_block').css('display', 'none');
$('#banking_type1').parent().parent().removeClass('has-success has-error has-feedback');
$('#banking_type2').parent().parent().removeClass('has-success has-error has-feedback');
$('.'+$(e).val() + '_business_type_block').css('display', 'block');
fillPhotoIdForm();
}
function displayPersonalBusinessType(e){
fillPhotoIdForm();
}
function displayRegisteredBusinessType(e){
$('.registered_business_type_display').html($(e).val());
fillPhotoIdForm();
}
function displayBusinessName(field, el_class){
var text_to_display = field.value;
text_to_display = text_to_display.replace(/ /g, "-");
text_to_display = text_to_display.replace(/\./g, "-");
$('.' + el_class).html(text_to_display);
fillPhotoIdForm();
}
/// STATUS ICONS ////////////////////////////////////////////////////////////
function showDefaultImg(field) {
}
function showErrorImg(field) {
$(field).parent().removeClass('has-success has-error has-feedback');
$(field).parent().addClass('has-error has-feedback');
$(field).next('.glyphicon').remove();
$(field).after('');
showDocumentValidImg(field, false);
}
function showWorkingImg(field) {
}
function showValidImg(field) {
$(field).parent().removeClass('has-success has-error has-feedback');
$(field).parent().addClass('has-success has-feedback');
$(field).next('.glyphicon').remove();
$(field).after('');
showDocumentValidImg(field, true);
}
function showEmptyImg(field) {
}
function showDocumentValidImg(field, isDisplay){
var option_val = $(field).val();
var option_id = $(field).attr('id');
$(field).removeClass('completed');
$(field).closest('fieldset').removeClass('completed');
$(field).closest('.ui-body').removeClass('completed');
//console.log('>>', option_id, option_val);
if( !empty(option_id) && ( option_id == 'slefie_document_type' || option_id == 'personal_document_type' || option_id == 'business_document_type' || option_id == 'pricing_document_type' || option_id == 'processing_document_type' || option_id == 'residence_document_type' || option_id == 'tax_returns_document_type') ){
var uploaded = 0;
$(field).closest('div.ui-body').find('.photo-container').each(function(){
if($(this).attr('upload-status') == "uploaded"){
uploaded++;
}
});
//console.log('>>', uploaded);
if(!empty(option_val) && uploaded > 0){
$(field).addClass('completed');
$(field).closest('fieldset').addClass('completed');
$(field).closest('.ui-body').addClass('completed');
}
}
else{
if(isDisplay){
$(field).addClass('completed');
$(field).closest('fieldset').addClass('completed');
$(field).closest('.ui-body').addClass('completed');
}
}
}
function showBirthdateValidImg(prefix) {
$('#' + prefix + 'birth_year').parent().removeClass('has-success has-error has-feedback');
$('#' + prefix + 'birth_year').parent().addClass('has-success has-feedback');
}
function showBirthdateEmptyImg(prefix) {
}
function showBirthdateErrorImg(prefix) {
$('#' + prefix + 'birth_year').parent().removeClass('has-success has-error has-feedback');
$('#' + prefix + 'birth_year').parent().addClass('has-error has-feedback');
}
function showBirthdateWaitingImg(prefix) {
$('#' + prefix + 'birth_year').parent().removeClass('has-success has-error has-feedback');
$('#' + prefix + 'birth_year').parent().addClass('has-error has-feedback');
}
function fillCallingCode(country){
country = $('#cboCountry').val();
$.ajax({
type: "GET"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/country_to_callingcode.gate'
,data: { country_name: country }
,dataType: 'json'
,success:function(data){
if(data!=null){
$('#telephone_country_iso3').val(data.country_iso3);
$('#telephone_calling_code').val('+' + data.calling_code);
}
}
,error:function(){
}
,complete:function(){
}
});
return false;
}
var CUSTOMER_IP = '0.0.0.0';
var viewport = null;
$(document)
.ready(function () {
//alert('loaded');
//goLogin();
viewport = {
width : $(window).width(),
height : $(window).height()
};
//AGENT_ACCOUNT_HASH
if(empty(agent_account_hash)){
$('#agentLogin').show();
$('#agentLogout').hide();
}
else{
$('#agentLogin').hide();
$('#agentLogout').show();
}
$('body').css('height', viewport.height);
//CLIENT IP
$.ajax({
type: "GET"
,async: true
,url: siteProtocol + '//'+API_DOMAIN+'/link_gateway/mobile_client_ip.gate'
,data: {}
,success:function(data){
CUSTOMER_IP = data;
console.log('CUSTOMER_IP', CUSTOMER_IP);
}
,error:function(jqXHR, errorText){
console.log('CUSTOMER_IP>ERROR', errorText);
}
});
loadCountryStateList();
//fillCountryList('cboCountry', '');fillStateList('cboCountry', 'cboState', '');
//getTermsAndConditionsAggreementText();
//getMemberEmailAddress();
// $.ajax({
// type: "GET"
// ,url: '//h-api.online-metrix.net/api/session-query?org_id=aohuqk6o&api_key=ezgonqbva6s44p68&session_id=' + token() + '&service_type=session-policy&event_type=ACCOUNT_CREATION&account_email=shea.writer@nsdb.com&ssn_hash=7eb6603566ad2fa44d1e7092d1dab2af4ac20bbd164ec9bb4f015fc193bffc1d&input_ip_address=67.29.138.7&policy='
// ,data: {}
// ,success:function(data){
// console.log('TM >', data);
// }
// ,error:function( jqXHR, textStatus, errorThrown){
// console.log('TM > ERROR ' + 'textStatus=' + textStatus + ' errorThrown=' + errorThrown);
// }
// });
});
var rand = function() {
return Math.random().toString(36).substr(2); // remove `0.`
};
var token = function() {
return rand() + rand() + rand(); // to make it longer
};
function showProgressDialog(msg){
var processingMessage = "Working...";
if(!empty(msg)) processingMessage = msg;
//window.location.href = SITE_SCHEMA+'://showProgressDialog?processingMessage=' + processingMessage;
showLoader(processingMessage);
}
function hideProgressDialog(){
//window.location.href = SITE_SCHEMA+'://hideProgressDialog';
hideLoader();
}
function checkAmountLimit(){
var url = siteProtocol + '//'+API_DOMAIN+'/link_gateway/get_account_limits.gate?member_hash=' + member_hash + '&account_hash=' + selected_account_hash;
$('#recipient_requested_amount').parent().append('
With your device camera, you may now please take a photo of your Proof of Additional Business Identity — Simply click on the button (below): "Take a Photo"! — or if you have a file/scan/or photo (of your Additional Business ID) already "in" your device gallery/storage, then: "Upload a File"!
');
$('.proof' + imageNo + ' .selectedImage .photo-container').remove(); //photo-container photo1
$('.proof' + imageNo + ' .selectedImage .selectedImageInfo').show();
}
}
function backToVerificationForm(){
showStepPage('#identity_verification_form');
return false;
}
function goToTopOfPage(){
$('html, body').animate({
scrollTop: $(".form-signin-heading").offset().top
}, 1000);
}
function showStepPage(id){
console.log("510-showStepPage(id)",id);
$('.logout').parent().css('display', 'none');
$('.step-page').css('display', 'none');
$(id).css('display', 'block');
searchHistory.push(id);
if(id == '#payment_receipt' || id == '#identity_verification_form_result' || id =='#email_invoice_form_receipt'){
searchHistory = []; //clear searHistory
}
fillDemoForm();
if(demoAccountHash==account_hash && id=='#payment_form'){
//
}
else if(id == '#account_form'){
$('.logout').parent().css('display', 'block');
showAccountLists();
}
else if(
id=='#selected_account_form'
|| id=='#email_invoice_form'
|| id=='#email_invoice_form_receipt'
|| id=='#identity_verification_region'
|| id=='#verification_form_advanced'
){
console.log("511-showStepPage(id)",id);
$('.logout').parent().css('display', 'none');
}
else if(id=='#identity_verification_form'){
$('.logout').parent().css('display', 'none');
$('html, body').animate({
scrollTop: $(".form-signin-heading").offset().top
}, 1000);
}
else if(id=='#identity_verification_photo_form'){
$('.logout').parent().css('display', 'none');
$('html, body').animate({
scrollTop: $(".form-signin-heading").offset().top
}, 1000);
}
else if(id=='#identity_verification_form_result'){
$('.logout').parent().css('display', 'none');
}
else{
//$('.logout').parent().css('display', 'block');
}
//fill form data
if(id=='#identity_verification_region'){
console.log("512-showStepPage(id)",id);
var tmp_verification_region = $('#verification_region').val(verification_region);
console.log("513-tmp_verification_region",tmp_verification_region);
if(empty($('#verification_region').val())){
verification_region = $("#verification_region").find("option").eq(0).val();
$("#verification_region").val(verification_region);
}
// if(email_address == 'demo@corp.nsdb.com' || email_address == 'demo@payyap.network' || email_address == 'shahid@corp.nsdb.com'){
// //
// }
// else{
// //REMOVE UNITED_STATES_DIRECT OPTION FOR NOT DEMO ACCOUNTS
// if($("#verification_region").find("option").eq(0).val() == 'united_states_direct'){
// $("#verification_region").find("option").eq(0).remove();
// $("#verification_region").val($("#verification_region").find("option").eq(0).val());
// verification_region = $("#verification_region").find("option").eq(0).val();
// }
// }
}
goToTopOfPage();
return false;
}
function selectAccount(account_hash, account_name){
$('.form-group').removeClass('has-error has-success has-feedback');
$('.form-group .glyphicon').remove();
selected_account_hash = account_hash;
resetPaymentForm();
var selected_account_details = getSelectAccountDetails();
//console.log(selected_account_details);
if(selected_account_details!=null){
$('.lblAccountName').html(selected_account_details.account_name);
$('.account_name').html(selected_account_details.account_name);
$('.account_balance').html(selected_account_details.account_balance);
if(empty(selected_account_details.service_message)){
$('.service-message-row').css('display', 'none');
}
else{
$('.service_message').html(selected_account_details.service_message);
$('.service-message-row').css('display', 'block');
}
//showTransactionHistory();
//showStepPage('#selected_account_form');
show_device_alert('SUCCESS', "\n\nAlert!\n\nYour account is already Approved!\n\n(Please contact Customer Support if you would like to edit / update your profile.)");
}
else{
show_device_alert('ERROR', "An error occured, please try again!");
}
}
function showSubmittedAlert(isApproved){
console.log("showSubmittedAlert(isApproved)",isApproved);
var message = "(1) You have already submitted your profile. A final activation notice will be sent to your registered email address once your payment processing account has been approved. Now sit back, relax... and allow up to 72 hours for your account to be acivated!";
var selected_account_details = accountMenus;
//console.log(selected_account_details);
if( !empty(selected_account_details) ){
if(isApproved){
message = '';
if(!empty(selected_account_details.your_profile_is_approved_alert_text) ){
message = selected_account_details.your_profile_is_approved_alert_text;
}
}
else{
if(!empty(selected_account_details.your_have_already_submitted_your_profile_alert_text) ){
message = selected_account_details.your_have_already_submitted_your_profile_alert_text;
}
}
}
if(!empty(message)){
//show_device_alert('ERROR', message);
show_device_confirm('ERROR', message, true);
}
return false;
}
function showApprovedAlert(account_hash) {
console.log("showApprovedAlert(isApproved)",account_hash);
var isApproved = true;
var message = "(2) You have already submitted your profile. A final activation notice will be sent to your registered email address once your payment processing account has been approved. Now sit back, relax... and allow up to 72 hours for your account to be acivated!";
var selected_account_details = accountMenus;
//console.log(selected_account_details);
if( !empty(selected_account_details) ){
if(isApproved){
message = '';
if(!empty(selected_account_details.your_profile_is_approved_alert_text) ){
message = selected_account_details.your_profile_is_approved_alert_text;
}
}
else{
if(!empty(selected_account_details.your_have_already_submitted_your_profile_alert_text) ){
message = selected_account_details.your_have_already_submitted_your_profile_alert_text;
}
}
}
if(!empty(message)){
//show_device_alert('ERROR', message);
//show_device_confirm('ERROR', message, true);
console.log("showApprovedAlert(message)",message);
var confirm_value = confirm(message);
if(confirm_value == true) {
console.log("showApprovedAlert(account_hash)",account_hash);
verifyAccount(account_hash);
return true;
} else {
return false;
}
}
return false;
}
var transaction_session_hash = '';
function openPaymentForm(){
transaction_session_hash = rand();
showStepPage('#payment_form');
$('#payment_form #amount').focus();
return false;
}
function showEmailInvoiceForm(){
show_device_alert('ALERT', "Coming Soon...");
//showStepPage('#email_invoice_form');
return false;
}
function getSelectAccountDetails(){
var selected_account_details = null;
console.log("700-getSelectAccountDetails",selected_account_details);
console.log("701-accountLists",accountLists);
if(accountLists!=null){
$.each(accountLists, function(index, item){
console.log("702-item.account_hash", index, item.account_hash);
if(item.account_hash == selected_account_hash){
//console.log(selected_account_hash, item);
selected_account_details = item;
}
});
}
console.log("703-selected_account_details", selected_account_details);
return selected_account_details;
}
function getSelectAccountDetails_v2(accountLists){
console.log("222-accountLists: "+accountLists);
var selected_account_details = null;
//if(!accountLists) accountLists = window.accountLists;
if(accountLists != null){
$.each(accountLists, function(index, item){
if(item.account_hash == selected_account_hash){
//console.log(selected_account_hash, item);
selected_account_details = item;
}
});
}
return selected_account_details;
}
var verifyFormCountryLoaded = false;
function verifyAccount(account_hash){
console.log('041-verifyAccount()',account_hash);
$('.form-group').removeClass('has-error has-success has-feedback');
$('.form-group .glyphicon').remove();
//window.location.href = SITE_SCHEMA+'://confirmAccountVerification';
showVerificationForm(account_hash);
return false;
}
function showVerificationForm(account_hash){
console.log("042-showVerificationForm()",account_hash);
selected_account_hash = account_hash;
//show_device_alert('ERROR', 'ALERT: This account needs to be validated before is it able to receives money. Please use your email address, to log into your BANGK! Account @ //login.payyap.network, and follow the logical instructions to Verify this account. Account validation takes about 5 minutes from your desktop, laptop or tablet.');
if(!verifyFormCountryLoaded){
//fillCountryList('official_country_of_citizenship');
//fillCountryList('residential_country');fillStateList('residential_country', 'residential_state');
//fillCountryList('business_country');fillStateList('business_country', 'business_state');
//fillCountryList('banking_country');fillStateList('banking_country', 'banking_state');
verifyFormCountryLoaded = true;
}
var selected_account_details = getSelectAccountDetails();
console.log("042-showVerificationForm(selected_account_details)",selected_account_details);
if(!empty(selected_account_details.activate_business_document_3) && selected_account_details.activate_business_document_3 == "YES"){
// $('#additional_business_document_type').html('');
// $.each(selected_account_details.activate_business_document_3_pulldown_option, function(i, val){
// $('#additional_business_document_type').append('');
// });
//fillSelectOptions('#additional_business_document_type', selected_account_details.activate_business_document_3_pulldown_option);
//showStepPage('#TSYS_US_Direct_form_proof_of_additional_identity');
console.log("503-buildDocument3Uploader(1)");
buildDocument3Uploader(1);
}
else if(startPage == 3){
console.log("504-startPage",startPage);
showStepPage('#TSYS_US_Direct_form_final');
$('#tsys_us_direct_business_name').focus();
}
else{
//var selected_account_details = getSelectAccountDetails();
console.log("505-showVerificationForm");
fillSelectOptions('#business_category', selected_account_details.KYC_business_category_pulldown_options);
fillSelectOptions('#business_description', selected_account_details.KYC_business_description_pulldown_options);
fillSelectOptions('#personal_document_type', selected_account_details.KYC_option_text_proof_of_person);
fillSelectOptions('#business_document_type', selected_account_details.KYC_option_text_proof_of_business);
fillSelectOptions('#pricing_document_type', selected_account_details.KYC_option_text_proof_of_pricing);
fillSelectOptions('#processing_document_type', selected_account_details.KYC_option_text_proof_of_processing);
fillSelectOptions('#residence_document_type', selected_account_details.KYC_option_text_proof_of_personal_residence);
fillSelectOptions('#tax_returns_document_type', selected_account_details.KYC_option_text_proof_of_business_tax_returns);
//fillSelectOptions('#business_registered_region', selected_account_details.business_registered_region_options);
//fillSelectOptions('#business_registered_country_iso3', selected_account_details.business_registered_country_iso3_options);
updateTitleAndDescriptiveParagraph('#business_category', selected_account_details.KYC_business_category_pulldown_title, '');
updateTitleAndDescriptiveParagraph('#business_description', selected_account_details.KYC_business_description_pulldown_title, '');
updateTitleAndDescriptiveParagraph('#personal_document_type', selected_account_details.KYC_option_text_proof_of_person_title, selected_account_details.KYC_option_text_proof_of_person_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#business_document_type', selected_account_details.KYC_option_text_proof_of_business_title, selected_account_details.KYC_option_text_proof_of_business_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#pricing_document_type', selected_account_details.KYC_option_text_proof_of_pricing_title, selected_account_details.KYC_option_text_proof_of_pricing_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#processing_document_type', selected_account_details.KYC_option_text_proof_of_processing_title, selected_account_details.KYC_option_text_proof_of_processing_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#residence_document_type', selected_account_details.KYC_option_text_proof_of_personal_residence_title, selected_account_details.KYC_option_text_proof_of_personal_residence_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#tax_returns_document_type', selected_account_details.KYC_option_text_proof_of_business_tax_returns_title, selected_account_details.KYC_option_text_proof_of_business_tax_returns_descriptive_paragraph);
updateTitleAndDescriptiveParagraph('#slefie_document_type', selected_account_details.KYC_option_text_selfie_title, selected_account_details.KYC_option_text_selfie_descriptive_paragraph);
showStepPage('#identity_verification_region');
//set form
if(!empty(selected_account_details.KYC_option_request_business_url_required) && selected_account_details.KYC_option_request_business_url_required == 'TRUE'){
console.log("506-showVerificationForm");
$('#tsys_us_direct_business_website').addClass('required');
$('#tsys_us_direct_business_website').prev().find('.field-optional').addClass('hide-filed');
}
else{
console.log("507-showVerificationForm");
$('#tsys_us_direct_business_website').removeClass('required');
$('#tsys_us_direct_business_website').prev().find('.field-optional').removeClass('hide-filed');
}
//changePageWithHeaderFooter('#configureAccount');
//checkAndShowNextForm(1);
}
console.log("508-showVerificationForm");
KYC_getSESSION();
}
function closeSignatureForm(){
setTimeout(function(){
$( "#signatureDialog" ).popup( "close" );
}, 1000);
}
function openSignatureForm(el){
gImageNo = 100;
$( "#signatureDialog" ).popup();
$( "#signatureDialog" ).popup( "open" );
return false;
}
function showSignatureImage(data){
closeSignatureForm();
console.log('showSignatureImage > ', data);
//var imageURL = siteProtocol + '//' + API_DOMAIN + '/authorizations/ids/' + account_hash + '_signature.png';
$('#sign').removeClass('do_not_display');
$('#sign').attr('src', data);
if(form_flow == 'single_page'){
//
}
else{
setTimeout(function(){
uploadPhoto();
setTimeout(function(){ openUploadProgressPopup(); }, 500);
}, 500);
}
return false;
}
function confirmTakePhoto1(n){
confirmTakePhoto(n + $('.additional_business_document_number').val());
return false;
}
function confirmSelectPhoto1(n){
confirmSelectPhoto(n + $('.additional_business_document_number').val());
return false;
}
function buildDocument3Uploader(n){
var selected_account_details = getSelectAccountDetails();
//selected_account_details.activate_business_document_3;
//RESET UPLOADER
$('#additional_business_document_type').parent().removeClass('has-success has-feedback has-error').find('.glyphicon').remove();
$('.proof6' + n + ' .selectedImage').html('
With your device camera, you may now please take a photo of your Proof of Additional Business Identity — Simply click on the button (below): Take A Photo! Or if you have a file, scan, or photo (of your Additional Business ID) already in your device gallery / storage, then: Upload A File!
'
if(data.length>0){
$('#transactionHistoryCancel').css('display', 'block');
}
$('#transactionHistoryBlock').css('display', 'block');
$('#transactionHistoryBlock').html(history_html);
$('#transactionHistoryBlock table tr').unbind('click');
$('#transactionHistoryBlock table tr').click(function(event){
var history_hash = $(this).attr('data-history-hash');
if(empty(history_hash)) return false;
openTransactionDetailsPopup(history_hash);
});
}
}
,error:function(){
var history_html = '';
$('#transactionHistoryBlock').html(history_html);
}
,complete:function(){
$('#transactionHistoryCancel').css('display', 'block');
}
});
return false;
}
function openTransactionDetailsPopup(hash){
if(empty(hash)) return false;
var windowWidth = window.outerWidth; //$(window).width();
var windowHeight = window.outerHeight; //$(window).height();
if($('body').height() < windowHeight){
$('body').css('height', windowHeight);
}
$('#transactionDetails').css('max-height', (windowHeight - 180));
$('#transactionDetails').css('overflow', 'auto');
$('#transactionDetailsModal').modal({
backdrop: 'static',
keyboard: false
});
$('#transaction_hash').val(hash);
////gateway.payyap.network/PAYYAP_transaction_details.gate?transaction_hash=10487abc06bac1c2853f6547bd55ff34
$.ajax({
type: "GET"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/PAYYAP_transaction_details.gate'
,data: {transaction_hash: hash}
//,dataType: 'json'
,success:function(data){
if(data == 'INVALID'){
show_device_alert('ERROR', "Details are not available for this transaction.");
closeTransactionDetailsPopup();
}
else $('#transactionDetails').html(data);
}
,error:function(){
show_device_alert('ERROR', "An error occurred, please try again.");
closeTransactionDetailsPopup();
}
,complete:function(){
}
});
return false;
}
function retryThisTransaction(){
var hash = $('#transaction_hash').val();
if(empty(hash)) return false;
showProgressDialog("Working...");
setTimeout(function(){
////gateway.payyap.network/PAYYAP_retry.gate?api_session_hash=10487abc06bac1c2853f6547bd55ff34
$.ajax({
type: "GET"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/PAYYAP_retry.gate'
,data: {api_session_hash: hash}
,dataType: 'json'
,success:function(data){
hideProgressDialog();
setTimeout(function(){
try {
//data = $.parseJSON(data);
if(!empty(data)){
var AUTHORIZATION_AMOUNT = 0.0;
if(!empty(data.AUTHORIZATION_AMOUNT)) AUTHORIZATION_AMOUNT = parseFloat(data.AUTHORIZATION_AMOUNT);
var CUSTOMER_FULL_NAME = '';
if(!empty(data.CUSTOMER_FULL_NAME)) CUSTOMER_FULL_NAME = data.CUSTOMER_FULL_NAME;
var CUSTOMER_TELEPHONE_COUNTRY_CODE = '';
if(!empty(data.CUSTOMER_TELEPHONE_COUNTRY_CODE)) CUSTOMER_TELEPHONE_COUNTRY_CODE = data.CUSTOMER_TELEPHONE_COUNTRY_CODE;
var CUSTOMER_TELEPHONE_NUMBER = '';
if(!empty(data.CUSTOMER_TELEPHONE_NUMBER)) CUSTOMER_TELEPHONE_NUMBER = data.CUSTOMER_TELEPHONE_NUMBER;
$('#amount').val(AUTHORIZATION_AMOUNT);
$('#name_on_card').val(CUSTOMER_FULL_NAME);
$('#telephone_country_iso3').val(CUSTOMER_TELEPHONE_COUNTRY_CODE);
$('#telephone_number').val(CUSTOMER_TELEPHONE_NUMBER);
showStepPage('#payment_form');
$('#payment_form #amount').focus();
closeTransactionDetailsPopup();
}
else show_device_alert('ERROR', data);
}
catch(err) {
//console.log(err.message);
show_device_alert('ERROR', "An error occurred, please try again.");
}
}, 500);
}
,error:function(){
show_device_alert('ERROR', "An error occurred, please try again.");
}
,complete:function(){
hideProgressDialog();
}
});
}, 500);
return false;
}
function refundThisTransaction(){
window.location.href = SITE_SCHEMA+'://confirmRefundThisTransaction';
return false;
}
function confirmRefundThisTransaction(){
var hash = $('#transaction_hash').val();
if(empty(hash)) return false;
showProgressDialog("Working...");
setTimeout(function(){
////gateway.payyap.network/PAYYAP_refund.gate?api_session_hash=10487abc06bac1c2853f6547bd55ff34
$.ajax({
type: "GET"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/PAYYAP_refund.gate'
,data: {api_session_hash: hash}
//,dataType: 'json'
,success:function(data){
hideProgressDialog();
setTimeout(function(){
if(data == 'SUCCESS') show_device_alert('SUCCESS', data);
else show_device_alert('ERROR', data);
setTimeout(function(){
closeTransactionDetailsPopup();
showTransactionHistory();
}, 500);
}, 500);
}
,error:function(){
show_device_alert('ERROR', "An error occurred, please try again.");
}
,complete:function(){
hideProgressDialog();
}
});
}, 500);
return false;
}
function closeTransactionDetailsPopup(){
$('#transactionDetailsModal').modal('hide');
}
function generateRandomNumber(){
return Math.floor((Math.random() * 100) + 1);
}
function show_device_alert(type, msg, callback){
//window.location.href = SITE_SCHEMA+'://showAlert/' + type + ':' + msg;
if(empty(callback)) callback = '';
//window.location.href = SITE_SCHEMA+'://showAlert?type=' + type + '&msg=' + encodeURIComponent(msg) + '&callback=' + callback;
if(!empty(msg)) alert(msg);
if(!empty(callback)) eval("callback();");
}
function show_device_confirm(type, msg, display_confirmation_message , callback){
console.log('show_device_confirm',type);
console.log('show_device_confirm',msg);
console.log('show_device_confirm',1);
if(empty(callback)) callback = '';
console.log('show_device_confirm',2);
//window.location.href = SITE_SCHEMA+'://showConfirm?type=' + type + '&msg=' + encodeURIComponent(msg) + '&callback=' + callback;
if(!empty(msg)){
console.log('show_device_confirm',3);
/// START: ODDITY
///
/// this used to show a confirmation message;
/// somehow if the user waited too long to confirm, it would fail to open the file finder in CHROME (only!);
/// temp solution: do not display message when file upload is selected;
/// ideally would be nice have some message that displays typs of document supported:
/// used "display_confirmation_message" variable to set true or flase to display;
///
///
if(display_confirmation_message == true) {
var retVal = confirm(msg);
} else {
var retVal = true; // DEFAULTED TO "true" and it works... no need to wait for user input.
}
//var retVal = true; // DEFAULTED TO "true" and it works... no need to wait for user input.
///
/// END ODDITY
console.log('show_device_confirm',4);
if( retVal == true ){
console.log('show_device_confirm',5);
//if(!empty(callback)){
//eval("callback();");
if (type == "ConfirmAccountVerification") {
console.log('show_device_confirm',6);
eval("showVerificationForm(account_hash);");
}
else if (type == "confirmSelectOption") {
console.log('show_device_confirm',7);
eval("confirmSelectOption('yes');");
}
else if(type == "confirmRemovePhoto"){
console.log('show_device_confirm',8);
removePhoto();
}
console.log('show_device_confirm',9);
//}
return true;
}
else{
console.log('show_device_confirm',10);
if (type == "confirmSelectOption") {
console.log('show_device_confirm',11);
eval("confirmSelectOption('no');");
}
console.log('show_device_confirm',12);
return false;
}
console.log('show_device_confirm',13);
}
console.log('show_device_confirm',14);
return false;
}
var searchHistory = [];
function goBack(){
var lastItem = searchHistory.pop();
lastItem = searchHistory.pop();
//alert(lastItem);
if(!empty(lastItem)){
showStepPage(lastItem);
}
else{
//alert("dd");
window.location.href = SITE_SCHEMA+'://finish';
}
}
var contactCategory = '';
function openContact(category){
contactCategory = category;
//window.location.href = SITE_SCHEMA+'://openContact';
if(contactCategory == 'tell_friends_form'){
openContactsCallLogsForm();
//$('.contactsUploadingStatus').html('');
}
window.location.href = SITE_SCHEMA+'://openContact/' + contactCategory;
return false;
}
function fillFormDataFromContact(email, name, phone){
if(!empty(phone)){
phone = phone.replace(/ /g, "");
phone = phone.replace(/-/g, "");
phone = phone.replace(/\+/g, "");
}
console.log('email, name, phone', email, name, phone);
switch(contactCategory){
case 'payment_form':
$('#cardholder_email_address').val(email);
$('#name_on_card').val(name);
$('#telephone_number').val(phone);
$('#cardholder_email_address').blur();
$('#name_on_card').blur();
$('#telephone_number').blur();
break;
case 'email_invoice':
$('#recipient_email_address').val(email);
$('#recipient_first_name').val(name);
$('#recipient_email_address').blur();
$('#recipient_first_name').blur();
break;
case 'official_identity':
$('#official_first_name').val(name);
$('#official_first_name').blur();
break;
case 'tell_friends_form':
break;
case 'XXXX':
break;
default:
break;
}
return false;
}
function contactUploadFinished(){
$('.contactsUploadingStatus').html('');
}
function tell_friends_cancel(){
window.location.href = SITE_SCHEMA+'://closeCalllogCursor';
return false;
}
function tell_friends_ok(){
window.location.href = SITE_SCHEMA+'://confirmInviteToPAYYAPNow?msg=' + escape(tell_a_friend_info_button);
return false;
}
function confirmInviteToPAYYAP(){
var len = $("#contacts_call_logs_form input[name='checked_contacts_index[]']:checked").length;
if(len<1){
show_device_alert('ERROR', "Please select at least one (1) associate to invite.");
return false;
}
$('#member_hash').val(member_hash);
$('#hash').val(account_hash);
$('#myModal .modal-footer').addClass('hideContactUploadModalButtons');
$('#myModal .modal-footer').parent().append('');
$.ajax({
type: "POST"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/payyap_member_referral.gate'
//,data: { member_hash: member_hash, hash: account_hash, contacts: $('#contacts_call_logs_form').serialize() }
,data: $('#contacts_call_logs_form').serialize()
//,dataType: 'json'
,success:function(data){
show_device_alert('SUCCESS', "InviteToPAYYAPNowSuccessMessage");
setTimeout(function(){
showAccountLists();
$('#checkUncheckAllContacts').prop('checked', true);
toggle(document.getElementById('checkUncheckAllContacts'));
closeContactsCallLogsForm();
}, 500);
}
,error:function(){
show_device_alert('ERROR', "An error occurred, please try again.");
}
,complete:function(){
$('#myModal .modal-footer').removeClass('hideContactUploadModalButtons');
$('#myModal .modal-footer').next().remove();
}
});
return false;
}
function fillContactsCallLogsForm(callDetails){
var windowWidth = window.outerWidth; //$(window).width();
var windowHeight = window.outerHeight; //$(window).height();
if($('body').height() < windowHeight){
$('body').css('height', windowHeight);
}
//$('#contacts_n_call_logs').css('height',viewport.height);
$('#contacts_n_call_logs').css('max-height', (windowHeight - 300));
$('#contacts_n_call_logs').css('overflow', 'auto');
callDetails = $.parseJSON(callDetails);
console.log('callDetails', callDetails);
var totalCallLogs = 0;
var totalContacts = 0;
var total = 0;
if(!empty(callDetails.callLogs.length)) totalCallLogs = callDetails.callLogs.length;
if(!empty(callDetails.contacts.length)) totalContacts = callDetails.contacts.length;
total = totalCallLogs+totalContacts;
console.log("total", total);
if(total>0){
var html = "";
html += '
Check/Uncheck All
';
html += '
Call Logs:
';
if(totalCallLogs<1) html += 'We cannot find any contacts in your call log.';
$.each(callDetails.callLogs, function(key, value) {
//console.log(key, value);
//for(k=0;k<20;k++){
html += '
';
html += '';
html += '';
html += '';
html += '';
html += '' + value.cachedName + '';
html += '' + value.phone + '';
html += '
';
//}
});
html += '
';
// html += '
Contacts:
';
// if(totalContacts<1) html += 'No contacts were found!';
// $.each(callDetails.contacts, function(key, value) {
// //console.log(key, value);
// var name = $.trim($.trim(value.firstname + ' ' + value.middlename) + value.lastname);
// html += '
';
// html += '';
// html += '' + value.name + '';
// html += '' + value.phone + '';
// html += '
`;
//$('#singlepage_queue').prepend(queue_item);
//prepare queue
var queue_hash = rand();
var singlepage_name = singlepage_first_name + ' ' + singlepage_last_name;
var selfieImage = $('#capturePhoto11').attr('src');
var singImage = $('#sign').attr('src');
var html = '
' + singlepage_name + '
';
if(!empty(selfieImage)){
html += '';
}
if(!empty(singImage)){
html += '';
}
$('#singlepage_queue').prepend('
'+html+'
');
//Scroll to top if cart icon is hidden on top
//$('html, body').animate({
// 'scrollTop' : $(".singlepage_queue").position().top
//});
//Select item image and pass to the function
var item = $("#singlepageForm");
flyToElement($(item), $('#singlepage_queue'));
//uploadQueueItem(queue_hash);
//}
//else{
//}
}, 500);
}, 500);
}
,error:function(){
setTimeout(function(){
hideProgressDialog();
show_device_alert('ERROR', 'An error occurred, please try again.');
}, 500);
}
,complete:function(){
//$(el).next().remove();
}
});
}, 500);
return false;
*/
}
/*!
* Function: flyToElement
* Author: CodexWorld
* Author URI: http://www.codexworld.com
* Author Email: contact@codexworld.com
* Description: This function is used for adding flying effect to the element.
*/
function flyToElement(flyer, flyingTo) {
var $func = $(this);
var divider = 3;
var flyerClone = $(flyer).clone();
$(flyerClone).css({position: 'absolute', top: $(flyer).offset().top + "px", left: $(flyer).offset().left + "px", opacity: 1, 'z-index': 1000});
$('body').append($(flyerClone));
var gotoX = $(flyingTo).offset().left + ($(flyingTo).width() / 2) - ($(flyer).width()/divider)/2;
var gotoY = $(flyingTo).offset().top + ($(flyingTo).height() / 2) - ($(flyer).height()/divider)/2;
$(flyerClone).animate({
opacity: 0.4,
left: gotoX,
top: gotoY,
width: $(flyer).width()/divider,
height: $(flyer).height()/divider
}, 700,
function () {
$(flyingTo).fadeOut('fast', function () {
$(flyingTo).fadeIn('fast', function () {
$(flyerClone).fadeOut('fast', function () {
$(flyerClone).remove();
$('.queue-item').eq(0).fadeIn('fast');
$('#singlepage_first_name').focus();
});
});
});
});
}
function addImageInFormData(imageName, imageData, formData){
var type = 'image/jpeg';
if(!empty(imageData)){
var base64ImageContent = imageData.replace(/^data:(image|application)\/(png|jpg|pdf);base64,/, "");
var binary = atob(imageData.split(',')[1]);
var array = [];
for (var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
}
var file = new Blob([new Uint8Array(array)], {type: type});
formData.append(imageName, file);
}
return formData;
}
function uploadQueueItem(queue_hash){
var url = siteProtocol + '//'+API_DOMAIN+'/link_gateway/KYC_Wizard.gate';
var singlepage_first_name = $('#singlepage_first_name').val();
var singlepage_last_name = $('#singlepage_last_name').val();
var singlepage_email_address = $('#singlepage_email_address').val();
var singlepage_country_code = $('#singlepage_country_code').val();
var singlepage_mobile_number = $('#singlepage_mobile_number').val();
var singlepage_selfie_url = '';
var singlepage_signature_url = '';
var selfieImage = $('#capturePhoto11').attr('src');
var singImage = $('#sign').attr('src');
var formData = new FormData();
formData.append("whitelabel_business_account_hash", whitelabel_business_account_hash);
formData.append("singlepage_first_name", singlepage_first_name);
formData.append("singlepage_last_name", singlepage_last_name);
formData.append("singlepage_email_address", singlepage_email_address);
formData.append("singlepage_country_code", singlepage_country_code);
formData.append("singlepage_mobile_number", singlepage_mobile_number);
formData = addImageInFormData('selfieImage', selfieImage, formData);
formData = addImageInFormData('singImage', singImage, formData);
formData.append("device", "desktop");
formData.append("action", "singlepage_form");
formData.append("extension", 'png');
$.ajax({
url: url,
type: "POST",
cache: false,
contentType: false,
processData: false,
data: formData,
dataType: 'json',
xhr: function(){
//upload Progress
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function(event) {
var percent = 0;
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
console.log('percent = ', percent);
//update progressbar
$('.queue-item[data-queue-hash="' + queue_hash + '"]').find(".progress-bar").html(percent +"%").css("width", + percent +"%");
}, true);
}
return xhr;
},
mimeType:"multipart/form-data"
})
.done(function(data){
//alert('done!');
console.log('queue_hash', queue_hash, data);
$('.queue-item[data-queue-hash="' + queue_hash + '"]').find(".progress-bar").html(data.msg);
console.log($('.queue-item[data-queue-hash="' + queue_hash + '"]'));
//$('.queue-item[data-queue-hash="' + queue_hash + '"]').find(".progress").remove();
//uploadFinished(data)
});
}
function sendGettingMerchantIDInstruction(el){
$(el).parent().append('');
$.ajax({
type: "POST"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/PAYYAP_send_merchant_account_instructions.gate'
,data: { member_hash: member_hash, business_account_hash: selected_account_hash, TSYS_merchant_account_id: '' }
//,dataType: 'json'
,success:function(data){
show_device_alert('SUCCESS', data);
goToTopOfPage();
$('#TSYS_merchant_account_id').focus();
}
,error:function(){
show_device_alert('ERROR', "An error occurred, please try again.");
}
,complete:function(){
$(el).next().remove();
}
});
return false;
}
function playDemoVideo(){
if(empty(YOUTUBE_Services_Video_ID)) return false;
else if($('#youtubeImage').attr('src') == 'loading.gif') return false;
window.location.href = SITE_SCHEMA+'://openLink/youtube?vid=' + YOUTUBE_Services_Video_ID;
return false;
}
function youtubeDemoVideoLoaded(){
$('#youtubeImage').attr('src', 'youtube-512.png');
}
function checkBusinessWebsiteIsNotEmpty(el){
if(document.configureAccount3Form['is_advertise_website'].checked){
if(empty($('#tsys_us_direct_business_website').val())){
show_device_alert('ERROR', "To qualify for free advertising, and a listing on the PAYYAP.network Business Directory, you must please set your business webpage / URL.");
document.configureAccount3Form['is_advertise_website'].checked = false;
//return false;
}
}
}
function confirmTermsPolicies(el){
if($(el).is(':checked')){
var key = $(el).attr('id');
var selected_account_details = getSelectAccountDetails();
show_device_alert('ALERT!', selected_account_details[key]);
}
}
function validateSocialSecurityNumber(id, validate_tax_id_country_iso3, callback){
//'#tsys_us_direct_social_security_number'
//$(id).val()
var ssn = $(id).val();
var tax_id_country_iso3 = $(validate_tax_id_country_iso3).val();
if(empty(ssn)){
if(!empty(callback)) callback();
return false;
}
else if($(id).attr('data-validation-status') == 'valid'){
if(!empty(callback)) callback();
return false;
}
else if($(id).attr('data-validation-status') == 'invalid'){
if(!empty(callback)) callback();
return false;
}
showProgressDialog('Checking ' + $(id).attr('placeholder')) + '...';
setTimeout(function(){
var url = siteProtocol + '//'+API_DOMAIN+'/link_gateway/social_security_checker.gate';
$.ajax({
type: "GET"
,url: url
,data: {tsys_us_direct_social_security_number: ssn, tax_country_iso3: tax_id_country_iso3}
,dataType: 'json'
,success:function(data){
hideProgressDialog();
setTimeout(function(){
//console.log(data);
if(data.status == 'VALID'){
//$(id).val(data.ssn);
//$('#btnActivateUSDirectAccount').removeAttr('disabled');
$(id).attr('data-validation-status', 'valid');
if(!empty(callback)) callback();
}
else{
showErrorImg($(id));
$(id).attr('data-validation-status', 'invalid');
//$('#btnActivateUSDirectAccount').attr('disabled', 'disabled');
show_device_alert('ERROR', 'INVALID ' + $(id).attr('placeholder') );
$(id).focus();
}
}, 500);
}
,error:function(){
hideProgressDialog();
setTimeout(function(){
show_device_alert('ERROR', globalErrorMessage + API_DOMAIN);
}, 500);
}
,complete:function(){
//hideProgressDialog();
}
});
}, 1000);
}
function actionBarItem(action){
window.location.href = SITE_SCHEMA+'://actionBarItem?action=' + action;
return false;
}
function openActionBarMenu(){
$('.dropdown').addClass('open'); // Opens the dropdown
}
function getTermsAndConditionsAggreementText(){
var key = 'step_4_of_4_proof_of_identity_introduction_text';
var selected_account_details = getSelectAccountDetails();
if(!empty(selected_account_details) && !empty(selected_account_details[key])){
$('#step_4_of_4_proof_of_identity_introduction_text').html(selected_account_details[key]);
}
key = 'final_confirmation_notes_prior_to_signature_and_submission';
if(!empty(selected_account_details) && !empty(selected_account_details[key])){
$('#final_confirmation_notes_prior_to_signature_and_submission').html(selected_account_details[key]);
}
//if(empty($('#tsys_service_agreement').html())){
/*
$('#tsys_service_agreement').html('');
$.ajax({
type: "GET"
,url:siteProtocol + '//'+API_DOMAIN+'/link_gateway/PROPAY_terms_of_service.gate?link_from_payyap=yes'
,data: {}
//,dataType: 'json'
,success:function(data){
$('#tsys_service_agreement').html(data);
}
,error:function(){
}
,complete:function(){
}
});
*/
if(kyc_session['onboarding_preferences'] == null) kyc_session['onboarding_preferences'] = "";
if(
(!empty(kyc_session['onboarding_preferences']))
) {
var terms_link = '';
if(!empty(kyc_session['onboarding_preferences']['onboarding_terms_of_service_url'])){
terms_link = 'Terms of Service';
if(form_flow == 'single_page'){
terms_link = 'Click here to see Terms of Service';
}
}
else if(!empty(kyc_session['onboarding_preferences']['onboarding_terms_of_service_text'])){
terms_link = '';
if(form_flow == 'single_page'){
terms_link = '