Giving the following code:
@PostMapping(value = "/wc-order")
public void getWcOrder(@RequestBody Order order, @RequestHeader Map<String, String> headers, @RequestBody String plainJsonBody){
String webhookSignature = headers.get("x-wc-webhook-signature");
String hashedBody = doHMAC(plainJsonBody);
if (hashedBody.equals(webhookSignature)) {
// all good
}
}
The JSON body will successfully be mapped to the Order object.
Furthermore I would like to have the JSON body as well as a string to finally hash it and compare with the signature. Unfortunately I don't know how to extract plain body without loosing the capability to map it to order Object.
Is there a simple way to achieve it?
I've tried as in How to access plain json body in Spring rest controller?
But here I loose the capability of the deserialization to the Order object.