Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.75 KB

Webhook.md

File metadata and controls

61 lines (45 loc) · 1.75 KB

Webhook

PGVerifyWebhookSignature

PGVerifyWebhookSignature(signature string, rawBody string, timestamp string) (*PGWebhookEvent, error)

Verify Webhook Signatures (Docs

Example

// Route
e.POST("/webhook", _this.Webhook)

// Controller
func (_this *WebhookRoute) Webhook(c echo.Context) error {
    signature := c.Request().Header.Get("x-webhook-signature")
    timestamp := c.Request().Header.Get("x-webhook-timestamp")
    
    body, _ := ioutil.ReadAll(c.Request().Body)
    rawBody := string(body)
    webhookEvent, err := cashfree.PGVerifyWebhookSignature(signature, rawBody, timestamp)
    if err != nil {
		fmt.Println(err.Error())
	} else {
		fmt.Println(webhookEvent.Object)
	}
}

Parameters

Name Type Description Notes
signature string The "x-webhook-signature" present in the headers received
rawBody string The request body received in the request in string format
timestamp string The "x-webhook-timestamp" present in the headers received

Response

{
    "type": "PAYMENT_SUCCESS_WEBHOOK",
    "rawBody":"{\"type\":\"PAYMENT_SUCCESS_WEBHOOK\",\"data\":{}}",
    "object": {
        "type": "PAYMENT_SUCCESS_WEBHOOK",
        "data": {
            
        }
    }
}

Note: The object in the response is returned as a JSON object. But it can be of any of the following types: