cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is PHP/Curl not working on CIM updates?

Is PHP/Curl not working on CIM updates?
This program was working and it just stopped about a week or two ago. - we don't use it very often.


Also, I have my sandbox setup and am not seeing an update into CIM - same as the live system - from the PHP/Curl program that was working.  
How do I trace the attempt?
I've debugged the program to see that all required fields are correct, and I'm not getting an error code - it's just not updating.
Does anyone here actually help out on code?  Maybe something has been deprecated.

dcassara
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

If it blacklisted, http://developer.authorize.net/support/ , email them or call supported.

 

On the server that did NOT work, can you open a web browser and put the https://api.authorize.net/xml/v1/request.api in the address and see if you getting anything? should be the something like

<ErrorResponse><messages><resultCode>Error</resultCode><message><code>E00002</code><text>The content-type specified is not supported.</text></message></messages></ErrorResponse>

 

The other unknown protocol was mostly about SSL protocol like

http://www.theunixcode.com/2013/09/ssl23_get_server_hellounknown-protocol-how-do-i-fix-my-ssl-cert/

 

View solution in original post

23 REPLIES 23

can you post the xml that your are trying to update a customer/payment profile

RaynorC1emen7
Expert

and xxxxx out sensitive info.

there also php sample code http://developer.authorize.net/downloads/samplecode/

This is strange - I had an echo in that was showing the XML - now I'm getting no response at all - blank screen.
I'll figure this out and then post it.

I'm getting 

Notice: Undefined property: AuthNetCim::$resultsCode

on echo $cim - that's probably why it's not working, right?
I'm missing something.

 

OK - echo $cim still gets an error, so I displayed all the fields the previous programmer was passing.
(not showing the account and transactions ids - they are correct):

paymentType-creditcard
cardNumber-4111111111111111
expirationDate-2017-04
billTo_firstName-D
billTo_lastName-Cass
billTo_address-23 Trail Dr.
billTo_state-MO
billTo_zip-63367
billTo_country-US
shipto_firstName-D
shipto_lastName-Cass
shipTo_address-23 Trail Dr.
shipTo_city-Lake St. Louis
shipTo_state-MO
shipTo_zip-63367
shipTo_country-US
description-Cass, D

email-x@csiportal.com
customerType-individual

Is there anything else required?

and here's the PHP code.
Now, I didn't write this but have to have this functional asap - a lot of pressure.  I'm reading everything I can find, but if you can help, I'd really appreciate it.

Remember - it's for CIM - I'm trying to get the ProfileID then next, get the PaymentProfileID.

<?php

$api_login_id='999999999999';
$api_transaction_key='999999999999999';
$serverName = "CASS\SQLEXPRESS";
$connectionInfo = array( "Database"=>"XXXX", "UID"=>"xxxxxxx", "PWD"=>"xxxxx");
$params = array();

 


if (isset($_POST["txtcustomerID"]))
{

if (isset($_POST["txtcustomerProfileID"]))
{
if ($_POST["txtcustomerProfileID"]=="0")
{
$ccexp=$_POST["cc_expiryyy"]."-".$_POST["cc_expirymm"];
$fname=$_POST["btfname"];
$lname=$_POST["btlname"];

create_update_customer_profile($_POST["cc_num"],$ccexp,$fname,$lname,$_POST["btaddr"],$_POST["btcity"],$_POST["btstate"],
$_POST["btzip"],$_POST["btemail"],'100.00',$_POST["txtcustomerID"],"","");
}
else
{
$ccexp=$_POST["cc_expiryyy"]."-".$_POST["cc_expirymm"];
//$cname = split(" ", $_POST["btname"]);
$fname=$_POST["btfname"];
$lname=$_POST["btlname"];
create_update_customer_profile($_POST["cc_num"],$ccexp,$fname,$lname,$_POST["btaddr"],$_POST["btcity"],$_POST["btstate"],
$_POST["btzip"],$_POST["btemail"],'100.00',$_POST["txtcustomerID"],$_POST["txtcustomerProfileID"],$_POST["txtcustomerPaymentProfileID"]);

}

}

}

