01-14-2016 09:43 AM
I'm working on a project that uses what appears to be a slightly older version of the PHP SDK. Sadly, the PHP code does not appear to specify any version for the SDK. I have constructed code using this SDK that is supposed to update a CIM profile. I keep getting this error though:
Message: The element 'creditCard' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd' has invalid child element 'expirationDate' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'. List of possible elements expected: 'cardNumber' in namespace 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'.
It appears to be generating this XML which causes the problem:
<?xml version="1.0" encoding="utf-8"?> <updateCustomerPaymentProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>XXXXXXXXX</name> <transactionKey>YYYYYYYY</transactionKey> </merchantAuthentication> <customerProfileId>AAAAAAAA</customerProfileId> <paymentProfile> <customerType>individual</customerType> <payment> <creditCard> <expirationDate>2022-06</expirationDate> <cardCode>456</cardCode> </creditCard> </payment> <customerPaymentProfileId>BBBBBBBB</customerPaymentProfileId> </paymentProfile> </updateCustomerPaymentProfileRequest>
I've been trying to figure out what's wrong with this XML by checking the API:
But I'm really just doing trial and error. Can someone help me sort this? My code looks something like this:
$authorizenet_cim_request = new AuthorizeNetCIM($this->conf_api_login_id, $this->conf_api_transaction_key); $authorizenet_cim_request->setSandbox($this->conf_sandbox); $authorizenet_cim_request->setLogFile($this->conf_log_file); $paymentProfile = new AuthorizeNetPaymentProfile; $paymentProfile->customerType = "individual"; $paymentProfile->payment->creditCard->expirationDate = "2022-06"; $paymentProfile->payment->creditCard->cardCode = "456"; $transaction_result = $authorizenet_cim_request->updateCustomerPaymentProfile("AAAAAAAA", "BBBBBBBB", $paymentProfile);
Any help would be much appreciated.
01-14-2016 11:23 AM
The sequence matter. and you need the credit card# "Number can also be masked, for example, XXXX1111"
Usually you do a get payment profile, then do a update with the masked card#.
01-14-2016 01:59 PM
OK supplying the masked credit card number (which seems really silly to me) is a very helpful tip.
With some trial-and-error, I've managed to get something working with the sandbox API.
Apparently the API docs are wrong. When you don't supply values, rather than the API blanking these in the system, it leaves the prior setting -- at least in most cases -- with the sandbox.
12-05-2016 01:35 PM
re: sequence matter
What??? Seriously?!?! XML is OOP and sequence shouldn't matter if it's compliant xml. And how do you suppose one gets the sequence right using your github api that uses SimpleXMLElement with it's ->toXml() method which appears to jumble the order? (I added the elements in order, it seems to have changed the order when creating the xml output)