Verilen Tarih Aralığına Göre Yapılan İşlemleri Getirme
Tüm işlemler arasından, verilen spesifik bir tarihe ait olan işlemleri getirir.
İstek Bilgileri
- Metot:
POST - URL:
https://staging.halkode.com.tr/ccpayment/api/getTransactions - CANLI URL:
https://app.halkode.com.tr/ccpayment/api/getTransactions - Yetkilendirme:
Bearer {token}Token Alma servisinden alınan değer
İstek Parametreleri (Body)
| Parametre | Tip | Koşul | Açıklama |
|---|---|---|---|
merchant_key | string | Zorunlu | Üye işyeri anahtarınız. |
hash_key | string | Zorunlu | Güvenlik imzası. |
date | string | Opsiyonel | İşlemlerin getirileceği spesifik tarih. |
invoiceid | string | Opsiyonel | Sizin tarafınızdaki tekil sipariş ID. |
currency_id | int | Opsiyonel | Para birimi ID bilgisi. |
paymentmethodid | int | Opsiyonel | Ödeme metodu ID bilgisi. |
minamount | int | Opsiyonel | Minimum tutar. |
maxamount | int | Opsiyonel | Maximum tutar. |
transactionState | int | Opsiyonel | İşlem durumu. |
type | string | Opsiyonel | Bu değer 'daily', 'hourly' veya 'range' olabilir. Eğer bu alan boş gönderilirse sistem bunu 'daily' olarak varsayar. |
order_by_option | int | Opsiyonel | Eğer bu değer 1 (varsayılan) ise "from_date" ve "to_date" aralığındaki tarih için sorgu, oluşturulma tarihini esas alır. Eğer bu değer 2 ise "from_date" ve "to_date" aralığındaki tarih için sorgu, değiştirilme tarihini esas alır. |
from_date | datetime | Opsiyonel | Verilecek tarih aralığı için başlangıç tarihini ifade eder. 'type' değeri 'range' ise bu parametre de zorunludur, aksi halde opsiyoneldir. |
to_date | datetime | Opsiyonel | Verilecek tarih aralığı için bitiş tarihini ifade eder. 'type' değeri 'range' ise bu parametre de zorunludur, aksi halde opsiyoneldir. |
page_limit | int | Opsiyonel | Her seferinde kaç kayıt getirileceğini belirler. |
Örnek İstek (Request)
json
{
"merchant_key":"{{merchant_key}}",
"hash_key" : "{{hash_key}}",
"date": "2021-02-10",
"invoiceid": "",
"currency_id": "",
"paymentmethodid": "",
"minamount": "",
"maxamount": "",
"transactionState": "",
"type": "daily"
}Başarılı Yanıt
json
{
"status_code": 100,
"status_description": "Successfull",
"data": {
"transactions": [
{
"merchant_id": 98950,
"payment_id": "hfs3u-x-TC10-98950-070122",
"merchant_commission": 0,
"gross": 0.1,
"net": 0.1,
"payment_type_id": 1,
"product_price": 0.1,
"total_refunded_amount": 0.1,
"card_holder_bank": "ZİRAAT BANKASI",
"dpl_id": 0,
"currency_id": 1,
"invoice_id": "62957",
"credit_card_no": "528208****7890",
"installment": 1,
"rolling_amount": 0.01,
"gsm_number": "",
"card_program": "BANKKART_COMBO",
"result": "Approved(164155826583087)",
"settlement_date_merchant": "2022-01-12 11:00:00",
"created_at": "2022-01-07T15:24:26.000000Z",
"updated_at": "2022-01-31T14:44:28.000000Z",
"recurring_id": 0,
"order_id": "164155825918674",
"ip": "85.99.21.139",
"refunded_chargeback_fee": 3.001,
"transaction_state_label": "Refunded",
"currency_code": "TRY",
"created_at_int": 20220107,
"updated_at_int": 20220131,
"sale_recurring": null,
"sale_billing": {
"id": 43609,
"sale_id": 23,
"card_holder_name": "şeyma"
},
"refund_history": {
"id": 175,
"sale_id": 23,
"transaction_state_id": 1,
"amount": 0.1,
"transaction_state_label": "Completed"
},
"sale_recurring_history": []
}
],
"paginate_data": {
"current_page": 1,
"total": 4,
"per_page": 50,
"last_page": 1,
"next_page_url": null,
"previous_page_url": null,
"current_page_url": "<ACCESS_URL>/api/getTransactions?page=1",
"last_page_url": "<ACCESS_URL>/api/getTransactions?page=1"
}
}
}Başarısız Yanıt
json
{
"status_code": 90,
"status_description": "Invalid Hash key"
}Kod Örnekleri
PHP Örnek Kodu
PHP
<?php
if (isset($_POST['process_payment'])) {
// Temel değişkenleri tanımla
$baseUrl = "https://staging.halkode.com.tr/ccpayment/api/getTransactions";
include 'degisken.php';
$invoice_id = $_POST['invoice_id'];
$credit_card = $_POST['credit_card'];
$amount = $_POST['amount'];
$currency_code = $_POST['currency_code'];
$date = date('Y-m-d'); // Güncel tarihi al
// Token isteği
$tokenResponse = getToken($app_id, $appSecret);
$decodedTokenResponse = json_decode($tokenResponse, true);
if ($decodedTokenResponse['status_code'] == 100) {
$token = $decodedTokenResponse['data']['token'];
} else {
echo "<p><strong>Hata:</strong> Token alınamadı. Lütfen bilgilerinizi kontrol ediniz.</p>";
return;
}
// Formdan verileri topla
$data = array(
"merchant_key" => $merchant_key,
"date" => $date,
"invoiceid" => $invoice_id,
"credit_card" => $credit_card,
"amount" => $amount,
"currency_code" => $currency_code,
);
// Gönderilen verileri göster
echo "<h3>Gönderilen Veriler</h3>";
echo "<pre>" . htmlspecialchars(json_encode($data, JSON_PRETTY_PRINT)) . "</pre>";
// Ödeme isteğini göndermek için CURL
$ch = curl_init($baseUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
"Authorization: Bearer $token"
));
$jsonData = json_encode($data);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
// Yanıtı göster
echo "<h3>Yanıt</h3><pre>" . htmlspecialchars($response) . "</pre>";
// Güncel tarihi göster
echo "<h3>Güncel Tarih</h3><p>$date</p>"; // Güncel tarihi burada gösteriyoruz
}
?>C# /.NET Örnek Kodu
C#
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;
using System.Net.Http.Json;
public async Task ProcessPayment() {
using var client = new HttpClient();
// 1. REQUEST Verisini Hazırla
var paymentRequest = new {
merchant_key = "MS_12345",
date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
invoiceid = "INV1001",
credit_card = "4132*********0003",
amount = 150,
currency_code = "TRY"
};
try {
// 2. REQUEST Gönder
Console.WriteLine("İstek gönderiliyor...");
HttpResponseMessage response = await client.PostAsJsonAsync("https://staging.halkode.com.tr/ccpayment/api/getTransactions", paymentRequest);
// 3. RESPONSE Al ve İşle
if (response.IsSuccessStatusCode) {
// Cevabı JSON olarak oku
var result = await response.Content.ReadFromJsonAsync<dynamic>();
Console.WriteLine($"Başarılı! Sunucu Yanıtı: {result}");
} else {
// Hata durumunda status kodunu al
string errorBody = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Hata oluştu! Kod: {response.StatusCode}, Detay: {errorBody}");
}
} catch (Exception ex) {
Console.WriteLine($"Bağlantı hatası: {ex.Message}");
}
}JavaScript / NodeJs Örnek Kodu
JavaScript
async function handlePaymentRequest() {
const apiURL = "https://staging.halkode.com.tr/ccpayment/api/getTransactions";
// 1. REQUEST Verisini Hazırla
const data = {
merchant_key: "MS_12345",
date: new Date().toISOString().slice(0, 19).replace('T', ' '),
invoiceid: "INV1001",
credit_card: "4132*********0003",
amount: 150,
currency_code: "TRY"
};
console.log("Request gönderiliyor:", data);
try {
// 2. REQUEST Gönder
const response = await fetch(apiURL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
// 3. RESPONSE Al ve İşle
if (response.ok) {
const result = await response.json(); // JSON yanıtını çöz
console.log("Response başarıyla alındı:", result);
if(result.status_code === 100) {
alert("İşlem Başarılı: " + result.message);
}
} else {
const errorText = await response.text();
console.error("Sunucu hatası döndü:", response.status, errorText);
}
} catch (error) {
console.error("İstek başarısız oldu (Network Error):", error);
}
}
