php - Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' payleap -


i have taken following code payleap checkout site

following code

    function payleap_send($packet, $url) {  $header = array("mime-version: 1.0","content-type: application/x-www-form-urlencoded","contenttransfer-encoding: text");  $ch = curl_init();  // set url , other appropriate options  curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_verbose, 1);  curl_setopt ($ch, curlopt_proxytype, curlproxy_http);  // uncomment host proxy server // curl_setopt ($ch, curlopt_proxy, "http://proxyaddress:port");  curl_setopt($ch, curlopt_httpheader, $header);  curl_setopt($ch, curlopt_ssl_verifypeer, false);  curl_setopt($ch, curlopt_post, true);  curl_setopt($ch, curlopt_postfields, $packet);  curl_setopt($ch, curlopt_returntransfer, true);  curl_setopt ($ch, curlopt_timeout, 10);   // send packet , receive response $response = curl_exec($ch);  curl_close($ch);  return($response); }  function simple_xml_find($haystack, $needle) { // supplying valid closing xml tag in $needle, return data contained element // element in question must leaf, , not contain other elements (this *simple*_xml_find =)  if(($end = strpos($haystack, $needle)) === false)     return("");  for($x = $end; $x > 0; $x--)     {     if($haystack{$x} == ">")         return(trim(substr($haystack, $x + 1, $end - $x - 1)));     } return (""); }   if(getenv("request_method") == "post")     {     // build http request     $args  = "username=" . htmlspecialchars($_post['txtusername']);     $args .= "&password=" . htmlspecialchars($_post['txtpassword']);     $args .= "&vendor=" . htmlspecialchars($_post['txtvendor']);     $args .= "&customerid=" . htmlspecialchars($_post['txtcustomerid']);     $args .= "&customername=" . htmlspecialchars($_post['txtcustomername']);     $args .= "&firstname=" . htmlspecialchars($_post['txtfirstname']);     $args .= "&lastname=" . htmlspecialchars($_post['txtlastname']);     $args .= "&title=" . htmlspecialchars($_post['txttitle']);     $args .= "&department=" . htmlspecialchars($_post['txtdepartment']);     $args .= "&street1=" . htmlspecialchars($_post['txtstreet1']);     $args .= "&street2=" . htmlspecialchars($_post['txtstreet2']);     $args .= "&street3=" . htmlspecialchars($_post['txtstreet3']);     $args .= "&city=" . htmlspecialchars($_post['txtcity']);     $args .= "&stateid=" . htmlspecialchars($_post['txtstateid']);     $args .= "&province=" . htmlspecialchars($_post['txtprovince']);     $args .= "&zip=" . htmlspecialchars($_post['txtzip']);     $args .= "&countryid=" . htmlspecialchars($_post['txtcountryid']);     $args .= "&phone=" . htmlspecialchars($_post['txtphone']);     $args .= "&email=" . htmlspecialchars($_post['txtemail']);     $args .= "&dayphone=" . htmlspecialchars($_post['txtdayphone']);     $args .= "&nightphone=" . htmlspecialchars($_post['txtnightphone']);     $args .= "&fax=" . htmlspecialchars($_post['txtfax']);     $args .= "&mobile=" . htmlspecialchars($_post['txtmobile']);     $args .= "&contractid=" . htmlspecialchars($_post['txtcontractid']);     $args .= "&contractname=" . htmlspecialchars($_post['txtcontractname']);     $args .= "&billamt=" . htmlspecialchars($_post['txtbillamt']);     $args .= "&taxamt=" . htmlspecialchars($_post['txttaxamt']);     $args .= "&totalamt=" . htmlspecialchars($_post['txttotalamt']);     $args .= "&maxfailures=" . htmlspecialchars($_post['txtmaxfailures']);     $args .= "&failureinterval=" . htmlspecialchars($_post['txtfailureinterval']);     $args .= "&emailcustomer=" . htmlspecialchars($_post['txtemailcustomer']);     $args .= "&emailmerchant=" . htmlspecialchars($_post['txtemailmerchant']);     $args .= "&emailcustomerfailure=" . htmlspecialchars($_post['txtemailcustomerfailure']);     $args .= "&emailmerchantfailure=" . htmlspecialchars($_post['txtemailmerchantfailure']);     $args .= "&ccaccountnum=" . htmlspecialchars($_post['txtccaccountnum']);     $args .= "&ccexpdate=" . htmlspecialchars($_post['txtccexpdate']);     $args .= "&ccnameoncard=" . htmlspecialchars($_post['txtccnameoncard']);     $args .= "&ccstreet=" . htmlspecialchars($_post['txtccstreet']);     $args .= "&cczip=" . htmlspecialchars($_post['txtcczip']);     $args .= "&startdate=" . htmlspecialchars($_post['txtstartdate']);     $args .= "&enddate=" . htmlspecialchars($_post['txtenddate']);     $args .= "&billingperiod=" . htmlspecialchars($_post['txtbillingperiod']);     $args .= "&billinginterval=" . htmlspecialchars($_post['txtbillinginterval']);     $args .= "&extdata=<trainingmode>t</trainingmode>";      // place against payleap payment gateway     $result = payleap_send($args, "https://uat.payleap.com/merchantservices.svc/addrecurringcreditcard");     $xmldata = new simplexmlelement(stripslashes($result));     } 

i getting error fatal error: uncaught exception 'exception' message 'string not parsed xml' on line $xmldata = new simplexmlelement(stripslashes($result));

the response of curl follows

<recurringresult xmlns="http://www.payleap.com/payments" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <ccinfokey>11111</ccinfokey> <code>ok</code> <contractkey>22222</contractkey> <customerkey>33333</customerkey> <error>recurringcreditcard added</error> <username>api_id001111</username> <vendor>3333</vendor> </recurringresult>  

do 1 have nay idea this?

i'm not sure please try headers instead of current headers.

curl_setopt($ch, curlopt_httpheader, array( 'content-type: text/xml' ));


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -