Fatura Ödeme
Alış faturası için ödeme işlemi ve ödeme kaydı.
Endpoint
POST /kolaybi/v1/invoices/payment
Parametreler
| Parametre | Tip | Zorunlu | Açıklama |
|---|---|---|---|
document_id | integer | Evet | Ödenecek alış faturasının ID'si |
vault_id | integer | Evet | Ödemenin yapılacağı kasa/banka ID |
amount | number | Hayır | Ödeme tutarı. Gönderilmezse kalan tutarın tamamı ödenir |
issue_date | string | Hayır | İşlem tarihi (YYYY-MM-DD HH:mm:ss) |
exchange_rate | number | Hayır | Döviz kuru. Gönderilmezse işlem tarihindeki kur kullanılır |
serial_no | string | Hayır | Ödeme hareketinin belge seri numarası. Her ödeme için benzersiz olmalıdır |
description | string | Hayır | Ödeme hareketine yazılacak açıklama |
project_id | integer | Hayır | Ödemenin bağlanacağı proje ID |
Örnekler
- cURL
- JavaScript
- PHP
- Python
- C#
# Kalan tutarın tamamını öde
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "document_id=1&vault_id=1"
# Belirli bir tutarı öde
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "document_id=1&vault_id=1&amount=100.50"
# Seri no, açıklama ve proje ile öde
curl -X POST "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Channel: YOUR_CHANNEL" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "document_id=1&vault_id=1&serial_no=ODM2024-0001&description=Nakliye ödemesi&project_id=1"
async function payInvoice(documentId, vaultId, amount = null, options = {}) {
const formData = new URLSearchParams();
formData.append("document_id", documentId);
formData.append("vault_id", vaultId);
if (amount !== null) {
formData.append("amount", amount);
}
if (options.serial_no) formData.append("serial_no", options.serial_no);
if (options.description) formData.append("description", options.description);
if (options.project_id) formData.append("project_id", options.project_id);
const response = await fetch(
"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment",
{
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
Channel: channel,
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData,
}
);
return await response.json();
}
// Kullanım - Kalan tutarın tamamını öde
const result = await payInvoice(1, 1);
// Kullanım - Belirli bir tutarı öde
const partialResult = await payInvoice(1, 1, 100.50);
// Kullanım - Seri no, açıklama ve proje ile öde
const detailedResult = await payInvoice(1, 1, null, {
serial_no: "ODM2024-0001",
description: "Nakliye ödemesi",
project_id: 1,
});
function payInvoice($documentId, $vaultId, $amount = null, $options = []) {
$url = 'https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment';
$postData = [
'document_id' => $documentId,
'vault_id' => $vaultId
];
if ($amount !== null) {
$postData['amount'] = $amount;
}
if (isset($options['serial_no'])) $postData['serial_no'] = $options['serial_no'];
if (isset($options['description'])) $postData['description'] = $options['description'];
if (isset($options['project_id'])) $postData['project_id'] = $options['project_id'];
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($postData),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $accessToken,
'Channel: ' . $channel,
'Content-Type: application/x-www-form-urlencoded'
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Kullanım - Kalan tutarın tamamını öde
$result = payInvoice(1, 1);
// Kullanım - Belirli bir tutarı öde
$partialResult = payInvoice(1, 1, 100.50);
// Kullanım - Seri no, açıklama ve proje ile öde
$detailedResult = payInvoice(1, 1, null, [
'serial_no' => 'ODM2024-0001',
'description' => 'Nakliye ödemesi',
'project_id' => 1
]);
import requests
def pay_invoice(document_id, vault_id, amount=None, serial_no=None, description=None, project_id=None):
url = "https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment"
headers = {
"Authorization": f"Bearer {access_token}",
"Channel": channel,
"Content-Type": "application/x-www-form-urlencoded"
}
data = {
"document_id": document_id,
"vault_id": vault_id
}
if amount is not None:
data["amount"] = amount
if serial_no is not None:
data["serial_no"] = serial_no
if description is not None:
data["description"] = description
if project_id is not None:
data["project_id"] = project_id
response = requests.post(url, headers=headers, data=data)
return response.json()
# Kullanım - Kalan tutarın tamamını öde
result = pay_invoice(1, 1)
# Kullanım - Belirli bir tutarı öde
partial_result = pay_invoice(1, 1, 100.50)
# Kullanım - Seri no, açıklama ve proje ile öde
detailed_result = pay_invoice(
1, 1,
serial_no="ODM2024-0001",
description="Nakliye ödemesi",
project_id=1,
)
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json;
async Task<dynamic> PayInvoiceAsync(int documentId, int vaultId, double? amount = null, string serialNo = null, string description = null, int? projectId = null)
{
using var client = new HttpClient();
var data = new Dictionary<string, string>
{
{ "document_id", documentId.ToString() },
{ "vault_id", vaultId.ToString() }
};
if (amount.HasValue)
{
data.Add("amount", amount.Value.ToString());
}
if (serialNo != null)
{
data.Add("serial_no", serialNo);
}
if (description != null)
{
data.Add("description", description);
}
if (projectId.HasValue)
{
data.Add("project_id", projectId.Value.ToString());
}
var request = new HttpRequestMessage(HttpMethod.Post,
"https://ofis-sandbox-api.kolaybi.com/kolaybi/v1/invoices/payment")
{
Content = new FormUrlEncodedContent(data)
};
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
request.Headers.Add("Channel", channel);
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<dynamic>(content);
}
// Kullanım - Kalan tutarın tamamını öde
var result = await PayInvoiceAsync(1, 1);
// Kullanım - Belirli bir tutarı öde
var partialResult = await PayInvoiceAsync(1, 1, 100.50);
// Kullanım - Seri no, açıklama ve proje ile öde
var detailedResult = await PayInvoiceAsync(1, 1, null, "ODM2024-0001", "Nakliye ödemesi", 1);
Yanıt
{
"data": {
"transaction_type": "Ödeme",
"payment_method": "Nakit",
"issue_date": "2024-01-15 14:37:11",
"remaining_amount": 0.0,
"currency": "try"
},
"message": "Belge ödemesi başarıyla tamamlandı."
}
Yanıt Alanları
| Alan | Tip | Açıklama |
|---|---|---|
transaction_type | string | İşlem tipi (Ödeme) |
payment_method | string | Ödeme yöntemi (ör. Nakit) |
issue_date | string | İşlem tarihi (datetime) |
remaining_amount | number | Kalan tutar |
currency | string | Para birimi |
message | string | İşlem sonucu mesajı |