/////////////////////////FUNCTIONS FOR CIM//////////////////////////


function create_update_customer_profile($cardNumber,$expirationDate,$billTo_firstName,$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,$billTo_zip,
$email,$add_amount,$custid,$custPrID,$custPayPrID)
{
require('include/authorizenet.cim.class.php');
global $api_login_id,$api_transaction_key;
// createCustomerProfileRequest()
$cim = new AuthNetCim($api_login_id, $api_transaction_key, true); // Need to change here mohit
$shipTo_firstName=$billTo_firstName;
$shipTo_lastName=$billTo_lastName;
$shipTo_address=$billTo_address;
$shipTo_city=$billTo_city;
$shipTo_state=$billTo_state;
$shipTo_zip=$billTo_zip;

// Choose a payment type - (creditCard or bankAccount) REQUIRED

//global $cardNumber,$expirationDate,$billTo_firstName,$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,$billTo_zip,$shipTo_firstName,$shipTo_lastName,
$shipTo_address,$shipTo_city,$shipTo_state,$shipTo_zip,$email;


$cim->setParameter('paymentType', 'creditCard');
$cim->setParameter('cardNumber', $cardNumber);
$cim->setParameter('expirationDate', $expirationDate); // (YYYY-MM)

echo "<BR>paymentType-creditcard<BR>cardNumber-".$cardNumber."<BR>expirationDate-".$expirationDate."<BR><BR>";

// Some Billing address information is required and some is optional
// depending on your Address Verification Service (AVS) settings
$cim->setParameter('billTo_firstName', $billTo_firstName); // Up to 50 characters (no symbols)
$cim->setParameter('billTo_lastName', $billTo_lastName); // Up to 50 characters (no symbols)
//$cim->setParameter('billTo_company', 'Acme, Inc.'); // Up to 50 characters (no symbols) (optional)
$cim->setParameter('billTo_address', $billTo_address); // Up to 60 characters (no symbols)
$cim->setParameter('billTo_city', $billTo_city); // Up to 40 characters (no symbols)
$cim->setParameter('billTo_state', $billTo_state); // A valid two-character state code (US only) (optional)
$cim->setParameter('billTo_zip', $billTo_zip); // Up to 20 characters (no symbols)
$cim->setParameter('billTo_country', 'US'); // Up to 60 characters (no symbols) (optional)

echo "<BR>billTo_firstName-".$billTo_firstName."<BR>billTo_lastName-".$billTo_lastName."<BR>billTo_address-".$billTo_address."<BR>";
echo "<BR>billTo_state-".$billTo_state."<BR>billTo_zip-".$billTo_zip."<BR>billTo_country-US<BR><BR>";

//$cim->setParameter('billTo_phoneNumber', '555-555-5555'); // Up to 25 digits (no letters) (optional)
//$cim->setParameter('billTo_faxNumber', '444-444-4444'); // Up to 25 digits (no letters) (optional)

// In this method, shipping information is required because it reduces an extra
// step from having to create a shipping address in the future, therefore you can simply update it when needed.
// You can populate it with the billing info if you don't have an order form with shipping details.
$cim->setParameter('shipTo_firstName', $shipTo_firstName); // Up to 50 characters (no symbols)
$cim->setParameter('shipTo_lastName', $shipTo_lastName); // Up to 50 characters (no symbols)
//$cim->setParameter('shipTo_company', 'Acme, Inc.'); // Up to 50 characters (no symbols) (optional)
$cim->setParameter('shipTo_address', $shipTo_address); // Up to 60 characters (no symbols)
$cim->setParameter('shipTo_city', $shipTo_city); // Up to 40 characters (no symbols)
$cim->setParameter('shipTo_state', $shipTo_state); // A valid two-character state code (US only) (optional)
$cim->setParameter('shipTo_zip', $shipTo_zip); // Up to 20 characters (no symbols)
$cim->setParameter('shipTo_country', 'US'); // Up to 60 characters (no symbols) (optional)

echo "shipto_firstName-".$shipTo_firstName."<BR>shipto_lastName-".$shipTo_lastName."<BR>shipTo_address-".$shipTo_address."<BR>shipTo_city-".
$shipTo_city."<BR>shipTo_state-".$shipTo_state."<BR>shipTo_zip-".$shipTo_zip."<BR>shipTo_country-US<BR><BR>";

//$cim->setParameter('shipTo_phoneNumber', '555-555-5555'); // Up to 25 digits (no letters) (optional)
//$cim->setParameter('shipTo_faxNumber', '444-444-4444'); // Up to 25 digits (no letters) (optional)

// Merchant-assigned reference ID for the request
//$cim->setParameter('refId', 'my unique ref id'); // Up to 20 characters (optional)

// merchantCustomerId must be unique across all profiles
//$cim->setParameter('merchantCustomerId', 'my unique custid2'); // Up to 20 characters (optional)

// description must be unique across all profiles, if defined
$cim->setParameter('description', $billTo_lastName.', '.$billTo_firstName); // Up to 255 characters (optional)

echo "description-".$billTo_lastName.', '.$billTo_firstName."<BR><BR>";

// A receipt from authorize.net will be sent to the email address defined here

$cim->setParameter('email', $email); // Up to 255 characters (optional)
$cim->setParameter('customerType', 'individual'); // individual or business (optional)

echo "email-".$email."<BR>customerType-individual<BR><BR>";

if ($custPrID=="")
{
$cim->createCustomerProfileRequest();
$cust_profile_id="";


if ($cim->isSuccessful())
{
$cust_profile_id = $cim->customerProfileId;
echo "<table align=center><TR><TD><font style=font-family:arial;font-size:1.5em><B><BR>Profile created!</b><font style=font-
family:arial;font-size:1em><br /><br />";
insertCustomerProfileID($cust_profile_id, $custid,$billTo_firstName,$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,
$billTo_zip,$email);
}
else
{
if($cim->code=='E00039')
{
if(strpos($cim->text,"A duplicate record with ID") !== false)
{
$cust_profile_id=substr($cim->text,strpos($cim->text,"ID")+3,8);
$cust_profile_id=trim($cust_profile_id);
}
}
else
{
echo "<table align=center><TR><TD><font style=font-family:arial;font-size:1.5em><B><BR>Profile NOT created!</b><BR><BR><font
style=font-family:arial;font-size:1em>Authorize.net could not be reached at this time. <BR>Please try again later<br /><br />";
}
}
echo "<BR><BR><font style=font-family:arial;font-size:.75em><a href=index.asp style=color:blue><u>Return</u></a><br /><br />";
$customer_payment_profile_id = get_customer_payment_profileid($cust_profile_id);
if ($custPrID=="")
{
insertCustomerPaymentProfileIDAndCustomerProfileID($cust_profile_id,$customer_payment_profile_id,$custid,$billTo_firstName,
$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,$billTo_zip,$email);
}

// process payment
if($customer_payment_profile_id !='' || $customer_payment_profile_id != '0')
{
$transaction_id = cim_transaction($cust_profile_id,$customer_payment_profile_id,$add_amount);
}
}
else
{

$cim->setParameter('customerProfileId', $custPrID); // Numeric (required)
// Payment gateway assigned ID associated with the customer payment profile
$cim->setParameter('customerPaymentProfileId', $custPayPrID); // Numeric (required)
$cim->updateCustomerPaymentProfileRequest();
echo "<table align=center><TR><TD><font style=font-family:arial;font-size:1.5em><B><BR>Profile updated. <br />";
// process payment
$transaction_id = cim_transaction($custPrID,$custPayPrID,$add_amount);

}
}

