Order Webhook triggered twice when order only update once.

in Development
Hi,
We are having issues with order update webhook firing twice with the same payload at a very close timestamp when order status is changed in the backend.
Here's an example from our log:
At Sep 7, 2020 @ 03:49:59.686
--> [POST] http://merkel-api.jmango360.com/webhook/lsd/orderupdate x-b3-parentspanid : 206970bbfe165e03 content-length : 19528 x-b3-sampled : 1 x-forwarded-port : 80 x-cluster-id : eu1 x-format : json x-language : en x-newrelic-id : VgQAUFJUDRACU1NbBgUCUFI= x-forwarded-host : merkel-api.jmango360.com host : merkel-api.jmango360.com content-type : application/json x-b3-flags : 0 x-request-id : 9e68878491c61a409d867130fc37ab98 x-shop-id : 118202 x-forwarded-proto : http x-order-id : 161783487 accept : */* x-real-ip : 35.204.106.164 x-b3-traceid : d71648f95cd462ce x-b3-spanid : b36e20346719594f x-event : orders/updated x-signature : de331d15a7548dd0c66af567c090f402 x-newrelic-transaction : PxRSAgMHDwsEUQNTAAcHUVUFFB8EBw8RVU4aB1tdUAULUQwDAFYFUlMHA0NKQQwAVAJWAQIBFTs= x-scheme : http user-agent : WebshopappApi {"order":{"id":161783487,"createdAt":"2020-09-07T05:38:03+02:00","updatedAt":"2020-09-07T05:49:58+02:00","number":"ORD13101","status":"processing_awaiting_shipment","customStatusId":0,"channel":"api","remoteIp":"35.204.106.164","userAgent":"WebshopappApi","referralId":false,"priceCost":0,"priceExcl":128.73,"priceIncl":141.5,"weight":0,"volume":0,"colli":0,"gender":false,"birthDate":"2020-07-17","nationalId":"","email":"****@jmango360.com","firstname":"jmango","middlename":"","lastname":"360","phone":"124","mobile":"124","newsletterSubscribed":false,"isCompany":true,"companyName":"a","companyCoCNumber":"a","companyVatNumber":"a","addressBillingName":"jmango 360","addressBillingStreet":"2","addressBillingStreet2":"","addressBillingNumber":"2","addressBillingExtension":"","addressBillingZipcode":"10001","addressBillingCity":"2gwyw","addressBillingRegion":"","addressBillingCountry":{"id":150,"code":"nl","code3":"nld","title":"Netherlands, The"},"addressBillingRegionData":false,"addressShippingCompany":false,"addressShippingName":"jmango 360","addressShippingStreet":"2","addressShippingStreet2":"","addressShippingNumber":"2","addressShippingExtension":"","addressShippingZipcode":"10001","addressShippingCity":"2gwyw","addressShippingRegion":"","addressShippingCountry":{"id":150,"code":"nl","code3":"nld","title":"Netherlands, The"},"addressShippingRegionData":false,"paymentId":"banktransfer","paymentStatus":"paid","paymentIsPost":false,"paymentIsInvoiceExternal":false,"paymentTaxRate":0,"paymentTaxRates":[{"name":"VAT","rate":0,"amount":0}],"paymentBasePriceExcl":0.99,"paymentBasePriceIncl":0.99,"paymentPriceExcl":0.99,"paymentPriceIncl":0.99,"paymentTitle":"Advance payment via bank transfer","paymentData":{"method":"banktransfer"},"shipmentId":"postnl|Default","shipmentStatus":"not_shipped","shipmentIsCashOnDelivery":false,"shipmentIsPickup":false,"shipmentTaxRate":0,"shipmentTaxRates":[{"name":"VAT","rate":0,"amount":0}],"shipmentBasePriceExcl":0,"shipmentBasePrice <-- 35 ms [200] 72179fe5-b772-41d3-af58-069988c54ce3 {"error":{"code":0,"message":"order updated","type":0,"parameters":null,"extradata":null},"success":null}
At Sep 7, 2020 @ 03:49:59.698
--> [POST] http://merkel-api.jmango360.com/webhook/lsd/orderupdate x-b3-parentspanid : 3c1a82f64c21fc2e content-length : 19528 x-b3-sampled : 1 x-forwarded-port : 80 x-cluster-id : eu1 x-format : json x-language : en x-newrelic-id : VgQAUFJUDRACU1NbBgUCUFI= x-forwarded-host : merkel-api.jmango360.com host : merkel-api.jmango360.com content-type : application/json x-b3-flags : 0 x-request-id : 2f3abdebc766ad91d7fa11fef64184d1 x-shop-id : 118202 x-forwarded-proto : http x-order-id : 161783487 accept : */* x-real-ip : 35.204.106.164 x-b3-traceid : 4a15fa5988f1afe4 x-b3-spanid : 688adc4289b5b5c4 x-event : orders/updated x-signature : de331d15a7548dd0c66af567c090f402 x-newrelic-transaction : PxRSAgMHDwsEUQNTAAcHUVUFFB8EBw8RVU4aB1tdUAULUQwDAFYFUlMHA0NKQQwAVAJWAQIBFTs= x-scheme : http user-agent : WebshopappApi {"order":{"id":161783487,"createdAt":"2020-09-07T05:38:03+02:00","updatedAt":"2020-09-07T05:49:58+02:00","number":"ORD13101","status":"processing_awaiting_shipment","customStatusId":0,"channel":"api","remoteIp":"35.204.106.164","userAgent":"WebshopappApi","referralId":false,"priceCost":0,"priceExcl":128.73,"priceIncl":141.5,"weight":0,"volume":0,"colli":0,"gender":false,"birthDate":"2020-07-17","nationalId":"","email":"****@jmango360.com","firstname":"jmango","middlename":"","lastname":"360","phone":"124","mobile":"124","newsletterSubscribed":false,"isCompany":true,"companyName":"a","companyCoCNumber":"a","companyVatNumber":"a","addressBillingName":"jmango 360","addressBillingStreet":"2","addressBillingStreet2":"","addressBillingNumber":"2","addressBillingExtension":"","addressBillingZipcode":"10001","addressBillingCity":"2gwyw","addressBillingRegion":"","addressBillingCountry":{"id":150,"code":"nl","code3":"nld","title":"Netherlands, The"},"addressBillingRegionData":false,"addressShippingCompany":false,"addressShippingName":"jmango 360","addressShippingStreet":"2","addressShippingStreet2":"","addressShippingNumber":"2","addressShippingExtension":"","addressShippingZipcode":"10001","addressShippingCity":"2gwyw","addressShippingRegion":"","addressShippingCountry":{"id":150,"code":"nl","code3":"nld","title":"Netherlands, The"},"addressShippingRegionData":false,"paymentId":"banktransfer","paymentStatus":"paid","paymentIsPost":false,"paymentIsInvoiceExternal":false,"paymentTaxRate":0,"paymentTaxRates":[{"name":"VAT","rate":0,"amount":0}],"paymentBasePriceExcl":0.99,"paymentBasePriceIncl":0.99,"paymentPriceExcl":0.99,"paymentPriceIncl":0.99,"paymentTitle":"Advance payment via bank transfer","paymentData":{"method":"banktransfer"},"shipmentId":"postnl|Default","shipmentStatus":"not_shipped","shipmentIsCashOnDelivery":false,"shipmentIsPickup":false,"shipmentTaxRate":0,"shipmentTaxRates":[{"name":"VAT","rate":0,"amount":0}],"shipmentBasePriceExcl":0,"shipmentBasePrice <-- 26 ms [200] 84fa093c-eb87-444f-81ea-e8f0bbfde1b8 {"error":{"code":0,"message":"order updated","type":0,"parameters":null,"extradata":null},"success":null}
As you can see above, the time different is only 12ms. We only expect 1 webhook callback here, as order is only changed in status once.
This only happen sometimes. When I checked our webhook list through webhook API, we only registered 1 webhook to https://merkel-api.jmango360.com/webhook/lsd/orderupdate
Here's our webhook.
{ "id": 3948003, "createdAt": "2020-09-07T05:39:33+02:00", "updatedAt": "2020-09-07T05:39:33+02:00", "isActive": true, "itemGroup": "orders", "itemAction": "*", "language": { "id": 3, "code": "en", "locale": "en_GB", "title": "English" }, "format": "json", "address": "https://merkel-api.jmango360.com/webhook/lsd/orderupdate" }
Can somebody tell me what's happening in this case?
Thank you.
1 comment
Hey @Kein,
Our webhooks guarantee at least once delivery, so you'll need to check if you've already received the message from us.
I might recommend stringifying it and base64 encoding it and comparing it to a "previously received" webhook table in your database.
That way you'll know if you've already received the message. The id will the same for duplicate messages.
Kind Regards,
Adrian Samuel
Software Developer
Lightspeed HQ