SinApp Muhasebe API - Kod Örnekleri

Bu sayfada, SinApp Muhasebe API'sini farklı programlama dillerinde nasıl kullanabileceğinize dair örnekler bulabilirsiniz.

Kod Örnekleri

Aşağıdaki örnekler, API'mizi kullanarak fatura oluşturma işleminin farklı programlama dillerinde nasıl yapılacağını göstermektedir.

PHP Örnekleri

1. Fatura Oluşturma (POST)

PHP ile fatura oluşturma:

<?php
// API kimlik bilgileri
$api_key = 'YOUR_API_KEY';
$api_secret = 'YOUR_API_SECRET';
$api_url = 'https://example.com/api/v1/invoices.php';

// Fatura verileri
$invoice_data = [
    "Channel" => [
        "website" => "example.com",
        "company_name" => "Örnek Şirket"
    ],
    "fatura_bilgileri" => [
        "invoice_id" => "INV-" . time(),
        "order_id" => "ORD-" . time(),
        "company_name" => "Müşteri Şirket",
        "tax_number" => "1234567890",
        "tax_office" => "Vergi Dairesi",
        "full_name" => "Ahmet Yılmaz",
        "contact_address" => "İstanbul, Türkiye"
    ],
    "kisisel_bilgiler" => [
        "users_namesurname" => "Ahmet",
        "users_surname" => "Yılmaz",
        "contact_phone" => "05551234567",
        "contact_email" => "ahmet@example.com"
    ],
    "siparis_detaylari" => [
        "order_id" => "ORD-" . time(),
        "courses" => [
            [
                "title" => "Web Geliştirme Kursu",
                "price" => 1000
            ]
        ],
        "total_course_price" => 1000,
        "amount" => 1000,
        "payment_method" => "1",
        "bank_name" => "Örnek Banka",
        "payment_date" => date("Y-m-d H:i:s")
    ]
];

// JSON verisi
$json_data = json_encode($invoice_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

// cURL ile API isteği
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    'X-Api-Key: ' . $api_key,
    'X-Api-Secret: ' . $api_secret
]);

// İsteği gönder ve yanıtı al
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    echo "cURL Hatası: " . curl_error($ch);
} else {
    $response_data = json_decode($response, true);
    
    if ($http_code == 200 || $http_code == 201) {
        echo "Fatura başarıyla oluşturuldu: " . $response_data['invoice_number'];
    } else {
        echo "Hata: " . ($response_data['error'] ?? 'Bilinmeyen hata');
    }
}

curl_close($ch);
?>
2. Fatura Güncelleme (PUT)

PHP ile fatura güncelleme:

<?php
// API kimlik bilgileri
$api_key = 'YOUR_API_KEY';
$api_secret = 'YOUR_API_SECRET';
$api_url = 'https://example.com/api/v1/invoice_operations.php';

// Güncellenecek fatura verileri
$update_data = [
    "invoice_id" => "INV-12345",
    "order_id" => "ORD-12345",
    "status" => "sent",
    "customer" => [
        "company_name" => "Müşteri Şirket",
        "tax_number" => "1234567890",
        "tax_office" => "Vergi Dairesi",
        "full_name" => "Ahmet Yılmaz",
        "contact_address" => "İstanbul, Türkiye",
        "contact_phone" => "05551234567",
        "contact_email" => "ahmet@example.com",
        "contact_city" => "İstanbul",
        "contact_district" => "Kadıköy",
        "identity_number" => "12345678901",
        "invoice_type" => "company"
    ],
    "kisisel_bilgiler" => [
        "users_namesurname" => "Ahmet",
        "users_surname" => "Yılmaz",
        "contact_phone" => "05551234567",
        "contact_email" => "ahmet@example.com",
        "identity_number" => "12345678901"
    ],
    "siparis_detaylari" => [
        "order_id" => "ORD-12345",
        "amount" => 1000,
        "payment_method" => "1",
        "bank_name" => "Örnek Banka",
        "payment_date" => date("Y-m-d H:i:s")
    ]
];

// Debug log - isteğe bağlı
file_put_contents('update_request.log', 
    date("Y-m-d H:i:s") . " - Güncelleme İsteği:\n" . 
    print_r($update_data, true) . "\n\n", 
    FILE_APPEND
);