function insertCustomerProfileID($CustomerProfileID,$custid,$fname,$lname,$btaddr,$btcity,$btstate,$btzip,$btemail)
{
global $serverName,$connectionInfo,$params;

$conn = sqlsrv_connect( $serverName, $connectionInfo);
$sql_update = "UPDATE Contacts SET
Var116='$CustomerProfileID',var122='$fname',var123='$lname',var29='$btaddr',var30='$btcity',var31='$btstate',var32='$btzip',var17='$btemail' WHERE ID =".$custid;
sqlsrv_query( $conn, $sql_update, $params);

}
function insertCustomerPaymentProfileIDAndCustomerProfileID($CustomerProfileID,$CustomerPaymentProfileID,$custid,$fname,$lname,$btaddr,$btcity,$btstate,$btzip,
$btemail)
{
global $serverName,$connectionInfo,$params;

$conn = sqlsrv_connect( $serverName, $connectionInfo);
$sql_update = "UPDATE Contacts SET Var116 ='$CustomerProfileID',Var117
='$CustomerPaymentProfileID',var122='$fname',var123='$lname',var29='$btaddr',var30='$btcity',var31='$btstate',var32='$btzip',var17='$btemail' WHERE ID =".$custid;
sqlsrv_query( $conn, $sql_update, $params);

}

