question

alexcunn avatar image
alexcunn asked alexcunn edited

Where can I find the order that triggered the webhook?

I am trying to set up my own print system. I have a webhook set up but can't figure out how to get the order ID of the order that triggered it. Maybe get the latest order?
Webhooks
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image
David Marginian Deactivated answered

Per the documentation I linked the objectId/eventId contains an event type key (see the docs) followed by an object id. For the case of an order the eventId will be O:orderId. You will need to parse the event id, the text after the ":" is the orderId. I just verified this with a test webhook. You can then use the REST API to obtain the order /v3/merchants/{mid}/orders/{orderId}?access_token={access_token}.

7 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

alexcunn avatar image alexcunn commented ·

You can enter any ID and it will return something. When I enter the objectID that does not reflect the orderid in the clover device, it returns a blank response when there are line items in the order.

'{"elements": [ ], "href": "http://api.clover.com/v3/merchants/(my merchant id)/orders/(objectID)/line_items?limit=100"}'

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ alexcunn commented ·

api.clover.com is a production endpoint. Are you possibly getting your environments confused?

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ alexcunn commented ·

If you want you can submit a private post with the webhook response body, and information on the environment you are working in and I can take a closer look.

0 Likes 0 ·
alexcunn avatar image alexcunn David Marginian ♦♦ commented ·

Sure! I'm using my clover flex, its a production full function device

0 Likes 0 ·
Show more comments
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated converted comment to answer
The webhook message payload should have that information - https://docs.clover.com/clover-platform/docs/webhooks.
4 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

alexcunn avatar image alexcunn commented ·

The eventID o:<eventID> isn't the orderID sadly. All it gives is the app ID merchant ID and the eventID but the eventID really can't be used for anything on our end unless we're talking to a customer service person,The event ID o:<eventID> isn't the order id

0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ commented ·

Your request is for the line items of the order not the order itself. The id in the webhook response is a valid order, otherwise you wouldn't be getting a response for the line items for that order. My guess is you haven't added/attached line items to the order.

0 Likes 0 ·
alexcunn avatar image alexcunn David Marginian ♦♦ commented ·

The one with the line items in it is a valid order, but you can change the numbers and letters to whatever you want and you would still get

{"elements": [ ], "href": "http://api.clover.com/v3/merchants/D8H10QQYQ5RQ1/orders/SQ2TPE4YQA19R/line_items?limit=100"}
0 Likes 0 ·
David Marginian avatar image David Marginian ♦♦ alexcunn commented ·

Remove line_items from the request. I won't be able to validate the data until next week.

0 Likes 0 ·
alexcunn avatar image
alexcunn answered alexcunn edited
The reason the objectID wasnt adding up was becuase the last webhook it was sending was not pointing to the last order I created but the next future order. I did a log of all the webhooks and the first one was type: UPDATE not CREATE when I created an order.
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

This explanation doesn't make sense. You can't get a webhook create for an order you haven't created.

0 Likes 0 ·
alexcunn avatar image alexcunn David Marginian ♦♦ commented ·

It may not be what it's supposed to, but it's what it's doing.

HTTP headers:
Host: 
Connection: Keep-Alive
Accept-Encoding: gzip
Cf-Ipcountry: NL
X-Forwarded-For: 169.47.192.181
Cf-Ray: 50eb7d0f4fa5d27e-DFW
X-Forwarded-Proto: https
Cf-Visitor: {"scheme":"https"}
X-Clover-Auth: 
Cf-Connecting-Ip: 169.47.192.181
Cdn-Loop: cloudflare


Request body:
{"appId":"H0PBJGMMR89AR","merchants":{"D8H10QQYQ5RQ1":[{"objectId":"O:SQ2TPE4YQA19R","type":"UPDATE","ts":1567217640627}]}}
POST /clvr/hooks.php HTTP/1.1
<br>
0 Likes 0 ·

Welcome to the
Clover Developer Community