Need JSON schema for Webhooks Order payment event

jfkScollar
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
marcusradica
Shopify Staff
Shopify Staff
41 5 6

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

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

0 Likes
KarlOffenberger
Shopify Partner
1867 182 805

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
Greg_Kujawa
Shopify Partner
1016 83 227

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
1867 182 805

@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