function get_customer_payment_profileid($cust_profile_id)
{
require_once('include/authorizenet.cim.class.php');
global $api_login_id,$api_transaction_key;

$cim = new AuthNetCim($api_login_id, $api_transaction_key, true); // Need to chage here mohit

$cim->setParameter('customerProfileId', $cust_profile_id); // Numeric (required)
$cim->getCustomerProfileRequest();

if ($cim->isSuccessful())
{
$str = $cim->response;
}
else
{


}

////////////WRITE AND READ XML FILE///////////////////////////

if(!empty($str))
{
$str1 = explode("<?xml",$str);
$str2 = "<?xml ". $str1[1];

$myFile = "cim_xml_files/cust_profile_id_".$cust_profile_id.".xml";
$fh = fopen($myFile, 'w');
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "$str2";
fwrite($fh, $stringData);
fclose($fh);

$XMLpath=$myFile;

$xml_data = fopen($XMLpath, "r");
$XMLfile=fread($xml_data,filesize($XMLpath));
$XMLparser = xml_parser_create();
xml_parse_into_struct($XMLparser, $XMLfile, $values, $index);
xml_parser_free($XMLparser);

for($i=0;$i<count($values);$i++)
{

/*
if(!empty($values[$i]['value']))
{
echo $values[$i]['tag'];
echo "=";
echo $values[$i]['value'];
}
echo "<br>";
*/
}

}



return $cim->customerPaymentProfileId;

}

 

 

function cim_transaction($customerProfileId,$customerPaymentProfileId,$transaction_amount)
{

require_once('include/authorizenet.cim.class.php');
$str = "";
$str1 = "";
global $api_login_id,$api_transaction_key;

$cim = new AuthNetCim($api_login_id, $api_transaction_key, true); // Need to chage here mohit
$cim->setParameter('transaction_amount', $transaction_amount); // Up to 4 digits with a decimal (required)

// transactionType = (profileTransCaptureOnly, profileTransAuthCapture or profileTransAuthOnly)
$cim->setParameter('transactionType', 'profileTransAuthOnly'); // see options above

// Payment gateway assigned ID associated with the customer profile
$cim->setParameter('customerProfileId', $customerProfileId); // Numeric (required)

// Payment gateway assigned ID associated with the customer payment profile
$cim->setParameter('customerPaymentProfileId', $customerPaymentProfileId); // Numeric (required)

// The tax exempt status
$cim->setParameter('transactionTaxExempt', 'false');

// The recurring billing status
$cim->setParameter('transactionRecurringBilling', 'false');

$cim->createCustomerProfileTransactionRequest();

if ($cim->isSuccessful())
{
$is_return = '1';
//echo "<br>".$cim->response;
$str = $cim->response;

echo "UPDATED<br>".$cim->directResponse;
echo "<br>";
//echo "<br>".$cim->validationDirectResponse;
//echo "<br>".$cim->resultCode;
//echo "<br>".$cim->code;
echo "<br>".$cim->text;
echo "<br>".$cim->refId;
echo "<br>".$cim->customerProfileId;
echo "<br>".$cim->customerPaymentProfileId;
echo "<br>".$cim->customerAddressId;

$str1 = explode(",Y,",$str);
$trans_id = substr($str1[1],0,10);
return $trans_id;
}
else
{
$is_return = '0';
//echo "NO<br>".$cim->directResponse;
//echo "<br>Validation=".$cim->validationDirectResponse;
//echo "<br>".$cim->resultCode;
//echo "<br>".$cim->code;
echo "<br>".$cim->text;
//echo "<br><pre>";
//print_r($cim->error_messages);
//echo "</pre>";
}

if($is_return=='1')
{
return('1');
}


// echo "<br>";
//echo "$str";

 

//exit;


}


