> ## Documentation Index
> Fetch the complete documentation index at: https://dkkangoyazlmteknolojiticareta.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Order Variables

> Retrieve payment and shipping method lists

## Overview

Returns the available payment methods and shipping methods used in the system.

## Headers

<ParamField header="Access-Token" type="string" required>
  Your API access token
</ParamField>

## Response

<ResponseField name="status" type="boolean">
  `true` if successful
</ResponseField>

<ResponseField name="data" type="object">
  Object containing payment and shipping method arrays

  <Expandable title="Response Structure">
    <ResponseField name="paymentMethod" type="array">
      Available payment methods

      <Expandable title="Payment Method Object">
        <ResponseField name="key" type="string">
          Payment method key (e.g., "CASH", "CREDIT\_CARD")
        </ResponseField>

        <ResponseField name="name" type="string">
          Display name (e.g., "Nakit", "Kredi Kartı")
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="shippingMethod" type="array">
      Available shipping methods

      <Expandable title="Shipping Method Object">
        <ResponseField name="key" type="string">
          Shipping method key (e.g., "delivery", "pickup")
        </ResponseField>

        <ResponseField name="name" type="string">
          Display name (e.g., "Teslimat", "Gel Al")
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET https://www.xn--dkkango-n2a.com/api/integrations/orders/variables \
    -H 'Access-Token: your-access-token'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    'https://www.xn--dkkango-n2a.com/api/integrations/orders/variables',
    {
      headers: {
        'Access-Token': 'your-access-token'
      }
    }
  );

  const data = await response.json();
  console.log('Payment methods:', data.data.paymentMethod);
  console.log('Shipping methods:', data.data.shippingMethod);
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://www.xn--dkkango-n2a.com/api/integrations/orders/variables',
      headers={'Access-Token': 'your-access-token'}
  )

  data = response.json()
  print('Payment methods:', data['data']['paymentMethod'])
  print('Shipping methods:', data['data']['shippingMethod'])
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://www.xn--dkkango-n2a.com/api/integrations/orders/variables');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
      'Access-Token: your-access-token'
  ));
  $response = curl_exec($ch);
  curl_close($ch);

  $data = json_decode($response, true);
  print_r($data['data']);
  ?>
  ```
</CodeGroup>

## Success Response (200)

```json theme={null}
{
  "status": true,
  "data": {
    "paymentMethod": [
      {
        "key": "CASH",
        "name": "Nakit"
      },
      {
        "key": "CREDIT_CARD",
        "name": "Kredi Kartı"
      },
      {
        "key": "DEBIT_CARD",
        "name": "Banka Kartı"
      }
    ],
    "shippingMethod": [
      {
        "key": "delivery",
        "name": "Teslimat"
      },
      {
        "key": "pickup",
        "name": "Gel Al"
      }
    ]
  }
}
```

## Error Response (401)

```json theme={null}
{
  "status": false,
  "error": "yetkisiz erişim"
}
```

## Use Cases

<AccordionGroup>
  <Accordion title="Initialize POS">
    Fetch and cache variables when POS starts.

    ```javascript theme={null}
    async function initializePOS() {
      const variables = await getOrderVariables();
      
      // Store in local cache
      localStorage.setItem('paymentMethods', 
        JSON.stringify(variables.paymentMethod));
      localStorage.setItem('shippingMethods', 
        JSON.stringify(variables.shippingMethod));
      
      console.log('POS initialized with order variables');
    }
    ```
  </Accordion>

  <Accordion title="Display Order Details">
    Map payment/shipping keys to display names.

    ```javascript theme={null}
    function formatOrderDetails(order) {
      const paymentMethods = getPaymentMethods();
      const shippingMethods = getShippingMethods();
      
      const paymentName = paymentMethods.find(
        p => p.key === order.payment_type
      )?.name || order.payment_type;
      
      const shippingName = shippingMethods.find(
        s => s.key === order.shipping_method
      )?.name || order.shipping_method;
      
      return {
        ...order,
        paymentMethodName: paymentName,
        shippingMethodName: shippingName
      };
    }
    ```
  </Accordion>

  <Accordion title="Build Filters">
    Create dropdown filters in POS interface.

    ```javascript theme={null}
    async function buildOrderFilters() {
      const variables = await getOrderVariables();
      
      // Payment filter
      const paymentFilter = variables.paymentMethod.map(pm => ({
        value: pm.key,
        label: pm.name
      }));
      
      // Shipping filter
      const shippingFilter = variables.shippingMethod.map(sm => ({
        value: sm.key,
        label: sm.name
      }));
      
      renderFilters(paymentFilter, shippingFilter);
    }
    ```
  </Accordion>

  <Accordion title="Validation">
    Validate incoming order data.

    ```javascript theme={null}
    function validateOrderVariables(order) {
      const variables = getCachedVariables();
      
      const validPayment = variables.paymentMethod.some(
        p => p.key === order.payment_type
      );
      
      const validShipping = variables.shippingMethod.some(
        s => s.key === order.shipping_method
      );
      
      if (!validPayment || !validShipping) {
        throw new Error('Invalid payment or shipping method');
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Caching Strategy

<Note>
  These values rarely change. Cache them locally to avoid unnecessary API calls.
</Note>

```javascript theme={null}
class VariablesCache {
  constructor() {
    this.cache = null;
    this.lastFetch = null;
    this.cacheDuration = 24 * 60 * 60 * 1000; // 24 hours
  }
  
  async getVariables() {
    const now = Date.now();
    
    // Return cached if recent
    if (this.cache && (now - this.lastFetch) < this.cacheDuration) {
      return this.cache;
    }
    
    // Fetch fresh
    const response = await fetch('/orders/variables');
    this.cache = await response.json();
    this.lastFetch = now;
    
    return this.cache;
  }
  
  invalidate() {
    this.cache = null;
    this.lastFetch = null;
  }
}
```

## Payment Methods

| Key          | Name        | Description              |
| ------------ | ----------- | ------------------------ |
| CASH         | Nakit       | Cash payment on delivery |
| CREDIT\_CARD | Kredi Kartı | Credit card (pre-paid)   |
| DEBIT\_CARD  | Banka Kartı | Debit card (pre-paid)    |

## Shipping Methods

| Key      | Name     | Description                     |
| -------- | -------- | ------------------------------- |
| delivery | Teslimat | Home/office delivery            |
| pickup   | Gel Al   | Customer pickup from restaurant |

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Current Orders" icon="shopping-cart" href="/api-reference/orders/get-current">
    Orders use these payment/shipping methods
  </Card>

  <Card title="Get Cancel Reasons" icon="list" href="/api-reference/orders/cancel-reasons">
    Another variables endpoint
  </Card>
</CardGroup>
