Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 903 Bytes

File metadata and controls

32 lines (24 loc) · 903 Bytes

Webhooks

Paychangu uses webhooks to notify your application about payment events. This SDK provides secure validation for incoming webhook requests.


Validating a Webhook Request

use Codelabmw\Paychangu\Support\Webhook;
use Codelabmw\Paychangu\Client;

$client = new Client('YOUR_SECRET_KEY');
$request = Webhook::getCurrentRequest(); // Or any PSR-7 RequestInterface instance
$webhook = new Webhook($client);

if ($webhook->authenticate($request)) {
    // Valid Paychangu webhook
    $payload = json_decode($request->getBody()->getContents(), true);
    // Handle the event
} else {
    http_response_code(401);
    exit('Invalid signature');
}

Tips

  • Always verify the webhook signature before processing.
  • Respond with HTTP 2xx status to acknowledge receipt.
  • See Paychangu API docs for full event types.