Webhooks allow you to build or set up integrations that subscribe to certain events on Razorpay APIs. When one of those events is triggered, we send an HTTP POST payload in JSON to the webhook's configured URL.
Set Up Webhooks #
To setup webhooks:
Log into your Razorpay Dashboard and navigate to Settings → Webhooks.
Click Setup Webhook.
Enter the following details:
Enter the Website URL where you want to receive the webhook payload when an event is triggered.
Enter a Secret for the webhook endpoint. The secret is used for validation purposes.
Note:
The secret that you enter here can be used to validate that the webhook is from Razorpay. Do not expose the secret publicly.
Select the required events from the list of Active Events .
Click Save to enable webhooks.
Set Up Webhooks #
To setup webhooks:
Log into your Razorpay Dashboard and navigate to Settings → Webhooks.
Click Setup Webhook.
Enter the following details:
Enter the Website URL where you want to receive the webhook payload when an event is triggered.
Enter a Secret for the webhook endpoint. The secret is used for validation purposes.
Note:
The secret that you enter here can be used to validate that the webhook is from Razorpay. Do not expose the secret publicly.
Select the required events from the list of Active Events .
Click Save to enable webhooks.
public function webhooks()
{
echo "Razorpay";
$dataBody = file_get_contents('php://input');
if($dataBody){
$data = json_decode(file_get_contents('php://input'), true);
$headers = apache_request_headers();
$stringHeaders= json_encode($headers);
$webhookHeaders = $stringHeaders;
$webhookData=array(
"webhook_body" => $dataBody,
"webhook_headers" => $webhookHeaders,
"whDate" => date('Y-m-d H:i:s'),
);
$this->Mdl_razorpay->_insert($webhookData,"rp_webhooks");
}
}
In Model :-
class Mdl_razorpay extends CI_Model {
function __construct() {
parent::__construct();
}
function _insert($data,$table)
{
$this->db->insert($table,$data);
return 1;
}
}
