Skip to main content
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.
Always verify the webhook signature before trusting the payload or updating order state. Skipping verification opens your endpoint to spoofed events.

Methods

Webhook::constructEvent()

Verifies the signature and returns the decoded JSON payload as an associative array. This is the recommended method for production webhook handlers — it throws an 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

  • ApiException with status 401 if the signature does not match.
  • ApiException with status 400 if the payload is not valid JSON.

Example


Webhook::verify()

Verifies the webhook signature and returns 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.

Webhook payload reference

Below is a representative payload sent by Taliup after a payment is captured: