# 13. Payment Inquiry

## Payment Inquiry

<mark style="color:blue;">`GET`</mark> `{{Base Address}}/api/paywall/private/query`

{% hint style="info" %}
**Important**: To use the Payment Inquiry service, you need to send the '**apikeyprivate**' and '**apiclientprivate**' parameters in the 'Header' section.\
\
[<mark style="color:green;">**PaymentAPI Address**</mark>](https://developer.paywall.one/payment-orchestration-integration-document/environment)
{% endhint %}

<table><thead><tr><th width="241">Parameter</th><th width="79">Type</th><th width="144">Compulsory</th><th width="403">Description</th></tr></thead><tbody><tr><td>apikeyprivate</td><td>string</td><td>Yes</td><td>The Public Key obtained from the merchant panel.</td></tr><tr><td>apiclientprivate</td><td>string</td><td>Yes</td><td>The Public Client obtained from the merchant panel.</td></tr><tr><td>merchantuniquecode</td><td>string </td><td>Yes</td><td>The unique tracking code provided by your side for the payment.</td></tr></tbody></table>

**Example codes:**

{% tabs %}
{% tab title="C#" %}

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

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

    private static async Task Main()
    {
        client.DefaultRequestHeaders.Add("apikeyprivate", "%PRIVATEKEY%");
        client.DefaultRequestHeaders.Add("apiclientprivate", "%PRIVATECLIENT%");
        client.DefaultRequestHeaders.Add("merchantuniquecode", "%MerchantUniqueCode%");
        var response = await client.GetAsync("{{Private Base Address}}/api/paywall/private/query");
        var responseString = await response.Content.ReadAsStringAsync();
        var responseObject = JsonConvert.DeserializeObject<Response>(responseString);
        Console.WriteLine(responseObject.Body.Paywall.StatusName);
    }

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

    public class Body
    {
        public Paywall Paywall { get; set; }
    }

    public class Paywall
    {
        public int PaymentId { get; set; }
        public int ActivityId { get; set; }
        public bool Status { get; set; }
        public string StatusName { get; set; }
        // Define other properties as needed...
    }
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

type Response struct {
    ErrorCode int    `json:"ErrorCode"`
    Result    bool   `json:"Result"`
    Message   string `json:"Message"`
    Body      struct {
        Paywall struct {
            PaymentId int `json:"PaymentId"`
            // Add the other fields as necessary...
        } `json:"Paywall"`
    } `json:"Body"`
}

func main() {
    url := "{{Private Base Address}}/api/paywall/private/query"
    
    req, _ := http.NewRequest("GET", url, nil)
    req.Header.Set("apikeyprivate", "%PRIVATEKEY%")
    req.Header.Set("apiclientprivate", "%PRIVATECLIENT%")
    req.Header.Set("merchantuniquecode", "%MerchantUniqueCode%")
    
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()
    
    body, _ := ioutil.ReadAll(resp.Body)
    
    var response Response
    json.Unmarshal(body, &response)
    fmt.Println(response.Body.Paywall.PaymentId)
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.URI;
import java.net.http.HttpResponse.BodyHandlers;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

class Response {
    @SerializedName("ErrorCode")
    int errorCode;
    
    @SerializedName("Result")
    boolean result;

    @SerializedName("Message")
    String message;

    @SerializedName("Body")
    Body body;
}

class Body {
    @SerializedName("Paywall")
    Paywall paywall;
}

class Paywall {
    @SerializedName("PaymentId")
    int paymentId;
    // Add the other fields as necessary...
}

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

        HttpRequest request = HttpRequest.newBuilder()
                .uri(new URI("{{Private Base Address}}/api/paywall/private/query"))
                .setHeader("apikeyprivate", "%PRIVATEKEY%")
                .setHeader("apiclientprivate", "%PRIVATECLIENT%")
                .setHeader("merchantuniquecode", "%MerchantUniqueCode%")
                .GET()
                .build();

        var response = client.send(request, BodyHandlers.ofString());

        Gson gson = new Gson();
        Response responseObject = gson.fromJson(response.body(), Response.class);
        System.out.println(responseObject.body.paywall.paymentId);
    }
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$options = array(
    'http' => array(
        'header'  => "Content-type: application/json\r\n" .
                     "apikeyprivate: %PRIVATEKEY%\r\n" .
                     "apiclientprivate: %PRIVATECLIENT%\r\n" .
                     "merchantuniquecode: %MerchantUniqueCode%\r\n",
        'method'  => 'GET',
    ),
);
$url = '{{Private Base Address}}/api/paywall/private/query';
$context  = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === FALSE) { /* Handle error */ }

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

// Print PaymentId
echo "PaymentId: " . $response->Body->Paywall->PaymentId . "\n";
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

