# Event: transaction_refund:status_changed

The `transaction_refund:status_changed` event serves to inform your application about changes in the refund processing path for a customer.

Since refunds in banking systems are processed asynchronously, you do not receive confirmation of a successful refund immediately in the API response. Instead, your system learns about the final result of the operation from this IPN notification.

## When Is This Event Sent?

This notification is triggered every time a refund order changes its status in the SimPay system. You will receive it in particular when:

* The refund is successfully processed and funds are sent to the customer (change to `refund_completed` status).
* The refund order is rejected, e.g., due to insufficient balance in your SimPay account or a too old transaction (change to `refund_rejected` or `refund_failed`).


## `data` Object Structure

When the `type` field in the main notification object has the value `transaction_refund:status_changed`, the `data` object will contain the following information:

| Field | Type | Description | Example Value |
|  --- | --- | --- | --- |
| `id` | `UUID` | Refund ID in the SimPay system | `0194837c-69df-71dd-adff-4b3058f3fb58` |
| `service_id` | `char(8)` | Service identifier (in SimPay Flow - parent service ID) | `e65c7519` |
| `status` | `RefundStatusEnum` | Current [refund status](/payment/statuses#statusGroup=Refund+Statuses) (e.g., `refund_completed`) | `refund_completed` |
| `amount` | `object` | Amount information object |  |
| `amount.currency` | `ISO 4217` | Currency in which the refund was ordered | `PLN` |
| `amount.value` | `string` (%.2f) | Amount ordered in the refund | `8.47` |
| `amount.wallet_currency` | `ISO 4217` | Currency of the wallet from which funds were taken for the refund | `EUR` |
| `amount.wallet_value` | `string` (%.2f) | Amount ultimately taken from the wallet (balance) | `2.00` |
| `transaction` | `object` | Information about the transaction this refund relates to |  |
| `transaction.id` | `UUID` | Original SimPay transaction ID | `00554475-7ebb-4f16-b30b-0ce21da1a03b` |
| `transaction.payment_channel` | `string` | Payment channel used by the payer | `blik` |
| `transaction.payment_type` | `string` | Type/group of payment method | `blik` |
| `flow` | `object` or absent | Only for [SimPay Flow](/simpay-flow/webhooks#payment-webhooks-ipn-in-simpay-flow) submerchants |  |
| `flow.submerchant_id` | `string` | Submerchant ID | `flsm_aaaabbbb` |
| `flow.submerchant_custom_id` | `string` | Submerchant `customId` | `user-123` |
| `flow.flow_service_id` | `string` | Flow service ID | `flow_aaaabbbb` |


Tip
When you receive this notification, check the `status` field. If it has the value **`refund_completed`**, it means the money has been sent to the customer – at this point you should mark the refund in your accounting/e-commerce system as completed and optionally send the customer a notification email.

## Example JSON Payload

Below is a complete dump (payload) of the notification sent for the `transaction_refund:status_changed` event.

*(The example signature was generated using the IPN key: **`UwSkKiIwlxIeOMF8MIq9iDkQWBTtjoJQ`**. You can use this key and the data below to test your validation algorithm).*

```json
{
  "type": "transaction_refund:status_changed",
  "notification_id": "0196ff00-376d-7399-a457-d166c9adf073",
  "date": "2025-05-23T23:15:26+02:00",
  "data": {
    "id": "0194837c-69df-71dd-adff-4b3058f3fb58",
    "service_id": "e65c7519",
    "status": "refund_completed",
    "amount": {
      "currency": "PLN",
      "value": "1.00",
      "wallet_currency": "PLN",
      "wallet_value": "1.00"
    },
    "transaction": {
      "id": "e568d9ba-a85a-444c-87c4-3b1e431428d1",
      "payment_channel": "paysafecard",
      "payment_type": "paysafe"
    }
  },
  "signature": "835819c5720c74f01b8d10a58b2dc43185f05379ea26f25a15158061f3bce10c"
}
```

See signature calculation
1. Flatten all elements sequentially + `|` separation:


Our string will look like this:

```
transaction_refund:status_changed|0196ff00-376d-7399-a457-d166c9adf073|2025-05-23T23:15:26+02:00|0194837c-69df-71dd-adff-4b3058f3fb58|e65c7519|refund_completed|PLN|1.00|PLN|1.00|e568d9ba-a85a-444c-87c4-3b1e431428d1|paysafecard|paysafe
```

1. Append the IPN key at the end of the string:
`...|UwSkKiIwlxIeOMF8MIq9iDkQWBTtjoJQ`
2. Calculate SHA256 from the above string and encode it in hex:


```php
<?php

$signature = hash('sha256', 'transaction_refund:status_changed|0196ff00-376d-7399-a457-d166c9adf073|2025-05-23T23:15:26+02:00|0194837c-69df-71dd-adff-4b3058f3fb58|e65c7519|refund_completed|PLN|1.00|PLN|1.00|e568d9ba-a85a-444c-87c4-3b1e431428d1|paysafecard|paysafe|UwSkKiIwlxIeOMF8MIq9iDkQWBTtjoJQ');
```

1. Compare using a secure comparison function (e.g., `hash_equals` in PHP) the calculated signature with the one sent in the `signature` field of the notification. In this case, the hashing result will be `835819c5720c74f01b8d10a58b2dc43185f05379ea26f25a15158061f3bce10c`.