import com.fyatu.webhook.Webhook;
import com.fyatu.webhook.WebhookEvent;
// Spring Boot controller example
@RestController
public class WebhookController {
@PostMapping("/webhooks/fyatu")
public ResponseEntity<String> handleWebhook(
@RequestBody String payload,
@RequestHeader("X-Fyatu-Signature") String signature
) {
boolean valid = Webhook.verifySignature(
payload,
signature,
"your_webhook_secret"
);
if (!valid) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.body("Invalid signature");
}
WebhookEvent event = Webhook.parseEvent(payload);
System.out.println("Received event: " + event.getType());
return ResponseEntity.ok("OK");
}
}