# Refunds & Cancelations

BreathePay processes payments as midnight each night, therefore if payments have been made on the same day (and have not yet been processed), you must cancel them. If payments were made before midnight that day, they will have been processed and therefore you can use the refund method to return money to your customers.

{% hint style="warning" %}
**ALWAYS** validate the signature in the response object using the function written in the Handling API Responses page
{% endhint %}

**Canceling a same-day request:**&#x20;

Using the code we stated in the Backend Code page, here is an example refund function which can be copied into your project: \\

```php
//PHP
public function cancel() {
   $data = [
      'merchantID' => YOUR_MERCHANT_ID,
      'action' => 'CANCEL',
      'xref' => TRANSACTION_XREF //stored from the charge function
   ];

   $data['signature'] = $this->createBreathepaySignature($data, YOUR_MERCHANT_SECRET);

   return $this->sendRequest($data);
 }
```

**Refunding a request made before this day:**

```php
//PHP
public function fullOrPartialRefund() {
   $data = [
      'merchantID' => YOUR_MERCHANT_ID,
      'action' => 'REFUND_SALE',
      'amount' => AMOUNT_TO_REFUND, //In pence, £1 = 100 (maximum is amount of transaction)
      'xref' => TRANSACTION_XREF //stored from the charge function
   ];

   $data['signature'] = $this->createBreathepaySignature($data, YOUR_MERCHANT_SECRET);

   return $this->sendRequest($data);
 }
```
