Need JSON schema for Webhooks Order payment event

Highlighted
New Member
1 0 0

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

0 Likes
Highlighted
Shopify Staff
Shopify Staff
26 3 4

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

0 Likes
Highlighted
Shopify Partner
1866 181 748

As @marcusradica 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.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Highlighted
Shopify Partner
649 46 130

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...  

1 Like
Highlighted
Shopify Partner
1866 181 748

@Greg_Kujawa True, I forgot the non JS world

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes