cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid child element in PHP CIM SDK when updating payment profile.

I'm using the provided PHP SDK to make CIM calls.  So far, I have correctly made calls to createCustomerProfile, createCustomerPaymentProfile, and getCustomerPaymentProfile.  Updating, however, is causing some issues for me.

 

In order to update the payment profile, I call getCustomerPaymentProfile, make my necessary changes, and pass it back using updateCustomerPaymentProfile.  The result from that call includes an error stating that the 'paymentProfile' element has an invalid child element 'payment'.  I've tried removing all the changes I make to the profile, and just resubmitting it as I receive it, but that didn't help.  Browsing the forums, I saw that the order of the elements may matter.  In case the SDK was printing the elements in the wrong order, I dumped the xml it produced, to verify it.

 

It turned out the xml for the paymentProfile contained the customerPaymentProfileId before either the payment or billTo elements.  Since the xml element is coming straight from the response to the getCustomerPaymentProfile call, I think this may be a bug in the SDK.  As a temporary workaround, I unset the customerPaymentProfileId field before sending it back, since the update method sets it again anyway.

 

Below is the code I used to expose this bug:

$request = new AuthorizeNetCIM;
$response = $request->getCustomerPaymentProfile($cpid, $ppid);
if ($response->isOk()) {
  $profile = $response->xml->paymentProfile;

  $request = new AuthorizeNetCIM;
  $response = $request->updateCustomerPaymentProfile($cpid, $ppid, $profile);

  if (!$response->isOk()) {
    print_r(array($profile, $response));
  }
}

 And here is the xml it sent (before implementing my workaround):

<!--?xml version="1.0" encoding="utf-8"?-->
<updatecustomerpaymentprofilerequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
  <merchantauthentication>
    <name>--snip--</name>
    <transactionkey>--snip--</transactionkey>
  </merchantauthentication>
  <customerprofileid>--snip--</customerprofileid>
  <paymentprofile>
    <customertype>individual</customertype>
    <customerpaymentprofileid>--snip--</customerpaymentprofileid>
    <payment>
      <creditcard>
        <cardnumber>XXXX1111</cardnumber>
        <expirationdate>XXXX</expirationdate>
      </creditcard>
    </payment>
  </paymentprofile>
</updatecustomerpaymentprofilerequest>

 Thank you for your time.

 

-Mark

mmillford
Member
1 REPLY 1

Hi Mark,

Thanks for the bug report, we'll document it for our Development team to take a review and fix in a future update.

 

Thanks,

Joy

Joy
Administrator Administrator
Administrator