> 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/9.-refund/2.-paywall-transaction-id.md).

# 2. Paywall Transaction ID

## Refund with Paywall Transaction ID

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

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 Refund with Paywall Transaction 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 %}

<table><thead><tr><th width="182">Parameter</th><th width="108.66536458333331">Type</th><th width="97">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>

#### Servise gönderilmesi gereken parametreler şu şekildedir:

<table><thead><tr><th width="215">Parameter</th><th width="120.53125">Type</th><th width="156.66015625">Compulsory</th><th>Description</th></tr></thead><tbody><tr><td>Date</td><td>date</td><td>Yes</td><td>The date when the payment was made.</td></tr><tr><td>UniqueCode</td><td>Guid</td><td>Yes</td><td>This is the value contained in the <code>UniqueCode</code> parameter within the response object returned by Paywall after the payment initiation.</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 true. When sent as true, existing earnings will be deleted after the cancellation request is successfully completed.</td></tr><tr><td>CompletePartialRefund</td><td>bool</td><td>No</td><td>If a partial refund has already been made for the relevant payment, the refunded amount is deducted from the main amount, and the refund process is completed with another partial refund request for the remaining amount.</td></tr></tbody></table>

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

```json5
{
    "Date": "2023-02-07",
    "UniqueCode": "0000-0000-0000-0000-0000",
    "CompletePartialRefund": false,
    "MarketPlace": { // nullable
        "DeleteExistingRecords": false
    }
}
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class Program
{
    private static readonly HttpClient client = new HttpClient();

    private static async Task Main()
    {
        var data = new 
        {
            Date = "2023-02-07",
            MerchantUniqueCode = "AA90T0SD0ASF99"
        };
        var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
        content.Headers.Add("apikeyprivate", "%PRIVATEKEY%");
        content.Headers.Add("apiclientprivate", "%PRIVATECLIENT%");

        var response = await client.PostAsync("{{Private Base Address}}/api/paywall/private/refund", content);

        var responseString = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseString);
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

import (
    "bytes"
    "fmt"
    "io/ioutil"
    "net/http"
    "encoding/json"
)

func main() {
    url := "{{Private Base Address}}/api/paywall/private/refund"
    data := map[string]string{
        "Date": "2023-02-07",
        "MerchantUniqueCode": "AA90T0SD0ASF99",
    }
    reqBody, _ := json.Marshal(data)
    
    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(reqBody))
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("apikeyprivate", "%PRIVATEKEY%")
    req.Header.Set("apiclientprivate", "%PRIVATECLIENT%")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.HashMap;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        Map<String, String> values = new HashMap<String, String>() {{
            put("Date", "2023-02-07");
            put("MerchantUniqueCode", "AA90T0SD0ASF99");
        }};

        String requestBody = new ObjectMapper().writeValueAsString(values);

        HttpRequest request = HttpRequest.newBuilder()
                .uri(new URI("{{Private Base Address}}/api/paywall/private/refund"))
                .setHeader("Content-Type", "application/json")
                .setHeader("apikeyprivate", "%PRIVATEKEY%")
                .setHeader("apiclientprivate", "%PRIVATECLIENT%")
                .POST(HttpRequest.BodyPublishers.ofString(requestBody))
                .build();

        HttpResponse<String> response = client.send(request, BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = '{{Private Base Address}}/api/paywall/private/refund';
$data = array(
    "Date" => "2023-02-07",
    "MerchantUniqueCode" => "AA90T0SD0ASF99",
);
$options = array(
    'http' => array(
        'header'  => "Content-type: application/json\r\n" .
                     "apikeyprivate: %PRIVATEKEY%\r\n" . 
                     "apiclientprivate: %PRIVATECLIENT%\r\n",
        'method'  => 'POST',
        'content' => json_encode($data),
    ),
);
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

// Decode
$response = json_decode($result);

// ErrorCode-Result-Message
echo "ErrorCode: " . $response->ErrorCode . "\n";
echo "Result: " . ($response->Result ? "true" : "false") . "\n";
echo "Message: " . $response->Message . "\n";
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = '{{Private Base Address}}/api/paywall/private/refund'
headers = {
    'Content-Type': 'application/json',
    'apikeyprivate': '%PRIVATEKEY%',
    'apiclientprivate': '%PRIVATECLIENT%',
}
data = {
    "Date": "2023-02-07",
    "MerchantUniqueCode": "AA90T0SD0ASF99",
}
response = requests.post(url, headers=headers, data=json.dumps(data))

response_data = response.json()

print('ErrorCode:', response_data['ErrorCode'])
print('Result:', response_data['Result'])
print('Message:', response_data['Message'])
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("{{Private Base Address}}/api/paywall/private/refund")
http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Post.new(uri.request_uri, {
    'Content-Type' => 'application/json',
    'apikeyprivate' => '%PRIVATEKEY%',
    'apiclientprivate' => '%PRIVATECLIENT%'
})
request.body = {Date: "2023-02-07", MerchantUniqueCode: "AA90T0SD0ASF99"}.to_json

response = http.request(request)

puts response.body
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
const axios = require('axios');

const data = {
    Date: "2023-02-07",
    MerchantUniqueCode: "AA90T0SD0ASF99"
};

axios.post('{{Private Base Address}}/api/paywall/private/refund', data, {
    headers: {
        'Content-Type': 'application/json',
        'apikeyprivate': '%PRIVATEKEY%',
        'apiclientprivate': '%PRIVATECLIENT%',
    }
})
.then((response) => {
    console.log(response.data);
})
.catch((error) => {
    console.error(error);
});
```

{% endtab %}

{% tab title="Curl" %}

```sh
curl -X POST "{{Private Base Address}}/api/paywall/private/refund" \
-H "Content-Type: application/json" \
-H "apikeyprivate: %PRIVATEKEY%" \
-H "apiclientprivate: %PRIVATECLIENT%" \
-d '{
    "Date": "2023-02-07",
    "MerchantUniqueCode": "AA90T0SD0ASF99"
}'
```

{% 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>Body</td><td>object</td><td>Optional JSON containing payment details.</td></tr><tr><td>ErrorCode</td><td>int</td><td>Error code. Returns “0” if the operation is successful.</td></tr><tr><td>Result</td><td>bool</td><td>Returns a true or false value. Returns “true” 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 %}
