Need JSON schema for Webhooks Order payment event

jfkScollar
Shopify Partner
16 0 2

Hello,

We are attempting to validate and process the JSON that our application subscribed to for the Order payment event. We are seeing inconsistent JSON object properties depending on how a customer's order is paid (paypal vs credit card) and other inconsistencies. We do not know all the variations for your JSON format for the Order payment event. Can you share the JSON schema for the order payment, so we can properly validate and parse this JSON without errors?

Thank you,

John

Replies 4 (4)

mrad
Shopify Staff (Retired)
63 10 15

Hello, you can find the JSON under "orders/paid" here: https://shopify.dev/docs/admin-api/rest/reference/events/webhook

mrad | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

KarlOffenberger
Shopify Partner
1873 184 901

As @mrad pointed out, the JSON responses are documented but there are no schema for validation. I do not believe validating the entire response is necessary - i.e. no need to validate the response as it resolves, just validate inputs at function level that make use of parts of that response as you're unlikely to be passing the entire response body to downstream functions in your code anyway.

Gregarican
Shopify Partner
1033 86 285

Perhaps the OP's code is performing some sort of JSON deserialization, so that inconsistencies can potentially break the string being parsed into an object. While Shopify's JSON response body is typically pretty consistent, I'm not too well-versed on using their webhooks. Using other vendor API's (e.g. - Lightspeed Retail) I would have to encapsulate the JSON string reading with some "gotcha" methods to sidestep their incredibly inconsistent API response JSON elements.

Point is that even if the API consumer only needs a couple of elements, if they are employing JSON deserialization then that's a potential gotcha...  

KarlOffenberger
Shopify Partner
1873 184 901

@Gregarican True, I forgot the non JS world 😄