Reply
Highlighted
Member
Posts: 4
Registered: ‎09-05-2011

CIM - php SDK for getHostedProfilePageRequest for hosted CIM

[ Edited ]

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.

 

 

Highlighted
All Star
Posts: 1,072
Registered: ‎08-17-2009

Re: CIM - php SDK for getHostedProfilePageRequest for hosted CIM

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

Highlighted
Member
Posts: 1
Registered: ‎10-31-2012

Re: CIM - php SDK for getHostedProfilePageRequest for hosted CIM

Hi Michelle,

 

Is this build into the PHP CIM SDK now?