/** * Created by lsubramaniam on 6/14/18. */ function postToHostedPage(msg){ if (globalStoreData.isZuoraUp) { postToIframe(msg); } else { postToOfflinePage(msg); } } function postToIframe(msgToIframe){ // pass the URL of the current parent page to the iframe using location.hash var hosted_iframe_id = 'z_hppm_iframe'; var src = document.getElementById(hosted_iframe_id).src + '#' + encodeURIComponent(document.location.href); document.getElementById(hosted_iframe_id).src = src; ZXD.postMessage(msgToIframe, src, document.getElementById(hosted_iframe_id).contentWindow); } function postToOfflinePage(msg){ msg = msg.split("setField(")[1]; msg = msg.split(")")[0]; var array = new Array(); array = msg.split(":"); switch (array[0]) { case "creditCardHolderName": $('#input-creditCardHolderName').val(array[1]); break; case "creditCardCountry": $('#input-creditCardCountry').val(array[1]).change(); break; case "creditCardState": var creditCardCountry = $('#input-creditCardCountry').val(); var creditCardState = ""; if (!this.globalStoreData.isZuoraUp) { if ('USA' === creditCardCountry) { $('#input-usCreditCardState').val(array[1]).change(); } else if ('CAN' === creditCardCountry) { $('#input-canCreditCardState').val(array[1]).change(); } else { $('#input-creditCardState').val(array[1]).change(); } } break; case "creditCardAddress1": $('#input-creditCardAddress1').val(array[1]); break; case "creditCardCity": $('#input-creditCardCity').val(array[1]); break; case "creditCardPostalCode": $('#input-creditCardPostalCode').val(array[1]); } }