• Dave Alvaro
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Hi
I have an visualforce page which calls custom controller.A method getIFrameSrc gets the ifRame URL.That URL i have to pass it to visualforce page <apex:iframe>.I am able to pass it.But i am getting a blank page.
VF Page Code
<apex:page sidebar="false"  controller="CXiIntercept3">
<!--action="{!getIFrameSrc}">-->
<!--showHeader="false"-->
<!--<apex:stylesheet value="{!URLFOR($Resource.paymetricsCSS, 'paymetricsCSS.css')}"/>-->
  <apex:form >
  <!--<apex:actionFunction name="getIFrameSrc" action="{!getIFrameSrc}" rerender="out" status="myStatus"/>-->
  <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="cache-control" content="no-cache, no-store, max-age=0, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <title>XiIntercept v3 - Implementation Demo</title>
    <script type="text/javascript">
<form id="form1">
   
        <div>
            <p>This sample shows the basic functionality of implementing the iframe solution.</p>
            <!--<iframe id="IFrame" name="dieCommFrame" frameBorder="0" src="http://www.w3schools.com"></iframe>-->
            <apex:iframe id="dieCommFrame" frameborder="0" src="{!getIFrameSrc}"/>
             <!--<apex:commandButton value="Load" action="{!getIFrameSrc}"/>-->
              <!--<apex:commandLink action="{!getIFrameSrc}" value="Load" id="theCommandLink"/>-->
            <!--<apex:param name="strSrcURL"
                value="{!getIFrameSrc}"
                assignTo="{!getIFrameSrc}"/>-->
        <!--</apex:commandButton>-->
                    </div>
        <div>
            <p />
            <table>
                <thead>
                    <tr>
                        <th colspan="2">Billing Address</th>
                    </tr>               
                </thead>
                <tbody>
                    <tr>
                        <td class="Column1">Name</td>
                        <td class="Column2">
                        <input id="Text1" type="text" value="John Doe" size="32" /></td>
                        <!--<apex:InputField label="Name" id="Text1" value="John Doe"/>-->
                    </tr>
                    <tr>
                        <td class="Column1">Address</td>
                        <td class="Column2"><input id="Text2" type="text" value="19500 State Hwy 249" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">City</td>
                        <td class="Column2"><input id="Text3" type="text" value="Houston" size="32" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">State</td>
                        <td class="Column2"><input id="Text4" type="text" value="Texas" size="16" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">Zip Code</td>
                        <td class="Column2"><input id="Text5" type="text" value="77070" size="8" /></td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="Column1">&nbsp;</td>
                        <td class="Column2">
                              <!--<apex:commandButton id="cmdPayment" action="{!submitForm}" value="Tokenize Data"/>-->
                         <input id="cmdPayment" type="button" onclick="submitForm(); return false;" value="Tokenize Data" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
       </body>
       </apex:form>
    </apex:page>
