cancel
Showing results for 
Search instead for 
Did you mean: 

Confused by CIM documentation (XML/PHP)

HI all,

 

I am a long time CyberSource API user and a new Auth.net user.  We are a PHP application.  We are migrating our platform to Auth.net and I am already confused with the documentation.  I am starting with the documentation for the CIM as we do a lot of integration with profiles in our application. 

 

All of the CIM online documentation (in beta, I think) located at http://developer.authorize.net/api/reference/index.html shows examples in an XML format.  However the PHP examples in the source code SDK I downloaded from github show exmples using PHP classes.  For example, to create a profile in the documentation says:

<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">  
   <merchantAuthentication>
     <name>API_LOGIN_ID</name>
     <transactionKey>API_TRANSACTION_KEY</transactionKey>
    </merchantAuthentication>
   <profile>
     <merchantCustomerId>Merchant_Customer_ID</merchantCustomerId>
     <description>Profile description here</description>
     <email>customer-profile-email@here.com</email>
     <paymentProfiles>
       <customerType>individual</customerType>
          <payment>
             <creditCard>
                <cardNumber>4111111111111111</cardNumber>
                <expirationDate>2020-12</expirationDate>
              </creditCard>
           </payment>
      </paymentProfiles>
    </profile>
	<validationMode>testMode</validationMode>
  </createCustomerProfileRequest>

Whereas the PHP SDK example code (from file AuthorizeNetCIM_Test.php) shows examples like this:

    public function testCreateCustomerProfile()
  {
    // Create new customer profile
    $request = new AuthorizeNetCIM;
    $customerProfile = new AuthorizeNetCustomer;
    $customerProfile->description = "Description of customer";
    $customerProfile->merchantCustomerId = time().rand(1,100);
    $customerProfile->email = "blahbla@domain.com";

    // Add payment profile.
    $paymentProfile = new AuthorizeNetPaymentProfile;
    $paymentProfile->customerType = "individual";
    $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
    $paymentProfile->payment->creditCard->expirationDate = "2015-10";
    $customerProfile->paymentProfiles[] = $paymentProfile;

    // Add another payment profile.
    $paymentProfile2 = new AuthorizeNetPaymentProfile;
    $paymentProfile2->customerType = "business";
    $paymentProfile2->payment->bankAccount->accountType = "businessChecking";
    $paymentProfile2->payment->bankAccount->routingNumber = "121042882";
    $paymentProfile2->payment->bankAccount->accountNumber = "123456789123";
    $paymentProfile2->payment->bankAccount->nameOnAccount = "Jane Doe";
    $paymentProfile2->payment->bankAccount->echeckType = "WEB";
    $paymentProfile2->payment->bankAccount->bankName = "Pandora Bank";
    $customerProfile->paymentProfiles[] = $paymentProfile2;


    // Add shipping address.
    $address = new AuthorizeNetAddress;
    $address->firstName = "john";
    $address->lastName = "Doe";
    $address->company = "John Doe Company";
    $address->address = "1 Main Street";
    $address->city = "Boston";
    $address->state = "MA";
    $address->zip = "02412";
    $address->country = "USA";
    $address->phoneNumber = "555-555-5555";
    $address->faxNumber = "555-555-5556";
    $customerProfile->shipToList[] = $address;

    // Add another shipping address.
    $address2 = new AuthorizeNetAddress;
    $address2->firstName = "jane";
    $address2->lastName = "Doe";
    $address2->address = "11 Main Street";
    $address2->city = "Boston";
    $address2->state = "MA";
    $address2->zip = "02412";
    $address2->country = "USA";
    $address2->phoneNumber = "555-512-5555";
    $address2->faxNumber = "555-523-5556";
    $customerProfile->shipToList[] = $address2;

    $response = $request->createCustomerProfile($customerProfile);
    $this->assertTrue($response->isOk());
    $this->assertEquals(2, count($response->getCustomerShippingAddressIds()));
    $this->assertEquals(2, count($response->getCustomerPaymentProfileIds()));
    $customerProfileId = $response->getCustomerProfileId();

... etc...

  }

I am much more comfortable with the latter as I am new to XML, but where can I find reliable documentation for the PHP class type calls instead of the XML version?  I am finding it very difficult to match the XML documentation back to the PHP class-style calls.

4classjuggler
Member
1 REPLY 1

Hello @4classjuggler

 

Do you still have questions, or was you post below the solution you found?

 

http://community.developer.authorize.net/t5/Integration-and-Testing/How-do-I-parse-the-result-messag...

 

Richard

RichardH
Administrator Administrator
Administrator