cancel
Showing results for 
Search instead for 
Did you mean: 

displaying CIM profile information with PHP SDK

Hello, 

 

I'm trying to display information, but its not displaying. Can someone help me figure this one out? I know its not a good idea to display information, but I'm doing this because it will help me understand how this SDK works.

 

Thanks

 

	require_once 'anet_php_sdk/AuthorizeNet.php';
    define("AUTHORIZENET_API_LOGIN_ID", "LOGIN_ID");
    define("AUTHORIZENET_TRANSACTION_KEY", "TRANSACTION_KEY");
    $request = new AuthorizeNetCIM;
    // Create new customer profile
//echo $_SESSION['user_id'];
	$customerProfile                    = new AuthorizeNetCustomer;
    $customerProfile->description       = "Description of customer";
    $customerProfile->merchantCustomerId= time();
    $customerProfile->email             = "test@domain.com";
	$customerProfile->cardNumber        = '4111111111111111';
	$customerProfile->expirationDate    = "2021-04";
	//$customerProfile->cardCode          = $cvv;
	
    $response = $request->createCustomerProfile($customerProfile);
    if ($response->isOk()) {
        $customerProfileId = $response->getCustomerProfileId();
		echo $customerProfileId;

    }
	$customerProfileId = $response->getCustomerProfileId();
echo $customerProfileId;

 

andrewliu
Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

The way you add a payment profile is wrong.

 

define('AUTHORIZENET_API_LOGIN_ID', 'LOGIN_ID');
define('AUTHORIZENET_TRANSACTION_KEY', 'TRANSACTION_KEY');

// Let's create a payment profile first.
$paymentProfile = new AuthorizeNetPaymentProfile();
$creditCard = $paymentProfile->payment->creditCard;
$creditCard->cardNumber = '4111111111111111';
$creditCard->expirationDate = '2021-04';
//$creditCard->cardCode = $cvv;

// Customer profile comes next.
$customerProfile = new AuthorizeNetCustomer();
$customerProfile->description = 'Description of customer';
$customerProfile->merchantCustomerId = time();
$customerProfile->email = 'test@domain.com';
$customerProfile->paymentProfiles[] = $paymentProfile;

// Off it goes.
$request = new AuthorizeNetCIM();
$response = $request->createCustomerProfile($customerProfile);

if($response->isOk()) {
	$customerProfileId = $response->getCustomerProfileId();
	echo $customerProfileId;
}
else {
	echo $response->getErrorMessage();
}

 

View solution in original post

4 REPLIES 4

anyone have CIM experience? 

 

Thanks

andrewliu
Contributor

The way you add a payment profile is wrong.

 

define('AUTHORIZENET_API_LOGIN_ID', 'LOGIN_ID');
define('AUTHORIZENET_TRANSACTION_KEY', 'TRANSACTION_KEY');

// Let's create a payment profile first.
$paymentProfile = new AuthorizeNetPaymentProfile();
$creditCard = $paymentProfile->payment->creditCard;
$creditCard->cardNumber = '4111111111111111';
$creditCard->expirationDate = '2021-04';
//$creditCard->cardCode = $cvv;

// Customer profile comes next.
$customerProfile = new AuthorizeNetCustomer();
$customerProfile->description = 'Description of customer';
$customerProfile->merchantCustomerId = time();
$customerProfile->email = 'test@domain.com';
$customerProfile->paymentProfiles[] = $paymentProfile;

// Off it goes.
$request = new AuthorizeNetCIM();
$response = $request->createCustomerProfile($customerProfile);

if($response->isOk()) {
	$customerProfileId = $response->getCustomerProfileId();
	echo $customerProfileId;
}
else {
	echo $response->getErrorMessage();
}

 

Amazing! Thank you!

So essentially, I can just call out that profileId and get those credit card information and Display it to the user?