cancel
Showing results for 
Search instead for 
Did you mean: 

Error connecting to AuthorizeNet using CIM

I can't understand why using the same customer and payment profile I can process one request and can not another. So here 2 XML requests I fetched from PHP SDK:

 

Working

<createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>94sBwY7W</name>
        <transactionKey>54CKFe355sY8cpgg</transactionKey>
    </merchantAuthentication>
    <transaction>
        <profileTransAuthCapture>
            <amount>2.10</amount>
            <lineItems>
                <itemId>7</itemId>
                <name>I Am Legend</name>
                <description>Years after a plague kills most of humanity and transforms the rest into monsters, the sole survivor in New York City struggles valiantly to find a cure.</description>
                <quantity>1</quantity>
                <unitPrice>2.10</unitPrice>
            </lineItems>
            <customerProfileId>7046088</customerProfileId>
            <customerPaymentProfileId>6115373</customerPaymentProfileId>
        </profileTransAuthCapture>
    </transaction>
</createCustomerProfileTransactionRequest>

 

Not working

<createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>----------------</name>
        <transactionKey>----------------</transactionKey>
    </merchantAuthentication>
    <transaction>
        <profileTransAuthCapture>
            <amount>2.99</amount>
            <lineItems>
                <itemId>41</itemId>
                <name>Mr. Imperium</name>
                <description>A beautiful singer/dancer turned actress and playboy crown prince turned monarch have their clandestine romance interfered with by their changing circumstances.</description>
                <quantity>1</quantity>
                <unitPrice>2.99</unitPrice>
            </lineItems>
            <customerProfileId>7045748</customerProfileId>
            <customerPaymentProfileId>6115050</customerPaymentProfileId>
        </profileTransAuthCapture>
    </transaction>
</createCustomerProfileTransactionRequest>

Difference only in itemId, name, description.

 

So as I said for the second requests I got just "Error connecting to AuthorizeNet" using CIM without any code or other explanation. Both requests constantly work in the same environment. 

 

I have to mention this is developer account, live mode. 

 

 

dV
Contributor
5 REPLIES 5

I also found in documetation that name must be not more that 31 and desc - 255 charachters length. So I remove thease itemId, nadm and descriptino at all 

 

<createCustomerProfileTransactionRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <merchantAuthentication>
        <name>----------------</name>
        <transactionKey>----------------</transactionKey>
    </merchantAuthentication>
    <transaction>
        <profileTransAuthCapture>
            <amount>2.99</amount>
            <lineItems>
                <quantity>1</quantity>
                <unitPrice>2.99</unitPrice>
            </lineItems>
            <customerProfileId>7047316</customerProfileId>
            <customerPaymentProfileId>6116654</customerPaymentProfileId>
        </profileTransAuthCapture>
    </transaction>
</createCustomerProfileTransactionRequest>

 

It doesn't work aither :(

dV
Contributor

If you're getting an error connecting, it might be unrelated to the request itself. If not, then post the response.

So here's XML response

 

<ErrorResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <messages>
        <resultCode>Error</resultCode>
        <message>
            <code>E00003</code>
            <text>The element 'lineItems' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'quantity' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'name' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.</text>
        </message>
    </messages>
</ErrorResponse>

 

Here's code I use (Authrize.net SDK)

 

$request = $this->getAuthorizNetRequest('cim');
        /* @var $request AuthorizeNetCIM */
        

        $item              = new AuthorizeNetLineItem;
        $item->itemId      = $this->id;
//        $item->name        = $this->title;
//        $item->description = $this->description;
        $item->quantity    = 1;
        $item->unitPrice   = $amount;

        $transaction = new AuthorizeNetTransaction;
        $transaction->amount                    = $amount;
        $transaction->customerProfileId         = $customerProfileId;
        $transaction->customerPaymentProfileId  = $paymentProfileId;
        $transaction->lineItems[]               = $item;

        
        return $request->createCustomerProfileTransaction('AuthCapture', $transaction);

 

 

 

That error is probably caused by the child elements being put in the wrong order. Normally this wouldn't be a problem with XML, but Authorize.net is rather finnicky that way. Try putting in a name and a description, with the description truncated if beyond the length cutoff, and see if that helps. If not, you could try looking at the CIM.markdown file in the doc folder of your SDK and seeing if using that code makes a difference. The sample code there says this (the last part may need slight changes):

 

$request = new AuthorizeNetCIM;

$transaction = new AuthorizeNetTransaction;
$transaction->amount = "9.79";
$transaction->customerProfileId = $customerProfileId;
$transaction->customerPaymentProfileId = $paymentProfileId;
$transaction->customerShippingAddressId = $customerAddressId;
    
$lineItem              = new AuthorizeNetLineItem;
$lineItem->itemId      = "4";
$lineItem->name        = "Cookies";
$lineItem->description = "Chocolate Chip";
$lineItem->quantity    = "4";
$lineItem->unitPrice   = "1.00";
$lineItem->taxable     = "true";

$lineItem2             = new AuthorizeNetLineItem;
$lineItem2->itemId     = "4";
$lineItem2->name       = "Cookies";
$lineItem2->description= "Peanut Butter";
$lineItem2->quantity   = "4";
$lineItem2->unitPrice  = "1.00";
$lineItem2->taxable    = "true";

$transaction->lineItems[] = $lineItem;
$transaction->lineItems[] = $lineItem2;

$response = $request->createCustomerProfileTransaction("AuthCapture", $transaction);
$transactionResponse = $response->getTransactionResponse();
$transactionId = $transactionResponse->transaction_id;

 

So as the error message said  "List of possible elements expected 'name' in namespace..." I removed description at all and cut name to 31 characters. It seems to work now. 

Generally it's strange cause in documentation siad that name is optional parameter.