Taliup\Sdk\Webhook is a static utility class for verifying Taliup webhook signatures. After a payment is captured, Taliup sends a POST request to your webhook_url with a JSON body and an X-Taliup-Signature header. You must verify this signature before processing the event.
The signature is computed as sha256=<HMAC-SHA256> of the raw request body, signed with your merchant_secret_key.
Methods
Webhook::constructEvent()
ApiException on failure so you can respond with an appropriate HTTP status code.
Parameters
string
required
The raw request body. Read it with
file_get_contents('php://input') before any framework middleware parses it.string
required
The value of the
X-Taliup-Signature HTTP header sent with the webhook request.string
required
Your Merchant Secret Key. This is the same key you pass to the
Client as merchant_secret_key.Returns
An associative array containing the decoded webhook event payload.Throws
ApiExceptionwith status401if the signature does not match.ApiExceptionwith status400if the payload is not valid JSON.
Example
Webhook::verify()
true if valid, false otherwise. Unlike constructEvent(), this method never throws — it is well-suited for middleware guards or situations where you want to handle the failure yourself.
Parameters
string
required
The raw request body. Read it with
file_get_contents('php://input').string
required
The value of the
X-Taliup-Signature HTTP header.string
required
Your Merchant Secret Key.
Returns
true if the HMAC-SHA256 signature matches; false otherwise. Also returns false if any argument is an empty string.
Example
constructEvent vs verify — Use constructEvent() in most webhook handlers: it verifies the signature, decodes the JSON, and surfaces errors as typed exceptions that map directly to HTTP status codes. Use verify() only when you need a simple boolean gate and want to control decoding and error handling yourself.