// JSON verisi
$json_data = json_encode($update_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

// cURL ile API isteği
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    'X-Api-Key: ' . $api_key,
    'X-Api-Secret: ' . $api_secret
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// İsteği gönder ve yanıtı al
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    echo "cURL Hatası: " . curl_error($ch);
} else {
    $response_data = json_decode($response, true);
    
    if ($http_code == 200) {
        echo "Fatura başarıyla güncellendi: " . $response_data['invoice_id'];
    } else {
        echo "Hata: " . ($response_data['error'] ?? 'Bilinmeyen hata');
    }
}

curl_close($ch);
?>
3. Fatura Silme (DELETE)

PHP ile fatura silme:

<?php
// API kimlik bilgileri
$api_key = 'YOUR_API_KEY';
$api_secret = 'YOUR_API_SECRET';
$api_url = 'https://example.com/api/v1/invoice_operations.php';

// Silinecek fatura ve sipariş ID
$invoice_id = "INV-12345";
$order_id = "ORD-12345"; // Sipariş numarası da eklendi

// Silinecek fatura verisi
$delete_data = [
    "invoice_id" => $invoice_id,
    "order_id" => $order_id // Sipariş numarası da gönderiliyor
];

// Debug log - isteğe bağlı
file_put_contents('delete_request.log', 
    date("Y-m-d H:i:s") . " - Silme İsteği:\n" . 
    "Fatura ID: " . $invoice_id . "\n" .
    "Sipariş ID: " . $order_id . "\n\n", 
    FILE_APPEND
);

// JSON verisi
$json_data = json_encode($delete_data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);

// cURL ile API isteği
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json; charset=utf-8',
    'X-Api-Key: ' . $api_key,
    'X-Api-Secret: ' . $api_secret
]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// İsteği gönder ve yanıtı al
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    echo "cURL Hatası: " . curl_error($ch);
} else {
    $response_data = json_decode($response, true);
    
    if ($http_code == 200) {
        echo "Fatura başarıyla silindi: " . $response_data['invoice_id'];
        echo "
Sipariş: " . $response_data['order_id']; echo "
Mesaj: " . $response_data['message']; } else { echo "Hata: " . ($response_data['error'] ?? 'Bilinmeyen hata'); echo "
HTTP Kodu: " . $http_code; } } curl_close($ch); ?>

Fatura İptal Etme

Fatura İptal Örneği

Bu örnek, bir faturayı iptal edildi olarak işaretlemek için kullanılır:

// API endpoint
$api_url = 'https://[sizin-domaininiz]/api/v1/invoice_operations.php';

// Fatura bilgileri
$data = [
    'invoice_id' => 'INV-2023-001',
    'order_id' => 'ORD-2023-001'  // Opsiyonel
];

// API isteği için gerekli başlıklar
$headers = [
    'X-Api-Key: YOUR_API_KEY',
    'X-Api-Secret: YOUR_API_SECRET',
    'Content-Type: application/json'
];

// cURL isteği
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

curl_close($ch);

// Yanıtı kontrol et
if ($http_code === 200) {
    $result = json_decode($response, true);
    if ($result['success']) {
        echo "Fatura başarıyla iptal edildi olarak işaretlendi.\\n";
        echo "Fatura No: " . $result['invoice_id'] . "\\n";
    }
} else {
    echo "Hata oluştu: " . $response . "\\n";
}
Bu işlem faturayı fiziksel olarak silmez, sadece durumunu "İptal" olarak işaretler.
PUT Fatura Güncelleme

Mevcut bir faturayı güncellemek için örnek kod:


$data = [
    'invoice_id' => 'INV-2024-001',
    'order_id' => 'ORD-2024-001',  // Güvenlik için önerilir
    'status' => 'paid',
    'siparis_detaylari' => [
        'amount' => 1000,
        'payment_method' => 'credit_card',
        'payment_date' => '2024-03-15 14:30:00',
        'bank_name' => 'Garanti',
        'payment_solution' => 'Paytr',
        'payment_solution_order_id' => 'PTR123456'
    ]
];

$ch = curl_init('https://[sizin-domaininiz]/api/v1/invoice_operations.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-Api-Key: YOUR_API_KEY',
    'X-Api-Secret: YOUR_API_SECRET'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
DELETE Fatura Silme

Bir faturayı silmek (is_deleted=2 olarak işaretlemek) için örnek kod:


$data = [
    'invoice_id' => 'INV-2024-001',
    'order_id' => 'ORD-2024-001'  // Güvenlik için önerilir
];

$ch = curl_init('https://[sizin-domaininiz]/api/v1/invoice_operations.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'X-Api-Key: YOUR_API_KEY',
    'X-Api-Secret: YOUR_API_SECRET'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
2. Fatura Detayı Alma (GET)

PHP ile fatura detaylarını alma:

<?php
// API kimlik bilgileri
$api_key = 'YOUR_API_KEY';
$api_secret = 'YOUR_API_SECRET';

// Fatura ve sipariş bilgileri
$invoice_number = 'INV-2024-001';
$order_id = '456';

// API URL'si
$api_url = "https://example.com/api/v1/invoices.php?number={$invoice_number}&order={$order_id}";

// cURL isteği oluştur
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-Api-Key: ' . $api_key,
    'X-Api-Secret: ' . $api_secret
]);

// İsteği gönder ve yanıtı al
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Yanıtı işle
if ($http_code === 200) {
    $data = json_decode($response, true);
    if ($data['status'] === 'success') {
        $invoice = $data['data']['invoice'];
        $customer = $data['data']['customer'];
        $items = $data['data']['items'];
        $payment = $data['data']['payment'];
        
        // Fatura bilgilerini kullan
        echo "Fatura No: " . $invoice['invoice_number'] . "\n";
        echo "Müşteri: " . ($customer['invoice_type'] === 'company' ? 
            $customer['company_name'] : $customer['full_name']) . "\n";
        echo "Toplam Tutar: " . $invoice['grand_total'] . " " . $invoice['currency'] . "\n";
    }
} else {
    echo "Hata: API isteği başarısız oldu. HTTP Kodu: " . $http_code;
}
?>

JavaScript Örnekleri

1. Fatura Oluşturma (POST)

JavaScript ile fatura oluşturma:

// Node.js ile API isteği
const fetch = require('node-fetch');

// API kimlik bilgileri
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const apiUrl = 'https://example.com/api/v1/invoices.php';

// Fatura verileri
const invoiceData = {
    "Channel": {
        "website": "example.com",
        "company_name": "Örnek Şirket"
    },
    "fatura_bilgileri": {
        "invoice_id": `INV-${Date.now()}`,
        "order_id": `ORD-${Date.now()}`,
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye"
    },
    "kisisel_bilgiler": {
        "users_namesurname": "Ahmet",
        "users_surname": "Yılmaz",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com"
    },
    "siparis_detaylari": {
        "order_id": `ORD-${Date.now()}`,
        "courses": [
            {
                "title": "Web Geliştirme Kursu",
                "price": 1000
            }
        ],
        "total_course_price": 1000,
        "amount": 1000,
        "payment_method": "1",
        "bank_name": "Örnek Banka",
        "payment_date": new Date().toISOString().slice(0, 19).replace('T', ' ')
    }
};

// API isteği gönder
async function createInvoice() {
    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'X-Api-Key': apiKey,
                'X-Api-Secret': apiSecret
            },
            body: JSON.stringify(invoiceData)
        });

        const data = await response.json();

        if (response.ok) {
            console.log(`Fatura başarıyla oluşturuldu: ${data.invoice_number}`);
        } else {
            console.error(`Hata: ${data.error || 'Bilinmeyen hata'}`);
        }
    } catch (error) {
        console.error('İstek hatası:', error);
    }
}