headers = {
    'apikeyprivate': '%PRIVATEKEY%',
    'apiclientprivate': '%PRIVATECLIENT%',
    'merchantuniquecode': '%MerchantUniqueCode%',
    'Content-Type': 'application/json',
}

response = requests.get('{{Private Base Address}}/api/paywall/private/query', headers=headers)
response_json = response.json()

# Print PaymentId
print('PaymentId:', response_json['Body']['Paywall']['PaymentId'])
```

{% endtab %}

{% tab title="Ruby" %}

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

uri = URI('{{Private Base Address}}/api/paywall/private/query')
req = Net::HTTP::Get.new(uri)
req['apikeyprivate'] = '%PRIVATEKEY%'
req['apiclientprivate'] = '%PRIVATECLIENT%'
req['merchantuniquecode'] = '%MerchantUniqueCode%'

res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') {|http|
  http.request(req)
}

# Parse and print PaymentId
response_json = JSON.parse(res.body)
puts "PaymentId: #{response_json['Body']['Paywall']['PaymentId']}"
```

{% endtab %}

{% tab title="TypeScript" %}

```typescript
import axios, { AxiosResponse } from 'axios';

interface Response {
    ErrorCode: number;
    Result: boolean;
    Message: string;
    Body: {
        Paywall: {
            PaymentId: number;
            // Add other properties as needed...
        }
    }
}

const headers = {
    'apikeyprivate': '%PRIVATEKEY%',
    'apiclientprivate': '%PRIVATECLIENT%',
    'merchantuniquecode': '%MerchantUniqueCode%',
};

axios.get<Response>('{{Private Base Address}}/api/paywall/private/query', { headers })
    .then((response: AxiosResponse<Response>) => {
        console.log(response.data.Body.Paywall.PaymentId);
    });
```

{% endtab %}

{% tab title="Curl" %}

```sh
curl -X GET '{{Private Base Address}}/api/paywall/private/query' \
    -H 'apikeyprivate: %PRIVATEKEY%' \
    -H 'apiclientprivate: %PRIVATECLIENT%' \
    -H 'merchantuniquecode: %MerchantUniqueCode%' \
```

{% endtab %}
{% endtabs %}

**Response From The service:**

<table><thead><tr><th width="251">Parameter</th><th width="117.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>PaymentId</td><td>int</td><td>Payment ID</td></tr><tr><td>ActivityId</td><td>int</td><td>Payment Last Transaction ID</td></tr><tr><td>Status</td><td>boolean</td><td>Last Transaction Status, true: successful / false: unsuccessful</td></tr><tr><td>StatusName</td><td>string</td><td>Payment Status</td></tr><tr><td>StatusId</td><td>int</td><td>Payment Status ID</td></tr><tr><td>TypeName</td><td>string</td><td>Payment Last Transaction Type</td></tr><tr><td>TypeId</td><td>int</td><td>Payment Last Transaction Type Identifier</td></tr><tr><td>Installment</td><td>int</td><td>Installment Information</td></tr><tr><td>CurrencyId</td><td>int</td><td>Payment Currency Identifier</td></tr><tr><td>CurrencyName</td><td>string</td><td>Payment Currency</td></tr><tr><td>PaymentMethodId</td><td>int</td><td>Payment Method Identifier</td></tr><tr><td>PaymentMethod</td><td>string</td><td>Payment Method</td></tr><tr><td>PaymentChannelId</td><td>int</td><td>Payment Channel Identifie</td></tr><tr><td>PaymentChannelName</td><td>string</td><td>Payment Channel</td></tr><tr><td>PaymentTagId</td><td>int</td><td>Payment Tag Identifier</td></tr><tr><td>PaymentTagName</td><td>string</td><td>Payment tag</td></tr></tbody></table>

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

```json
{
    "ErrorCode": 0,
    "Result": true,
    "Message": "",
    "Body": {
        "Paywall": {
            "PaymentId": 329659,
            "ActivityId": 355097,
            "Status": true,
            "StatusName": "Başarılı",
            "StatusId": 4,
            "TypeName": "İade",
            "TypeId": 2,
            "Installment": 1,
            "CurrencyId": 1,
            "CurrencyName": "TRY",
            "PaymentMethodId": 1,
            "PaymentMethodName": null,
            "PaymentChannelId": 6,
            "PaymentChannelName": "Checkout",
            "PaymentTagId": 0,
            "PaymentTagName": null,
            "CardNumber": "552879******0008",
            "CardOwnerName": "tes test",
            "CardBankName": "T.HALK BANKASI A.Ş.",
            "CardBrandName": "Master Card",
            "CardTypeName": "Credit",
            "CardFamilyName": "Paraf",
            "LastActivityDateTime": "2023-04-10T04:05:10.8722766",
            "PaymentAmount": 1.00,
            "ActivityAmount": 1.00,
            "IP": "3.94.21.171"
        }
    }
}
```

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