Apex Class Code is given below
public with sharing class CXiIntercept3
{

   /*public CXiIntercept3(ApexPages.StandardController controller) {
       m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
    }*/


    public String getIFrameSrc { get;
    set
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
        getIFrameSrc = strSrcURL;
        System.debug('getIFrameSRc is'+getIFrameSrc);
        //return strSrcURL;
     }
    }
    public PageReference submitForm() {
        /*pageReference acctPage = new PageReference('https://cynosure--slqa--c.cs19.visual.force.com/apex/Paymetrics_Page');
    acctPage.setRedirect(true);*/
        return null ;    }

    public String m_strURL;
    public String m_strGUID;
    public String m_strPSK;
       
    public CXiIntercept3()
    {
        m_strURL = 'https://qaapp02.xisecurenet.com/diecomm';
        m_strGUID = '8842aa98-d6d1-40a4-9ee0-c02a3393b7af' ;
        m_strPSK = '4Kb/=5ZkrX{7_3HcTt8+!Md6C2$e9}aJ' ;
        getIFrameSrc();
      }

    public String getIFrameSrc()
    {
        System.debug('Inside IFrameSrc');
        String strWhere = 'getIFrameSrc';
        //alert('getIFrameSrc');
        System.debug('strWhere is'+strWhere);
        String strAccessToken = getIFrameAccessToken();
       
        String strSrcURL = m_strURL + '/view/iframe/' + m_strGUID + '/' + strAccessToken + '/true';
       
        Log(strWhere, 'IFrameSrc', strSrcURL);
        System.debug('iFrame URL is'+strSrcURL);
       
        return strSrcURL;
    }
   
    public String getIFrameAccessToken()
    {
        String strAT = '';
        String strResponse = '';
        String strURL = m_strURL + '/AccessToken';
        String strWhere = 'getSignedXML';
        StaticResource static_resource = [Select Body From StaticResource Where Name = 'Paymetrics_CSS'];
        String strXml = static_resource.body.toString();
        System.debug('strxml is'+strxml);
        //String strXml = '';
        //String strXml = getIFrameMerchantHTML();
        String strSignature = '';
       
        Dom.Document hDoc = null;
        Dom.XmlNode hRoot = null;
        Dom.XmlNode hResponse = null;
        Dom.XmlNode hAT = null;
        System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        String strPostXml = 'MerchantGuid=' + m_strGUID + '&' +
                    'SessionRequestType=1&' +
                    'Packet=' + EncodingUtil.urlEncode(strXml, 'UTF-8') + '&' +
                    'Signature=' + EncodingUtil.urlEncode(getDigitalSignature(strXml), 'UTF-8') + '&' +
                    'MerchantDevelopmentEnvironment=SalesForce';
        System.debug('strPostxml is ' +strPostXml);
        //System.debug('packet ' + EncodingUtil.urlEncode(strXml, 'UTF-8'));
        //Log(strWhere, 'strXml', strXml);
        //Log(strWhere, 'strPostXml', strPostXml);
        //Log(strWhere, 'strSignature', strSignature);
       
        hDoc = executeHttpRequest(strURL, strPostXml, 'POST');
        hRoot = hDoc.getRootElement();
        if(hRoot != null)
        {
            hResponse = hRoot.getChildElement('ResponsePacket', null);
            if(hResponse != null)
            {
                hAT = hResponse.getChildElement('AccessToken', null);
                if(hAT != null)
                    strAT = hAT.getText();
            }
        }
        Log(strWhere, 'AccessToken', strAT);
        System.debug('Access Token is'+strAT);
       
        return strAT;
    }
   
    public String getXmlRequest()
    {
        String strWhere = 'getXmlRequest';
        //String strRedirect = getRequestUrl();
        String strRedirect = '';
        String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
       

        //strRedirect = strRedirect.replace('XiIntercept3RQ', 'XiIntercept3RS');
        xmlRequest += '<PostPacketModel><RedirectUri>' + strRedirect + '</RedirectUri></PostPacketModel>';
       
        Log(strWhere, 'strRedirect', strRedirect);
        Log(strWhere, 'xmlRequest', xmlRequest);
       
        return xmlRequest;
    }
   
    /*public String getIFrameMerchantHTML()
    {
        /* code snippet to retrieve merchant xml into string */
        /*
            String strURL = '' + Site.getBaseUrl();
       
            if(strURL.length() == 0)
            {
                strURL = URL.getCurrentRequestUrl().toExternalForm().replace('XiIntercept3RQ', 'XiIntercept3RS');
            }
            else strURL += '/XiIntercept3RS';
           
           
           
            String xmlRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
        */
   // }
   
    private void Log(String strWhere, String strName, String strValue)
    {
        System.debug(strWhere + '() - ' + strName + ' => ' + strValue);
    }

    private String getDigitalSignature(String strData)
    {
        String strWhere = 'getDigitalSignature';
        String strSignature = '';
       
        strSignature = EncodingUtil.base64Encode(Crypto.generateMac('hmacSHA256', Blob.valueOf(strData), Blob.valueOf(m_strPSK)));
        System.debug('strsignature is'+strsignature);
        Log(strWhere, 'strData', strData);
        Log(strWhere, 'strSignature', strSignature);
       
        return strSignature;
    }

    private Dom.Document getResponsePacket(String strAccessToken)
    {
        String strWhere = 'getResponsePacket';
        String strSignature = getDigitalSignature(strAccessToken);
        String strUrlParams = m_strURL + '/ResponsePacket';
        Dom.Document hDoc = null;
       
        strUrlParams += '?MerchantGUID=' + m_strGUID;
        strUrlParams += '&Signature=' + EncodingUtil.urlEncode(strSignature, 'UTF-8');
        strUrlParams += '&AccessToken=' + strAccessToken;
       
        Log(strWhere, 'strUrlParams', strUrlParams);
        hDoc = executeHttpRequest(strUrlParams, '', 'GET');
        Log(strWhere, 'hDoc.toXmlString()', hDoc.toXmlString());
       
        return hDoc;
    }
   
    private Dom.Document executeHttpRequest(String targetURL, String urlParameters, String requestType)
    {
        String strWhere = 'executeHttpRequest';
        Dom.Document hDoc = null;
        Http myHttp = new Http();
        HttpRequest httpRQ = new HttpRequest();
        HttpResponse httpRS = null;
       
        Log(strWhere, 'targetURL', targetURL);
        Log(strWhere, 'requestType', requestType);
        Log(strWhere, 'urlParameters', urlParameters);
       
        httpRQ.setEndpoint(targetURL);
        httpRQ.setMethod(requestType);
        if(requestType.equalsIgnoreCase('POST'))
        {
            httpRQ.setHeader('Content-Type', 'application/x-www-form-urlencoded');
            httpRQ.setHeader('Content-Length', String.valueOf(urlParameters.Length()));
            httpRQ.setHeader('Content-Language', 'en-US');
            httpRQ.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
            httpRQ.setHeader('Pragma', 'no-cache');
            httpRQ.setBody(urlParameters);
        }
       
        httpRS = myHttp.send(httpRQ);
        if(httpRS != null)
        {
            Log(strWhere, 'httpRS.getBody()', httpRS.getBody());
            hDoc = httpRS.getBodyDocument();
        }
        else
        {
            hDoc = new Dom.Document();
        }
       
        return hDoc;
    }
}
Any suggestions are welcome..
Thanks
Sricharan
 
Hello everyone,
I have a question in an area where I am stuck after creating a new stand-alone Lightning app. I do not want to run the Lightning app on the Salesforce1 platform but want to run it on a desktop platform from within the Salesforce org. What process does one have to go through to set up a stand alone Lightning App to be launched from within the Salesforce org? Is there a way to link Salesforce tabs to the Lightning App that will launch the app when they are clicked like you can with Visualforce pages or to add the Lightning App in the Apps menu? I am not able to find any documentation or how to use desktop Lightning Apps from within Salesforce or if that is possible at this time.