createInvoice();
2. Fatura Güncelleme (PUT)

JavaScript ile fatura güncelleme:

// Node.js ile API isteği
const fetch = require('node-fetch');

// API kimlik bilgileri
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const apiUrl = 'https://example.com/api/v1/invoice_operations.php';

// Güncellenecek fatura verileri
const updateData = {
    "invoice_id": "INV-12345",
    "order_id": "ORD-12345",
    "status": "sent",
    "customer": {
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com",
        "contact_city": "İstanbul",
        "contact_district": "Kadıköy",
        "identity_number": "12345678901",
        "invoice_type": "company"
    },
    "kisisel_bilgiler": {
        "users_namesurname": "Ahmet",
        "users_surname": "Yılmaz",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com",
        "identity_number": "12345678901"
    },
    "siparis_detaylari": {
        "order_id": "ORD-12345",
        "amount": 1000,
        "payment_method": "1",
        "bank_name": "Örnek Banka",
        "payment_date": new Date().toISOString().replace('T', ' ').substring(0, 19)
    }
};

// HTTP başlıkları
const headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'X-Api-Key': apiKey,
    'X-Api-Secret': apiSecret
};

// API isteği
fetch(apiUrl, {
    method: 'PUT',
    headers: headers,
    body: JSON.stringify(updateData)
})
.then(response => {
    console.log(`HTTP Durum Kodu: ${response.status}`);
    return response.json();
})
.then(data => {
    if (data.success) {
        console.log(`Fatura başarıyla güncellendi: ${data.invoice_id}`);
        console.log(`Mesaj: ${data.message}`);
    } else {
        console.error(`Hata: ${data.error || 'Bilinmeyen hata'}`);
    }
})
.catch(error => {
    console.error(`İstek hatası: ${error.message}`);
});
3. Fatura Silme (DELETE)

