Error in Deprecated API - Possible to get it working?

I have an application using the deprecated PHP iSDK found here: https://github.com/jakedewitt87/iSDK

Some of the API calls are still working but I get this error when trying to add a new card to contact:

ERROR: -1 - Failed to invoke method add in class com.infusionsoft.api.xmlrpc.XmlRpcDataService: java.lang.StringIndexOutOfBoundsException: String index out of range: 1

I’m wondering if there is some method of getting this to work even temporarily or if I’m out of luck and just need to update the application to the new PHP SDK.

Here’s a code snippet of the API call that fails. I’ve checked to make sure all the information is valid.

$card = array('ContactId' => $contactID,
	      'NameOnCard' => $_POST['contactCCName'],
	      'CardNumber' => $_POST['contactCCNumber'],
	      'CardType' => $_POST['contactCCType'],
	      'CVV2' => $_POST['contactCCCode'],
	      'ExpirationMonth' => $_POST['contactExpDateMonth'],
	      'ExpirationYear' => "20".$_POST['contactExpDateYear'],
	      'BillAddress1' => $_POST['contactStreetAddress'],
	      'BillCity' => $_POST['contactCity'],
	      'BillState' => $_POST['contactState'],
	      'BillZip' => $_POST['contactZip'],
	      'BillCountry' =>"United States",
          'Email' => $_POST['contactEmail'],
              );

$cardID = $app->dsAdd("CreditCard", $card);

@Jonathan_Rand Would you post a capture of the request being made to the API? (Be sure to remove any sensitive data.)

Here’s a dump of the $call data. Let me know if it’s something else you’re looking for. All sensitive data has been changed.

    $result = $this->client->send($call);
    var_dump($call);