function processCustomerByCustomerProfileID($CustomerProfileID,$CustomerPaymentProfileID,$add_amount)
{
if($CustomerPaymentProfileID !='' || $CustomerPaymentProfileID != '0')
{
$transaction_id = cim_transaction($CustomerProfileID,$CustomerPaymentProfileID,$add_amount);
}
}

 

 

Can't really tell from the code.

Can you get the echo response right after the curl?

the full curl posturlpath?

 

Did see any update, but create customer profile/payment profile if they don't exist, then create an auth_only transaction.

Here's where it dies.  I get the "Profile Not Created" message, after that (you can see the echo's), I get:


Profile NOT created!

Authorize.net could not be reached at this time. 
Please try again later

NO





ProfileId=

Error: Array
(
)

.

 

if ($custPrID=="")
{
$cim->createCustomerProfileRequest();
$cust_profile_id="";


if ($cim->isSuccessful())
{
$cust_profile_id = $cim->customerProfileId;
echo "<table align=center><TR><TD><font style=font-family:arial;font-size:1.5em><B><BR>Profile created!</b><font style=font-family:arial;font-size:1em><br /><br />";
insertCustomerProfileID($cust_profile_id, $custid,$billTo_firstName,$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,$billTo_zip,$email);
}
else
{
if($cim->code=='E00039')
{
if(strpos($cim->text,"A duplicate record with ID") !== false)
{
$cust_profile_id=substr($cim->text,strpos($cim->text,"ID")+3,8);
$cust_profile_id=trim($cust_profile_id);
}
}
else
{
echo "<table align=center><TR><TD><font style=font-family:arial;font-size:1.5em><B><BR>Profile NOT created!</b><BR><BR><font style=font-family:arial;font-size:1em>Authorize.net could not be reached at this time. <BR>Please try again later<br /><br />";
echo "NO<br>".$cim->directResponse;
echo "<br>".$cim->validationDirectResponse;
echo "<br>".$cim->resultCode;
echo "<br>".$cim->code;
echo "<br>".$cim->text;
echo "<br>ProfileId=".$cim->customerProfileId;
echo "<br><pre>Error: ";
print_r($cim->error_messages);
echo "</pre>";
}
}
echo "<BR><BR><font style=font-family:arial;font-size:.75em><a href=index.asp style=color:blue><u>Return</u></a><br /><br />";
$customer_payment_profile_id = get_customer_payment_profileid($cust_profile_id);
if ($custPrID=="")
{
insertCustomerPaymentProfileIDAndCustomerProfileID($cust_profile_id,$customer_payment_profile_id,$custid,$billTo_firstName,$billTo_lastName,$billTo_address,$billTo_city,$billTo_state,$billTo_zip,$email);
}

// process payment
if($customer_payment_profile_id !='' || $customer_payment_profile_id != '0')
{
$transaction_id = cim_transaction($cust_profile_id,$customer_payment_profile_id,$add_amount);
}
}

 

I assume the previous programmer echo's are correct, but please let me know if not.

All that tell us it that it fail, and it wasn't duplicate profile, it doesn't help to see why it fail.

Really need to get the response right after the curl. You might have to go into createCustomerProfileRequest to see where is calling curl.