> For the complete documentation index, see [llms.txt](https://docs.hyperswitch.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperswitch.io/integrations/prism/api-reference/event-service/handle.md). Agents can also search and read this documentation through its [MCP server](https://docs.hyperswitch.io/~gitbook/mcp).

# Handle

## Overview

The `Handle` RPC processes raw webhook payloads from payment processors. It verifies webhook signatures, parses the event data, and returns a normalized response with the event type and associated payment/refund/dispute details.

**Business Use Case:** When payment processors send webhook notifications to your endpoint, you need to verify they're authentic, understand what happened, and update your system accordingly. This RPC handles the verification and parsing so you can focus on business logic.

## Purpose

**Why use the Event Service for webhooks?**

| Challenge                      | How Handle RPC Helps                                                 |
| ------------------------------ | -------------------------------------------------------------------- |
| **Signature verification**     | Automatically verifies webhook authenticity using connector secrets  |
| **Multiple connector formats** | Normalizes Stripe, Adyen, PayPal events into consistent format       |
| **Event parsing**              | Extracts payment/refund/dispute IDs and status from complex payloads |
| **Security**                   | Validates webhook secrets before processing                          |

**Key outcomes:**

* Verified webhook authenticity
* Normalized event structure
* Extracted entity details (payment, refund, dispute)
* Ready-to-process event data

## Request Fields

| Field               | Type           | Required | Description                                       |
| ------------------- | -------------- | -------- | ------------------------------------------------- |
| `merchant_event_id` | string         | Yes      | Your unique event reference for idempotency       |
| `request_details`   | RequestDetails | Yes      | HTTP request details including headers, body, URL |
| `webhook_secrets`   | WebhookSecrets | No       | Secrets for verifying webhook signatures          |
| `state`             | ConnectorState | No       | State from previous webhook processing            |

### RequestDetails Fields

| Field     | Type                | Required | Description                              |
| --------- | ------------------- | -------- | ---------------------------------------- |
| `method`  | string              | Yes      | HTTP method (e.g., "POST")               |
| `url`     | string              | Yes      | Full webhook URL                         |
| `headers` | map\<string,string> | Yes      | HTTP headers including signature headers |
| `body`    | bytes               | Yes      | Raw webhook payload                      |

### WebhookSecrets Fields

| Field    | Type         | Required | Description                                     |
| -------- | ------------ | -------- | ----------------------------------------------- |
| `secret` | SecretString | No       | Webhook signing secret from connector dashboard |

## Response Fields

| Field               | Type               | Description                                                                       |
| ------------------- | ------------------ | --------------------------------------------------------------------------------- |
| `event_type`        | WebhookEventType   | Type of event: PAYMENT\_INTENT\_SUCCESS, CHARGE\_REFUNDED, DISPUTE\_CREATED, etc. |
| `event_response`    | EventResponse      | Event content with payment/refund/dispute details                                 |
| `source_verified`   | bool               | Whether webhook signature was verified                                            |
| `merchant_event_id` | string             | Your event reference (echoed back)                                                |
| `event_status`      | WebhookEventStatus | Processing status: COMPLETE, INCOMPLETE                                           |

### EventResponse Content

The `event_response` contains one of the following based on `event_type`:

| Field               | Type                      | Present When           |
| ------------------- | ------------------------- | ---------------------- |
| `payments_response` | PaymentServiceGetResponse | Payment-related events |
| `refunds_response`  | RefundResponse            | Refund-related events  |
| `disputes_response` | DisputeResponse           | Dispute-related events |

## Example

### Request (grpcurl)

```bash
grpcurl -H "x-connector: stripe" \
  -H "x-connector-config: {\"config\":{\"Stripe\":{\"api_key\":\"$STRIPE_API_KEY\"}}}" \
  -d '{
    "merchant_event_id": "evt_webhook_001",
    "request_details": {
      "method": "POST",
      "url": "https://your-app.com/webhooks/stripe",
      "headers": {
        "stripe-signature": "t=1234567890,v1=abc123...",
        "content-type": "application/json"
      },
      "body": "ewogICJpZCI6ICJldF8xT..."
    },
    "webhook_secrets": {
      "secret": "whsec_your_webhook_secret"
    }
  }' \
  localhost:8080 \
  types.EventService/Handle
```

### Response

```json
{
  "event_type": "PAYMENT_INTENT_SUCCESS",
  "event_response": {
    "payments_response": {
      "connector_transaction_id": "pi_3Oxxx...",
      "status": "CAPTURED",
      "status_code": 200
    }
  },
  "source_verified": true,
  "event_status": "WEBHOOK_EVENT_STATUS_COMPLETE"
}
```

## Next Steps

* [Payment Service](https://docs.hyperswitch.io/integrations/prism/api-reference/payment-service.md) - Process payment events
* [Refund Service](https://docs.hyperswitch.io/integrations/prism/api-reference/refund-service.md) - Process refund events
* [Dispute Service](https://docs.hyperswitch.io/integrations/prism/api-reference/dispute-service.md) - Process dispute events


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hyperswitch.io/integrations/prism/api-reference/event-service/handle.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