["debug"]=> int(0)
["content_type"]=> string(8) "text/xml" } object(xmlrpcmsg)#18 (5) {
["payload"]=> string(1385) " DataService.add {{legacyAPIKey}} CreditCard ContactId 689 NameOnCard Jonathan Rand CardNumber {{actualCardNumber}} CardType Visa CVV2 999 ExpirationMonth 02 ExpirationYear 2019 BillAddress1 123 Main St BillCity Beverly Hills BillState CA BillZip 90210 BillCountry United States Email notmyemailaddress@gmail.com "
["methodname"]=> string(15) "DataService.add"
["params"]=> array(3) {
[0]=> object(xmlrpcval)#3 (3) {
["me"]=> array(1) {
["string"]=> string(32) "{{legacyAPIKey}}" }
["mytype"]=> int(1)
["_php_class"]=> NULL } [1]=> object(xmlrpcval)#17 (3) {
["me"]=> array(1) {
["string"]=> string(10) "CreditCard" }
["mytype"]=> int(1)
["_php_class"]=> NULL } [2]=> object(xmlrpcval)#19 (3) {
["me"]=> array(1) {
["struct"]=> array(13) {
["ContactId"]=> object(xmlrpcval)#16 (3) {
["me"]=> array(1) {
["int"]=> int(689) }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["NameOnCard"]=> object(xmlrpcval)#14 (3) {
["me"]=> array(1) {
["string"]=> string(15) "Jonathan Rand" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["CardNumber"]=> object(xmlrpcval)#15 (3) {
["me"]=> array(1) {
["string"]=> string(16) "{{actualCardNumber}}" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["CardType"]=> object(xmlrpcval)#7 (3) {
["me"]=> array(1) {
["string"]=> string(4) "Visa" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["CVV2"]=> object(xmlrpcval)#4 (3) {
["me"]=> array(1) {
["string"]=> string(3) "999" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["ExpirationMonth"]=> object(xmlrpcval)#5 (3) {
["me"]=> array(1) {
["string"]=> string(2) "02" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["ExpirationYear"]=> object(xmlrpcval)#8 (3) {
["me"]=> array(1) {
["string"]=> string(4) "2019" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["BillAddress1"]=> object(xmlrpcval)#6 (3) {
["me"]=> array(1) {
["string"]=> string(22) "123 Main St" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["BillCity"]=> object(xmlrpcval)#9 (3) {
["me"]=> array(1) {
["string"]=> string(11) "Beverly Hills" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["BillState"]=> object(xmlrpcval)#10 (3) {
["me"]=> array(1) {
["string"]=> string(2) "CA" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["BillZip"]=> object(xmlrpcval)#11 (3) {
["me"]=> array(1) {
["string"]=> string(5) "90210" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["BillCountry"]=> object(xmlrpcval)#12 (3) {
["me"]=> array(1) {
["string"]=> string(13) "United States" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
["Email"]=> object(xmlrpcval)#13 (3) {
["me"]=> array(1) {
["string"]=> string(23) "notmyemailaddress@gmail.com" }
["mytype"]=> int(1)
["_php_class"]=> NULL }
}
}

Hey @Jonathan_Rand, The call itself looks ok, but I am not 100% sure what the post variables are once they get evaluated and inserted on your end, I can see them here but I mean it in a more of a general sense of knowing or guaranteeing their expected value.

I would recommend putting some sanitation/helpers on the post variables, or inspecting them with a debugger to get their actual value. There are several different types of filters/cleaners available out of the box. I would just find one that fits your use case.

@Carlos_Ochoa
@mike.christianson
Here’s a printout of the XML being sent by the SDK. It took a bit of digging to get to this point, so I’m imagining if the problem isn’t apparent here from some data that it’s an issue with the SDK since the updates. Is anyone successfully using the old SDK for card/ payment data?
—SENDING—

<?xml version="1.0"?>
<methodCall>
   <methodName>DataService.add</methodName>
   <params>
      <param>
         <value>
            <string>{{legacyAPIKey}}</string>
         </value>
      </param>
      <param>
         <value>
            <string>CreditCard</string>
         </value>
      </param>
      <param>
         <value>
            <struct>
               <member>
                  <name>ContactId</name>
                  <value>
                     <int>689</int>
                  </value>
               </member>
               <member>
                  <name>NameOnCard</name>
                  <value>
                     <string>Jonathan Rand</string>
                  </value>
               </member>
               <member>
                  <name>Email</name>
                  <value>
                     <string>notmyemail@gmail.com</string>
                  </value>
               </member>
               <member>
                  <name>BillAddress1</name>
                  <value>
                     <string>123 Main St</string>
                  </value>
               </member>
               <member>
                  <name>BillState</name>
                  <value>
                     <string>CA</string>
                  </value>
               </member>
               <member>
                  <name>BillZip</name>
                  <value>
                     <string>90210</string>
                  </value>
               </member>
               <member>
                  <name>BillCity</name>
                  <value>
                     <string>Beverly Hills</string>
                  </value>
               </member>
               <member>
                  <name>BillCountry</name>
                  <value>
                     <string>United States</string>
                  </value>
               </member>
               <member>
                  <name>CardType</name>
                  <value>
                     <string>Visa</string>
                  </value>
               </member>
               <member>
                  <name>CardNumber</name>
                  <value>
                     <string>{{actualCardNumber}}</string>
                  </value>
               </member>
               <member>
                  <name>ExpirationMonth</name>
                  <value>
                     <string>02</string>
                  </value>
               </member>
               <member>
                  <name>ExpirationYear</name>
                  <value>
                     <string>2019</string>
                  </value>
               </member>
               <member>
                  <name>CVV2</name>
                  <value>
                     <string>999</string>
                  </value>
               </member>
            </struct>
         </value>
      </param>
   </params>
</methodCall>

—END—

Hmm, interesting…I tested this xml by swapping out the ContactId for one that exists in my application. I used postman and a card was added to my contact record successfully.

POST https://{{appName}}.infusionsoft.com/api/xmlrpc
<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
   <methodName>DataService.add</methodName>
   <params>
      <param>
         <value>
            <string>{{APIKey}}</string>
         </value>
      </param>
      <param>
         <value>
            <string>CreditCard</string>
         </value>
      </param>
      <param>
         <value>
            <struct>
               <member>
                  <name>ContactId</name>
                  <value>
                     <int>{{contactID}}</int>
                  </value>
               </member>
               <member>
                  <name>NameOnCard</name>
                  <value>
                     <string>Jonathan Rand</string>
                  </value>
               </member>
               <member>
                  <name>Email</name>
                  <value>
                     <string>notmyemail@gmail.com</string>
                  </value>
               </member>
               <member>
                  <name>BillAddress1</name>
                  <value>
                     <string>123 Main St</string>
                  </value>
               </member>
               <member>
                  <name>BillState</name>
                  <value>
                     <string>CA</string>
                  </value>
               </member>
               <member>
                  <name>BillZip</name>
                  <value>
                     <string>90210</string>
                  </value>
               </member>
               <member>
                  <name>BillCity</name>
                  <value>
                     <string>Beverly Hills</string>
                  </value>
               </member>
               <member>
                  <name>BillCountry</name>
                  <value>
                     <string>United States</string>
                  </value>
               </member>
               <member>
                  <name>CardType</name>
                  <value>
                     <string>Visa</string>
                  </value>
               </member>
               <member>
                  <name>CardNumber</name>
                  <value>
                     <string>{{actualCardNumber}}</string>
                  </value>
               </member>
               <member>
                  <name>ExpirationMonth</name>
                  <value>
                     <string>02</string>
                  </value>
               </member>
               <member>
                  <name>ExpirationYear</name>
                  <value>
                     <string>2019</string>
                  </value>
               </member>
               <member>
                  <name>CVV2</name>
                  <value>
                     <string>999</string>
                  </value>
               </member>
            </struct>
         </value>
      </param>
   </params>
</methodCall>

Are you able to test using an http client and let me know your result?

It appears to an issue on our end if @Carlos_Ochoa was successful. What appname is this for an I can check the logs.