cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get response code for CIM PHP SDK?

I am using the following code

$customerProfile = new AuthorizeNetCustomer;
	$customerProfile->description = "Description of customer";
	$customerProfile->merchantCustomerId = "honululu27";
	$customerProfile->email = "user2@domain.com";

	// Add payment profile.
	$paymentProfile = new AuthorizeNetPaymentProfile;
	$paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
	$paymentProfile->payment->creditCard->expirationDate = "2015-10";
	$customerProfile->paymentProfiles[] = $paymentProfile;
	
	//Check customer
	$request = new AuthorizeNetCIM;
	$response = $request->createCustomerProfile($customerProfile);
	echo $response->getCustomerProfileId(); //shows up only in case of success
	echo $response->xml->resultCode; //never shows up
        echo $response->xml->message->code; //never shows up
        echo $response->xml->customerProfileId; //shows up only in case of success
	
        // Confused about the portion below
if($response->isOk()) { echo "Success"; echo $response->getCustomerProfileId(); } else { echo "FAILED"; echo $response->xml->resultCode; }

 Now, as you can probably tell, i am a novice at this, so I can't figure out how to display the message text and code. The only thing working is the customer id, which shows up in case of success, but what about all the other xml fields like messages?

mps_sudipta
Contributor
1 REPLY 1

If the response is in the same format as for AIM and ARB, you should be able to access the result code with:

 

$response->xml->messages->resultCode

 and descriptive text with:

 

$response->xml->messages->message->text

 I know it's a bit confusing - I had to experiment a lot before I figured out how to do it. Your best bet is to use print_r() to output the response so you can see what it looks like, then print_r() the individual parts and gradually work your way to the specific variable you want. If you're not familiar with print_r(), go to php.net and search for it.

TJPride
Expert