# 6. Provizyon İptal

## Provizyon İptal

<mark style="color:green;">`POST`</mark> `{{Base Adres}}/api/paywall/payment/provision/cancel`

Yukarıda verilmiş olan adrese istek atmanız yeterli olacaktır. Test ortamı ve Gerçek ortam için 'Base Address' istediğiniz gibi kullanabilirsiniz.

{% hint style="info" %}
Önemli: **Provizyon İptal** servisini kullanabilmeniz için 'Header' alanında '**apikeypublic**' ve '**apiclientpublic**' parametrelerini göndermeniz gerekmektedir.\
\
[<mark style="color:green;">**PaymentAPI Adresi**</mark>](https://developer.paywall.one/ortam)
{% endhint %}

<table><thead><tr><th width="162">Parametre</th><th width="79">Tip</th><th width="107">Zorunlu</th><th width="403">Açıklama</th></tr></thead><tbody><tr><td>apikeypublic</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Public Key.</td></tr><tr><td>apiclientpublic</td><td>string</td><td>Evet</td><td>Üye işyeri panelinden temin etmiş olduğunuz Public Client.</td></tr></tbody></table>

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

<table><thead><tr><th width="226">Parametre</th><th width="91">Tip</th><th width="93">Zorunlu</th><th>Açıklama</th></tr></thead><tbody><tr><td>MerchantUniqueCode</td><td>string</td><td>Evet </td><td>Ödeme başlatma için gönderilen istek içerisindeki MerchantUniqueCode ile aynı değer olmalıdır. Bu kod sizin tarafınızdan işleme ait verilen tekil değerdir. İptal/İade/Ödeme Sorgulama işlemlerinin hepsinde bir ödemeyi tekilleştirmeniz ve takip etmeniz için kullanılmaktadır.</td></tr><tr><td>Date</td><td>date</td><td>Evet</td><td>Ödeme'nin gerçekleştiği tarih bilgisi</td></tr></tbody></table>

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

```json5
{
    "Date": "2024-06-13",
    "MerchantUniqueCode": "aaa"
}
```

{% 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(string[] args)
    {
        var data = new
        {
            MerchantUniqueCode = "aaa"
        };

        client.DefaultRequestHeaders.Add("apikeypublic", "%PUBLICKEY%");
        client.DefaultRequestHeaders.Add("apiclientpublic", "%PUBLICCLIENT%");

        var content = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
        var response = await client.PostAsync("{{Base Adres}}/api/paywall/payment/end3d", content);

        var responseString = await response.Content.ReadAsStringAsync();
        var responseObject = JsonConvert.DeserializeObject<Response>(responseString);

        Console.WriteLine("ErrorCode: " + responseObject.ErrorCode);
        Console.WriteLine("Result: " + responseObject.Result);
        Console.WriteLine("Message: " + responseObject.Message);
    }

    public class Response
    {
        public int ErrorCode { get; set; }
        public bool Result { get; set; }
        public string Message { get; set; }
        public string Body { get; set; }
    }
}
```

{% endtab %}

{% tab title="GO" %}

```go
package main

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

type Response struct {
	ErrorCode int
	Result    bool
	Message   string
	Body      string
}

type Request struct {
	MerchantUniqueCode string `json:"MerchantUniqueCode"`
}

func main() {
	url := "{{Base Adres}}/api/paywall/payment/end3d"
	reqBody := &Request{
		MerchantUniqueCode: "aaa",
	}

	reqBodyBytes := new(bytes.Buffer)
	json.NewEncoder(reqBodyBytes).Encode(reqBody)

	req, _ := http.NewRequest("POST", url, reqBodyBytes)

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("apikeypublic", "%PUBLICKEY%")
	req.Header.Set("apiclientpublic", "%PUBLICCLIENT%")

	client := &http.Client{}
	resp, err := client.Do(req)

	if err != nil {
		panic(err)
	}

	defer resp.Body.Close()

	body, _ := ioutil.ReadAll(resp.Body)

	var responseObj Response
	json.Unmarshal(body, &responseObj)

	fmt.Println("ErrorCode:", responseObj.ErrorCode)
	fmt.Println("Result:", responseObj.Result)
	fmt.Println("Message:", responseObj.Message)
}
```

{% endtab %}

{% tab title="Java" %}

```java
import okhttp3.*;
import org.json.*;

public class Main {
    public static void main(String[] args) {
        OkHttpClient client = new OkHttpClient();

        MediaType mediaType = MediaType.parse("application/json");
        JSONObject json = new JSONObject();
        json.put("MerchantUniqueCode", "aaa");
        
        RequestBody body = RequestBody.create(mediaType, json.toString());
        Request request = new Request.Builder()
        .url("{{Base Adres}}/api/paywall/payment/end3d")
        .post(body)
        .addHeader("Content-Type", "application/json")
        .addHeader("apikeypublic", "%PUBLICKEY%")
        .addHeader("apiclientpublic", "%PUBLICCLIENT%")
        .build();

        try {
            Response response = client.newCall(request).execute();
            String responseString = response.body().string();

            // Parse the response
            JSONObject jsonResponse = new JSONObject(responseString);
            System.out.println("ErrorCode: " + jsonResponse.getInt("ErrorCode"));
            System.out.println("Result: " + jsonResponse.getBoolean("Result"));
            System.out.println("Message: " + jsonResponse.getString("Message"));
            
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$url = '{{Base Adres}}/api/paywall/payment/end3d';
$data = array(
    "MerchantUniqueCode" => "aaa"
);
$options = array(
    'http' => array(
        'header'  => "Content-type: application/json\r\n" .
                     "apikeypublic: %PUBLICKEY%\r\n" . 
                     "apiclientpublic: %PUBLICCLIENT%\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 = '{{Base Adres}}/api/paywall/payment/end3d'
headers = {
    'Content-Type': 'application/json',
    'apikeypublic': '%PUBLICKEY%',
    'apiclientpublic': '%PUBLICCLIENT%'
}
data = {
    "MerchantUniqueCode": "aaa"
}
response = requests.post(url, headers=headers, data=json.dumps(data))

# Parsing the response
response_json = response.json()

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

{% endtab %}

{% tab title="Ruby" %}

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

uri = URI.parse("{{Base Adres}}/api/paywall/payment/end3d")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request["Apikeypublic"] = "%PUBLICKEY%"
request["Apiclientpublic"] = "%PUBLICCLIENT%"
request.body = JSON.dump({
  "MerchantUniqueCode" => "aaa"
})

req_options = {
  use_ssl: uri.scheme == "https",
}

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end

response = JSON.parse(response.body)

puts "ErrorCode: #{response['ErrorCode']}"
puts "Result: #{response['Result']}"
puts "Message: #{response['Message']}"
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import * as https from 'https';

const data = JSON.stringify({
  "MerchantUniqueCode": "aaa"
});

const options = {
  hostname: '{{Base Adres}}',
  port: 443,
  path: '/api/paywall/payment/end3d',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'apikeypublic': '%PUBLICKEY%',
    'apiclientpublic': '%PUBLICCLIENT%'
  }
};

const req = https.request(options, (res) => {
  res.on('data', (d) => {
    // Parse the response
    const response = JSON.parse(d.toString());

    console.log(`ErrorCode: ${response.ErrorCode}`);
    console.log(`Result: ${response.Result}`);
    console.log(`Message: ${response.Message}`);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
```

{% endtab %}

{% tab title="Curl" %}

```sh
curl --location --request POST '{{Base Adres}}/api/paywall/payment/end3d' \
--header 'Content-Type: application/json' \
--header 'apikeypublic: %PUBLICKEY%' \
--header 'apiclientpublic: %PUBLICCLIENT%' \
--data-raw '{
    "MerchantUniqueCode": "aaa"
}'
```

{% endtab %}
{% endtabs %}

**Servisten dönen cevap:**

<table><thead><tr><th width="185.33333333333331">Parametre</th><th width="79">Tip</th><th>Açıklama</th></tr></thead><tbody><tr><td>ErrorCode</td><td>int</td><td>İşlem sonucunu bildirir. İşlem başarılı ise '0' değilse '1' döner</td></tr><tr><td>Result</td><td>string</td><td>İşlem Başarılı ise 'true' değilse 'false' değeri döner</td></tr><tr><td>Message</td><td>string</td><td>İşlem sonuç mesajını bildirir.</td></tr></tbody></table>

Örnek  Kod :

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

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

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