JavaScript ile fatura silme:

// Node.js ile API isteği
const fetch = require('node-fetch');

// API kimlik bilgileri
const apiKey = 'YOUR_API_KEY';
const apiSecret = 'YOUR_API_SECRET';
const apiUrl = 'https://example.com/api/v1/invoice_operations.php';

// Silinecek fatura ID
const invoiceId = "INV-12345";
const orderId = "ORD-12345"; // Sipariş numarası da eklendi

// HTTP başlıkları
const headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'X-Api-Key': apiKey,
    'X-Api-Secret': apiSecret
};

// API isteği
fetch(apiUrl, {
    method: 'DELETE',
    headers: headers,
    body: JSON.stringify({ 
        invoice_id: invoiceId,
        order_id: orderId // Sipariş numarası da gönderiliyor
    })
})
.then(response => {
    console.log(`HTTP Durum Kodu: ${response.status}`);
    return response.json();
})
.then(data => {
    if (data.success) {
        console.log(`Fatura başarıyla silindi: ${data.invoice_id}`);
        console.log(`Sipariş: ${data.order_id}`);
        console.log(`Mesaj: ${data.message}`);
    } else {
        console.error(`Hata: ${data.error || 'Bilinmeyen hata'}`);
    }
})
.catch(error => {
    console.error(`İstek hatası: ${error.message}`);
});

Python Örnekleri

1. Fatura Oluşturma (POST)

Python ile fatura oluşturma:

import requests
import json
import time
from datetime import datetime

# API kimlik bilgileri
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
api_url = 'https://example.com/api/v1/invoices.php'

# Fatura verileri
invoice_data = {
    "Channel": {
        "website": "example.com",
        "company_name": "Örnek Şirket"
    },
    "fatura_bilgileri": {
        "invoice_id": f"INV-{int(time.time())}",
        "order_id": f"ORD-{int(time.time())}",  # Sipariş numarası eklendi
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye"
    },
    "kisisel_bilgiler": {
        "users_namesurname": "Ahmet",
        "users_surname": "Yılmaz",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com"
    },
    "siparis_detaylari": {
        "order_id": f"ORD-{int(time.time())}",
        "courses": [
            {
                "title": "Web Geliştirme Kursu",
                "price": 1000
            }
        ],
        "total_course_price": 1000,
        "amount": 1000,
        "payment_method": "1",
        "bank_name": "Örnek Banka",
        "payment_date": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
        "payment_solution": "iyzico",  # Ödeme çözümü eklendi
        "is_deleted": 0  # Silme durumu eklendi
    }
}

# HTTP başlıkları
headers = {
    'Content-Type': 'application/json',
    'X-Api-Key': api_key,
    'X-Api-Secret': api_secret
}

# API isteği gönder
try:
    response = requests.post(
        api_url,
        headers=headers,
        data=json.dumps(invoice_data, ensure_ascii=False).encode('utf-8')
    )
    
    # Yanıtı kontrol et
    response_data = response.json()
    
    if response.status_code in (200, 201):
        print(f"Fatura başarıyla oluşturuldu: {response_data.get('invoice_number')}")
    else:
        print(f"Hata: {response_data.get('error', 'Bilinmeyen hata')}")
        
except Exception as e:
    print(f"İstek hatası: {str(e)}")
2. Fatura Güncelleme (PUT)

Python ile fatura güncelleme:

import requests
import json
from datetime import datetime

# API kimlik bilgileri
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
api_url = 'https://example.com/api/v1/invoice_operations.php'

# Güncellenecek fatura verileri
update_data = {
    "invoice_id": "INV-12345",
    "order_id": "ORD-12345",  # Güvenlik için önerilir
    "status": "sent",
    "customer": {
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com",
        "contact_city": "İstanbul",
        "contact_district": "Kadıköy",
        "identity_number": "12345678901",
        "invoice_type": "company"
    }
}

# HTTP başlıkları
headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'X-Api-Key': api_key,
    'X-Api-Secret': api_secret
}

