sdk-php icon indicating copy to clipboard operation
sdk-php copied to clipboard

XML to JSON endpoint bug

Open rcernava opened this issue 5 years ago • 0 comments

Hi,

Since the move to JSON in 2.0 getAUJobDetailsRequest is not operating as expected. This is due to the fact that the auDetails response would expect tags of type auDelete and auUpdate. The XML version works as expected, but when going to JSON a numbered array is returned vs tags. Understandably this is a limitation of JSON as you could only have one property with the same key value of auDelete or auUpdate. This is causing so the SDK does not work with this endpoint request. The fix would be to build one record for the AU and set a type OR wrap all updates or deletions in their own respective array.

example:

{
    "totalNumInResultSet": 2,
    "auDetails": [
        {
            "creditCard": {
                "cardNumber": "XXXX12345",
                "expirationDate": "2026-01",
                "cardType": "V"
            },
            "customerProfileID": 123123123,
            "customerPaymentProfileID": 123123123,
            "firstName": "NAME",
            "lastName": "NAME",
            "updateTimeUTC": "6/24/2019 5:27:46 AM",
            "auReasonCode": "CCH",
            "reasonDescription": "ContactCardHolder"
        },
        {
            "newCreditCard": {
                "cardNumber": "XXXX1234",
                "expirationDate": "2026-11",
                "cardType": "V"
            },
            "oldCreditCard": {
                "cardNumber": "XXXX1234",
                "expirationDate": "2020-11",
                "cardType": "V"
            },
            "customerProfileID": 123123,
            "customerPaymentProfileID": 123123,
            "firstName": "NAME",
            "lastName": "NAME",
            "updateTimeUTC": "6/24/2019 5:27:46 AM",
            "auReasonCode": "NAN",
            "reasonDescription": "NewAccountNumber"
        }]}

XML version example:

<getAUJobDetailsResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
    <refId>ref1596905156</refId>
    <messages>
        <resultCode>Ok</resultCode>
        <message>
            <code>I00001</code>
            <text>Successful.</text>
        </message>
    </messages>
    <totalNumInResultSet>2</totalNumInResultSet>
    <auDetails>
        <auDelete>
            <customerProfileID>123123123</customerProfileID>
            <customerPaymentProfileID>123123123</customerPaymentProfileID>
            <firstName>NAME</firstName>
            <lastName>NAME</lastName>
            <updateTimeUTC>6/24/2019 5:27:46 AM</updateTimeUTC>
            <auReasonCode>CCH</auReasonCode>
            <reasonDescription>ContactCardHolder</reasonDescription>
            <creditCard>
                <cardNumber>XXXX123</cardNumber>
                <expirationDate>2026-04</expirationDate>
                <cardType>V</cardType>
            </creditCard>
        </auDelete>
        <auUpdate>
            <customerProfileID>123123123</customerProfileID>
            <customerPaymentProfileID>123123123</customerPaymentProfileID>
            <firstName>NAME</firstName>
            <lastName>NAME</lastName>
            <updateTimeUTC>6/24/2019 5:27:46 AM</updateTimeUTC>
            <auReasonCode>NAN</auReasonCode>
            <reasonDescription>NewAccountNumber</reasonDescription>
            <newCreditCard>
                <cardNumber>XXXX1123</cardNumber>
                <expirationDate>2026-11</expirationDate>
                <cardType>V</cardType>
            </newCreditCard>
            <oldCreditCard>
                <cardNumber>XXXX123</cardNumber>
                <expirationDate>2020-11</expirationDate>
                <cardType>V</cardType>
            </oldCreditCard>
        </auUpdate>
    </auDetails>
</getAUJobDetailsResponse>

rcernava avatar Aug 08 '20 17:08 rcernava