# 12. Cancel & Refund

## Cancel & Refund

<mark style="color:green;">`POST`</mark> `{{Private Base Address}}/api/paywall/private/revert`

You should replace the address above with your actual environment URL. You can use a specific 'Base Address' for both test and production environments.

{% hint style="info" %}
**Note:** In order to use the Cancel & Refund service, you must send the parameters **apikeyprivate** and **apiclientprivate** in the Header\
\
[<mark style="color:green;">**PaymentPrivateAPI Address**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

{% hint style="warning" %}
**The Cancel** & **Refund service** checks the date the payment was made after receiving the request and proceeds according to the following flows:

1. If the request was sent on the same day the payment was made, a **cancellation** is processed.
2. If the request was sent on a different day than the payment date, a **refund** is processed.\
   a. If the **Amount** value specified in the request is not zero and differs from the transaction amount, a **partial refund** is processed.
   {% endhint %}

<table><thead><tr><th width="232">Parameter</th><th width="83">Type</th><th width="140.03515625">Compulsory</th><th>Description</th></tr></thead><tbody><tr><td>apikeyprivate</td><td>string</td><td>Yes</td><td>Your Private Key obtained from the merchant panel.</td></tr><tr><td>apiclientprivate</td><td>string</td><td>Yes</td><td>Your Private Client obtained from the merchant panel.</td></tr></tbody></table>

#### Parameters to be sent to the service:

<table><thead><tr><th width="227">Parameter</th><th width="105.33333333333331">Type</th><th width="141.29296875">Compulsory</th><th>Description</th></tr></thead><tbody><tr><td>UniqueCode</td><td>Guid</td><td>Yes</td><td>The UniqueCode returned in the API response after the payment initiation from Paywall. This information must be stored on your side.</td></tr><tr><td>MerchantUniqueCode</td><td>string</td><td>Yes</td><td>This code must match the MerchantUniqueCode in the request used for payment initiation. It is a unique identifier for your transaction. It should be used to trigger and track the transaction in all Cancel/Refund/Query operations.</td></tr><tr><td>Amount</td><td>decimal</td><td>No</td><td>If the Amount parameter is sent as 0, the transaction is processed for the full amount. If an Amount different from the original is sent, the <strong>transaction</strong> is processed as a Partial Refund.</td></tr><tr><td>MarketPlace:DeleteExistingRecords</td><td>bool</td><td>No</td><td>In the context of a marketplace, if the payout approval has been granted for the relevant payment, this parameter must be sent as <strong>true</strong>.<br>If sent as <strong>true</strong>, existing payouts will be deleted after the cancellation request is successfully processed.</td></tr></tbody></table>

{% tabs %}
{% tab title="JSON" %}
{% code overflow="wrap" lineNumbers="true" %}

```json5
{
    "UniqueCode": "1111-1111-1111-1111", // Ödeme sonucunda Paywall'dan dönmektedir
    "MerchantUniqueCode": "ABCD-EFGH-JKLP-MNBV",
    "Amount": 0,
    "MarketPlace": { // nullable
        "DeleteExistingRecords": false
    }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Response from the service:

<table><thead><tr><th width="156">Parameter</th><th width="83.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns a value of '0' if the operation is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns either a true or false value. If the operation is successful, it returns true.</td></tr><tr><td>Message</td><td>string</td><td>If the operation fails, this is the message indicating the error. It provides language support based on the locale parameter.</td></tr></tbody></table>

{% tabs %}
{% tab title="JSON" %}
{% code overflow="wrap" lineNumbers="true" %}

```json5
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "Success",
    "Body": null
}
```

{% endcode %}
{% endtab %}
{% endtabs %}
