cancel
Showing results for 
Search instead for 
Did you mean: 

Who Me Too'd this topic

JSON API warning: properties are order-dependent

It took me a long time to figure this out. For the benefit of the next poor soul:

 

The order of the properties of transactionRequest is significant.

 

If you do not put the "amount" property into your object immediately following the "transactionType" property, you will get confusing errors claiming it is an invalid child element.

 

This happened to me because I was totaling up the lineItems and then inserting the total as the last property.

 

Normally in JSON APIs property order does not matter. Indeed, JavaScript does not guarantee a property order, period! But on the back end it's pretty clear authorize.net is translating this into XML and order dependent elements are a little less weird there. Although still weird and annoying and I suspect they could fix this.

 

But, the simplest workaround if, like me, you want to touch the total property last, is to add it with a dummy value early and then change that value. This works because the order of the properties has already been established.

 

Hope this is helpful!

boutell
Member
Who Me Too'd this topic