Class WebhookVerifier

java.lang.Object
com.chargebee.v4.webhook.WebhookVerifier

public class WebhookVerifier extends Object
Utility class for verifying Chargebee webhook requests using HTTP Basic Authentication.

Chargebee supports optional HTTP Basic Authentication for webhooks. When configured, Chargebee sends the username and password in the Authorization header as Base64-encoded credentials.

To enable webhook authentication in Chargebee:

  1. Go to Settings → Configure Chargebee → Webhooks
  2. Edit your webhook endpoint
  3. Enable "Basic Authentication" and set username/password

Usage example:

 WebhookVerifier verifier = new WebhookVerifier();
 boolean isValid = verifier.verifyBasicAuth(
     authorizationHeader,
     expectedUsername,
     expectedPassword
 );
 
See Also:
  • Constructor Details

    • WebhookVerifier

      public WebhookVerifier()
  • Method Details

    • verifyBasicAuth

      public boolean verifyBasicAuth(String authorizationHeader, String expectedUsername, String expectedPassword)
      Verifies the webhook request using HTTP Basic Authentication.

      Chargebee sends credentials in the Authorization header as: "Basic base64(username:password)"

      Parameters:
      authorizationHeader - The Authorization header value from the request
      expectedUsername - The expected username configured in Chargebee
      expectedPassword - The expected password configured in Chargebee
      Returns:
      true if credentials match, false otherwise
    • extractUsername

      public String extractUsername(String authorizationHeader)
      Extracts username from the Authorization header.
      Parameters:
      authorizationHeader - The Authorization header value
      Returns:
      The username, or null if extraction fails