# Events

## Overview

PaySG generates event data that you can use to inform you of activity on your payment service. When an event occurs, PaySG generates a new [Event object](#event-object). For example, when a payer pays on PaySG, you receive `payment.succeeded` event.

By registering webhook endpoints in your payment service, you enable PaySG to automatically send [Event objects](#event-object) as part of **POST** requests to the registered webhook endpoint hosted by your application.&#x20;

#### Event Object

The Event object we send to your webhook endpoint provides a snapshot of the object that changed.

Currently, we only support the `payment.succeeded` event type.

#### Example event payload

{% code overflow="wrap" %}

```json
{
  "id": "evt_752ced1f-00ce-4905-8c46-367371dd78e6",
  "data": {
    "object": {
      "id": "wLAnFWQLYyYNKBimc2ZkA",
      "due_date": null,
      "metadata": {},
      "payout_id": null,
      "created_at": "2023-07-17T17:15:12.200+08:00",
      "creator_id": "user_655d26a2-ddfc-4718-a008-bd181c1522e8",
      "payer_name": "John Doe",
      "updated_at": "2023-10-02T16:17:08.167+08:00",
      "payer_email": "abc@gmail.com",
      "payment_url": "http://pay.gov.sg/payments/payment01",
      "description": "Payment for XXX",
      "reference_id": "INV001",
      "latest_status": "paid",
      "payer_address": "36 Robinson Road, Singapore 068877",
      "refund_status": "not_refunded",
      "amount_in_cents": 12.34,
      "payment_status": "paid",
      "payer_identifier": "S1234567A",
      "paid_out_timestamp": null,
      "payment_service_id": "payment_service_fd724c82-786b-43ba-b7d7-1eecab0388e1",
      "email_delivery_status": "sent",
      "payment_sent_timestamp": "2023-07-31T10:01:48.761+08:00",
      "stripe_payment_intentId": "pi_3NUnWOLRKRlnGcim1Nzy18Z0",
      "payment_cancelled_timestamp": null,
      "payment_succeeded_timestamp": "2023-10-02T16:17:08.164+08:00",
      "payment_fully_refunded_timestamp": null
    }
  },
  "type": "payment.succeeded",
  "object": "event",
  "created_at": "2023-10-02T16:17:08.210+08:00",
  "payment_service_id": "payment_service_fd724c82-786b-43ba-b7d7-1eecab0388e1"
}
```

{% endcode %}

#### Why event object gets generated

This table describes different scenarios that trigger generating events.

<table><thead><tr><th width="370">Source</th><th>Trigger</th></tr></thead><tbody><tr><td>PaySG platform</td><td>When a user action (i.e. pays) in the PaySG platform results in an API call</td></tr></tbody></table>

## Event delivery behaviours

This section provides documentation on the different behaviors that you can expect when PaySG sends events to your webhook endpoint. Specifically, it covers event retry deliveries and event ordering.

#### Retry behaviour

PaySG attempts to deliver an event to your webhook endpoint for up to 3 days with an exponential back off.&#x20;

If your endpoint has been deleted when PaySG attempts a retry, future retries of that event will be prevented.

#### Event ordering

PaySG doesn’t guarantee delivery of events in the order in which they’re generated.

Your endpoint should not expect delivery of events in order, and needs to handle out-of-order delivery accordingly.
