> For the complete documentation index, see [llms.txt](https://developer.paywall.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.paywall.one/payment-orchestration-integration-document/payment-service/12.-cancel-and-refund/1.-payment-id.md).

# 1. Payment ID

## **Cancellation & Refund**

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

It is sufficient to send a request to the address provided above. You can use the **"Base Address"** as needed for both the test and live environments.

{% hint style="info" %}
**Important:** In order to use the Cancellation & Refund with Payment ID service, you must send the **'apikeyprivate'** and **'apiclientprivate'** parameters in the **Header** field.\
\
[<mark style="color:green;">**PaymentPrivateAPI Address**</mark>](/payment-orchestration-integration-document/environment.md)
{% endhint %}

{% hint style="warning" %}
After receiving the request, the Cancellation & Refund service checks the day the payment was made and applies the appropriate flow below:

1. If the request is sent on the same day the payment was made, a cancellation will be performed.
2. If the request is sent after the day the payment was made, a refund will be performed.
   1. If the **Amount** specified in the request is not zero and differs from the transaction amount, a partial refund will be performed.
      {% endhint %}

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

#### The parameters to be sent to the service are as follows:

<table><thead><tr><th width="169.40625">Parameter</th><th width="105.33333333333331">Type</th><th width="156.58203125">Compulsory</th><th>Description</th></tr></thead><tbody><tr><td>PaymentId</td><td>int</td><td>Yes</td><td>In the API response returned by Paywall after the payment initiation, the corresponding <strong>PaymentId</strong> of the transaction in Paywall is included. This information should be stored on your side.</td></tr><tr><td>Amount</td><td>decimal</td><td>No</td><td>If the <strong>Amount</strong> parameter is sent as <strong>0</strong>, the transaction will be processed based on the full amount. If the <strong>Amount</strong> value differs from the existing transaction amount, it will be processed as a <strong>partial refund</strong>.</td></tr><tr><td>MarketPlace:DeleteExistingRecords</td><td>bool</td><td>No</td><td>Within the scope of the marketplace, if the earnings approval for the relevant payment is granted, this parameter must be sent as <strong>true</strong>. When sent as <strong>true</strong>, existing earnings will be deleted after the cancellation request is successfully completed.</td></tr></tbody></table>

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

```json5
{
    "PaymentId": 9474444843, // Ödeme sonucunda Paywall'dan dönmektedir
    "Amount": 0,
    "MarketPlace": { // nullable
        "DeleteExistingRecords": false
    }
}
```

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

**Response returned 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 <strong>“0”</strong> if the operation is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns a true or false value. Returns <strong>“true”</strong> if the operation is successful.</td></tr><tr><td>Message</td><td>string</td><td>If the operation fails, this is the message describing 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 %}
