# User

## Get Balance

<mark style="color:green;">`GET`</mark>  `/balance`

Returns the user's balance.

**Example request:**

{% tabs %}
{% tab title="cURL" %}
```
curl -X GET "https://apid.iproyal.com/v1/reseller/balance" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
```
{% endtab %}

{% tab title="PHP" %}
```php
<?php
$api_token = '<your_access_token>';

$url = "https://apid.iproyal.com/v1/reseller/balance";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>
```
{% endtab %}

{% tab title="Python" %}
```python
import requests

api_token = '<your_access_token>'
url = 'https://apid.iproyal.com/v1/reseller/balance'

headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())
```
{% endtab %}

{% tab title="Node.js" %}
```javascript
const https = require('https');

const api_token = '<your_access_token>';

const options = {
  hostname: 'apid.iproyal.com',
  path: '/v1/reseller/balance',
  method: 'GET',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

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

req.end();
```
{% endtab %}

{% tab title="Java" %}
```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ApiRequest {
    public static void main(String[] args) {
        String apiToken = "<your_access_token>";
        String urlString = "https://apid.iproyal.com/v1/reseller/balance";

        try {
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("X-Access-Token", apiToken);
            connection.setRequestProperty("Content-Type", "application/json");

            int responseCode = connection.getResponseCode();
            System.out.println("Response Code: " + responseCode);

            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder content = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }
                in.close();

                System.out.println("Response Body: " + content.toString());
            } else {
                System.out.println("GET request failed. Response Code: " + responseCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
{% endtab %}

{% tab title="Go" %}
```go
package main

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

const (
	apiToken = "<your_access_token>"
	url      = "https://apid.iproyal.com/v1/reseller/balance"
)

func main() {
	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("X-Access-Token", apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	fmt.Println("Status Code:", resp.StatusCode)

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}

	fmt.Printf(string(responseBody))
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        string url = "https://apid.iproyal.com/v1/reseller/balance";

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            HttpResponseMessage response = await client.GetAsync(url);

            Console.WriteLine((int)response.StatusCode);

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}
```
{% endtab %}
{% endtabs %}

**Example response:**

```json
884.05
```



## Get Cards

<mark style="color:green;">`GET`</mark>  `/cards`

**Example request:**

{% tabs %}
{% tab title="cURL" %}
```
curl -X GET "https://apid.iproyal.com/v1/reseller/cards" \
     -H "X-Access-Token: <your_access_token>" \
     -H "Content-Type: application/json"
```
{% endtab %}

{% tab title="PHP" %}
```php
<?php
$api_token = '<your_access_token>';
$order_id = 12345;

$url = "https://apid.iproyal.com/v1/reseller/cards";

$options = [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "X-Access-Token: $api_token",
        'Content-Type: application/json'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, $options);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {
    echo $response;
}

curl_close($ch);
?>

```
{% endtab %}

{% tab title="Python" %}
```python
import requests

api_token = '<your_access_token>'
order_id = 12345

url = f'https://apid.iproyal.com/v1/reseller/cards'
headers = {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
}

response = requests.get(url, headers=headers)

print(response.status_code)
print(response.json())
```
{% endtab %}

{% tab title="Node.js" %}
```javascript
const https = require('https');

const api_token = '<your_access_token>';
const order_id = 12345;

const options = {
  hostname: 'apid.iproyal.com',
  path: `/v1/reseller/cards`,
  method: 'GET',
  headers: {
    'X-Access-Token': api_token,
    'Content-Type': 'application/json'
  }
};

const req = https.request(options, (res) => {
  let responseData = '';

  res.on('data', (chunk) => {
    responseData += chunk;
  });

  res.on('end', () => {
    console.log(responseData);
  });
});

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

req.end();
```
{% endtab %}

{% tab title="Java" %}
```java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class ApiRequest {
    public static void main(String[] args) {
        String apiToken = "<your_access_token>";
        int orderId = 12345;
        String urlString = String.format("https://apid.iproyal.com/v1/reseller/cards");

        try {
            URL url = new URL(urlString);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setRequestProperty("X-Access-Token", apiToken);
            connection.setRequestProperty("Content-Type", "application/json");

            int responseCode = connection.getResponseCode();
            System.out.println("Response Code: " + responseCode);

            if (responseCode == HttpURLConnection.HTTP_OK) {
                BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuilder content = new StringBuilder();

                while ((inputLine = in.readLine()) != null) {
                    content.append(inputLine);
                }
                in.close();

                System.out.println("Response Body: " + content.toString());
            } else {
                System.out.println("GET request failed. Response Code: " + responseCode);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```
{% endtab %}

{% tab title="Go" %}
```go
package main

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

const (
	apiToken = "<your_access_token>"
	orderID  = 12345
)

func main() {
	url := fmt.Sprintf("https://apid.iproyal.com/v1/reseller/cards")

	req, err := http.NewRequest(http.MethodGet, url, nil)
	if err != nil {
		log.Fatal("Error creating request:", err)
	}

	req.Header.Set("X-Access-Token", apiToken)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal("Error making request:", err)
	}
	defer resp.Body.Close()

	fmt.Println("Status Code:", resp.StatusCode)

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		log.Fatal("Error reading response body:", err)
	}

	var jsonResponse map[string]interface{}
	err = json.Unmarshal(responseBody, &jsonResponse)
	if err != nil {
		log.Fatal("Error unmarshaling JSON:", err)
	}

	fmt.Printf("%+v\n", jsonResponse)
}
```
{% endtab %}

{% tab title="C#" %}
```csharp
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string apiToken = "<your_access_token>";
        int orderId = 12345;
        string url = $"https://apid.iproyal.com/v1/reseller/cards";

        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("X-Access-Token", apiToken);

            HttpResponseMessage response = await client.GetAsync(url);

            Console.WriteLine((int)response.StatusCode);

            string responseText = await response.Content.ReadAsStringAsync();
            var jsonResponse = JsonSerializer.Deserialize<JsonElement>(responseText);
            Console.WriteLine(jsonResponse);
        }
    }
}
```
{% endtab %}
{% endtabs %}

**Example response:**&#x20;

```json
{
    "data": [
        {
            "id": 2,
            "provider": "stripe",
            "custom_name": null,
            "payment_method": "card",
            "card_type": "visa",
            "currency": "USD",
            "last_four_digits": "1234",
            "expiry_date": "2026/01",
            "update_url": null,
            "cancel_url": null,
            "products_with_order_ids": [],
            "has_royal_auto_extend_enabled": false,
            "updated_at": "2025-04-11T14:06:28.000000Z"
        },
    ]
}
```
