cancel
Showing results for 
Search instead for 
Did you mean: 

CIM - php SDK for getHostedProfilePageRequest for hosted CIM

It drove me nuts looking for it.. unless I just didn't have the latest SDK (which would be horrible) so here's the code I had to write:

 

 

 

it goes in AuthorizeNewCIM.php:

 

 

        public function getHostedProfilePageRequest($customerProfileId,$setting=0)
    {
        $this->_constructXml("getHostedProfilePageRequest");
        $this->_xml->addChild("customerProfileId", $customerProfileId);
  
        if(!empty($setting)) {
			 $set_settings_global=$this->_xml->addChild("hostedProfileSettings");
			foreach($setting as $key=>$val){
				$set_settings=$set_settings_global->addChild("setting");
				$set_settings->addChild("settingName",$key);
				$set_settings->addChild("settingValue",$val);
				}//end each setting
			}//end has a setting
		/*hostedProfileReturnUrl,
		hostedProfileReturnUrlText,
		hostedProfileHeadingBgColor,
		hostedProfilePageBorderVisible,
		hostedProfileIFrameCommunicatorUrl*/

        return $this->_sendRequest();
    }

And you call it like so:

$request = new AuthorizeNetCIM;
	$settings=array('hostedProfileIFrameCommunicatorUrl'=>'http://domain.com/contentx/IframeCommunicator.html');

	$response = $request->getHostedProfilePageRequest($profileID,$settings);
	$token=trim($response->xml->token);

 

 

 

And then find the rest of the code in the file with the samples. You don't need to put the DIV exactly before the </body>, but if you don't pass the iframecommunicator.html URL, it won't close the popup.

 

 

edit: woops, I'm not sure it will correctly pass an array of values. I only needed and tested the one.

 

 

avimarcus
Member
2 REPLIES 2

Hey avimarcus,

 

Thanks for posting this. We are currently working on getting the hosted CIM feature built into the SDKs, so thanks for posting your code for those working on it in the meantime.

 

Thanks,

 

Michelle

Developer Community Manager

Michelle
All Star

Hi Michelle,

 

Is this build into the PHP CIM SDK now?