# API isteği gönder
try:
    response = requests.put(
        api_url,
        headers=headers,
        data=json.dumps(update_data, ensure_ascii=False).encode('utf-8')
    )
    
    # Yanıtı kontrol et
    print(f"HTTP Durum Kodu: {response.status_code}")
    response_data = response.json()
    
    if response.ok:
        print(f"Fatura başarıyla güncellendi: {response_data.get('invoice_id')}")
        print(f"Mesaj: {response_data.get('message')}")
    else:
        print(f"Hata: {response_data.get('error', 'Bilinmeyen hata')}")
        
except Exception as e:
    print(f"İstek hatası: {str(e)}")
3. Fatura Silme (DELETE)

Python ile fatura silme:

import requests
import json

# API kimlik bilgileri
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'
api_url = 'https://example.com/api/v1/invoice_operations.php'

# Silinecek fatura ve sipariş ID
invoice_id = "INV-12345"
order_id = "ORD-12345"  # Güvenlik için önerilir

# HTTP başlıkları
headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'X-Api-Key': api_key,
    'X-Api-Secret': api_secret
}

# API isteği gönder
try:
    response = requests.delete(
        api_url,
        headers=headers,
        data=json.dumps({
            "invoice_id": invoice_id,
            "order_id": order_id  # Sipariş numarası da gönderiliyor
        }, ensure_ascii=False).encode('utf-8')
    )
    
    # Yanıtı kontrol et
    print(f"HTTP Durum Kodu: {response.status_code}")
    response_data = response.json()
    
    if response.ok:
        print(f"Fatura başarıyla iptal edildi: {response_data.get('invoice_id')}")
        print(f"Sipariş: {response_data.get('order_id')}")
        print(f"Mesaj: {response_data.get('message')}")
        print("Not: Fatura fiziksel olarak silinmedi, is_deleted=2 olarak işaretlendi.")
    else:
        print(f"Hata: {response_data.get('error', 'Bilinmeyen hata')}")
        
except Exception as e:
    print(f"İstek hatası: {str(e)}")

cURL Örnekleri

1. Fatura Oluşturma (POST)

cURL ile fatura oluşturma:

curl -X POST \
  'https://example.com/api/v1/invoices.php' \
  -H 'Content-Type: application/json' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'X-Api-Secret: YOUR_API_SECRET' \
  -d '{
    "Channel": {
        "website": "example.com",
        "company_name": "Örnek Şirket"
    },
    "fatura_bilgileri": {
        "invoice_id": "INV-123456",
        "order_id": "ORD-789012",
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye"
    },
    "kisisel_bilgiler": {
        "users_namesurname": "Ahmet",
        "users_surname": "Yılmaz",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com"
    },
    "siparis_detaylari": {
        "order_id": "ORD-789012",
        "courses": [
            {
                "title": "Web Geliştirme Kursu",
                "price": 1000
            }
        ],
        "total_course_price": 1000,
        "amount": 1000,
        "payment_method": "1",
        "bank_name": "Örnek Banka",
        "payment_date": "2024-03-15 14:30:00",
        "payment_solution": "iyzico",
        "is_deleted": 0
    }
}'
2. Fatura Güncelleme (PUT)

cURL ile fatura güncelleme:

curl -X PUT \
  'https://example.com/api/v1/invoice_operations.php' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'X-Api-Secret: YOUR_API_SECRET' \
  -d '{
    "invoice_id": "INV-12345",
    "order_id": "ORD-12345",
    "status": "sent",
    "customer": {
        "company_name": "Müşteri Şirket",
        "tax_number": "1234567890",
        "tax_office": "Vergi Dairesi",
        "full_name": "Ahmet Yılmaz",
        "contact_address": "İstanbul, Türkiye",
        "contact_phone": "05551234567",
        "contact_email": "ahmet@example.com",
        "contact_city": "İstanbul",
        "contact_district": "Kadıköy",
        "identity_number": "12345678901",
        "invoice_type": "company"
    }
}'
3. Fatura Silme (DELETE)

cURL ile fatura silme:

curl -X DELETE \
  'https://example.com/api/v1/invoice_operations.php' \
  -H 'Content-Type: application/json; charset=utf-8' \
  -H 'X-Api-Key: YOUR_API_KEY' \
  -H 'X-Api-Secret: YOUR_API_SECRET' \
  -d '{
    "invoice_id": "INV-12345",
    "order_id": "ORD-12345"
}'
Not: DELETE isteği faturayı fiziksel olarak silmez, sadece is_deleted=2 olarak işaretler.
Yukarıdaki örneklerde yer alan YOUR_API_KEY ve YOUR_API_SECRET değerlerini, kendi API kimlik bilgilerinizle değiştirmeyi unutmayın.