Yapılan Tüm İşlemleri Getirme
Bu API, aşağıda belirtilen parametreler kullanılarak tüm işlemleri görüntülemek için kullanılabilir.
İstek Bilgileri
- Metot:
POST - URL:
https://staging.halkode.com.tr/ccpayment/api/alltransaction - CANLI URL:
https://app.halkode.com.tr/ccpayment/api/alltransaction - Yetkilendirme:
Bearer {token}Token Alma servisinden alınan değer
İstek Parametreleri (Body)
| Parametre | Tip | Koşul | Açıklama |
|---|---|---|---|
transaction_id | string | Opsiyonel | Satış işlem ID bilgisi. |
invoice_id | string | Opsiyonel | Sizin tarafınızdaki tekil sipariş ID. |
order_id | string | Opsiyonel | Satış sipariş ID bilgisi. |
payment_method | int | Opsiyonel | Ödeme metodu ID bilgisi (paymet_method: 1= Credit Card, 2= Mobile, 3= Wallet). |
transactionState | string | Opsiyonel | İşlem durumu. Eğer 1 ise 'Tamamlandı', 3 ise 'Beklemede'. |
date_range | string | Opsiyonel | İşlemlerin getirileceği tarih aralığı. Örnek: ‘2021-04-20 - 2021-04-20’ |
currency_code | string | Opsiyonel | Para birimi kodu. |
amount | int | Opsiyonel | Tutar. |
minamount | int | Opsiyonel | Minimum tutar. |
maxamount | int | Opsiyonel | Maximum tutar. |
billing_phone | string | Opsiyonel | Fatura için kayıtlı telefon numarası. |
billing_email | string | Opsiyonel | Fatura için kayıtlı mail adresi. |
search_key | any | Opsiyonel | order_id, invoice_id, merchant_name gibi arama yapılacak sütun adlarından biri, arama anahtarı. |
order | string | Opsiyonel | Azalan veya artan şekilde sıralama seçimi (asc/desc). |
page_limit | string | Opsiyonel | Her seferinde kaç kayıt getirileceğini belirler. |
Örnek İstek (Request)
json
{
"transaction_id": "",
"invoice_id": "",
"order_id": "",
"payment_method": "",
"transactionState": "",
"date_range": "2021/12/23 - 2022/01/23",
"currency_code": "TRY",
"amount": "",
"maxamount": "",
"minamount": "",
"billing_phone": "",
"billing_email": "",
"search_key": "vPiWL-pMmb-TC10-98950-230122",
"order": "desc",
"page_limit":"2"
}Başarılı Yanıt
json
{
"status_code": 100,
"status_description": "data fetched successfully",
"data": {
"current_page": 1,
"data": [
{
"id": 287447,
"payment_id": "vPiWL-pMmb-TC10-98950-230122",
"invoice_id": "14391",
"order_id": "164290959020713",
"remote_order_id": "",
"user_id": 12,
"end_user_id": 0,
"user_name": "",
"merchant_id": 98950,
"merchant_name": "Fintlix Demo",
"transaction_state_id": 3,
"purchase_id": 0,
"gross": 5,
"refund_request_amount": 0,
"fee": 0.1,
"net": 4.9,
"pay_by_token_fee": 0,
"cost": 0.05,
"rolling_amount": 0,
"product_price": 5,
"user_commission": 0,
"merchant_commission": 0.1,
"gsm_number": "",
"settlement_date_bank": "",
"settlement_date_merchant": "",
"payment_type_id": 1,
"operator": "",
"issuer_name": "DENIZBANK A.S.",
"card_program": "",
"card_issuer_name": "",
"pos_name": "Deniz DCC Try Pos",
"pos_id": 113,
"allocation_id": 0,
"campaign_id": 0,
"dpl_id": 0,
"json_data": "{\"action\":\"WL_REQUEST_PAY_SMART_3D\",\"transaction_type\":\"Auth\",\"merchant_key\":\"$2y$10$w\\/ODdbTmfubcbUCUq\\/ia3OoJFMUmkM1UVNBiIQIuLfUlPmaLUT1he\",\"invoice_id\":\"14391\",\"total\":\"5\",\"items\":[{\"name\":\"Test Product\",\"price\":\"5.00\",\"quantity\":1,\"description\":\"Some Description\"}],\"currency_code\":\"TRY\",\"cc_no\":\"cJ>_uWL@_fv<2ad9:tE@_:bxl37OOAv0mU4GU4pngAsnLel6pIezOQR\\/kZtJeryKE=\",\"installments_number\":1,\"cancel_url\":\"https:\\/\\/localhost\\/app.halkode.com.tr\\/api\\/payment_success.php?merchant_key=%242y%2410%24w%2FODdbTmfubcbUCUq%2Fia3OoJFMUmkM1UVNBiIQIuLfUlPmaLUT1he\",\"return_url\":\"https:\\/\\/localhost\\/app.halkode.com.tr\\/api\\/payment_success.php?merchant_key=%242y%2410%24w%2FODdbTmfubcbUCUq%2Fia3OoJFMUmkM1UVNBiIQIuLfUlPmaLUT1he\",\"hash_key\":\"645e82f0848a9279:e319:x2odQXfr+xcmL0OSE6qMxs81SJiAu9p+nQjaY618glpH5Io6+4pFL68rNZYZkz+B4l4+l3JpF2zIEGG7k8pM63G0+jbsct+gEVv3cbjNEvg=\",\"name\":\"Customer Name\",\"surname\":\"Customer surname\",\"saved_card\":0,\"maturity_period\":\"0\",\"payment_frequency\":\"0\",\"pf_id\":\"\",\"bill_address1\":\"Address 1 should not more than 100\",\"bill_address2\":\"Address 2\",\"bill_city\":\"Istanbul\",\"bill_postcode\":\"1111\",\"bill_state\":\"Istanbul\",\"bill_country\":\"TURKEY\",\"bill_phone\":\"008801777711111\",\"bill_email\":\"demo@your-domain.com\",\"sale_web_hook_key\":\"\",\"merchant_server_id\":\"\",\"referer_url\":\"https:\\/\\/localhost\\/app.halkode.com.tr\\/public\\/api\\/paySmart3D\\/payment_page.php\",\"api_name\":\"PAY_SMART_3D\",\"payment_type\":\"3d\",\"is_pay_by_marketplace\":0,\"currency_id\":1,\"pos_id\":113,\"campaign_id\":0,\"allocation_id\":0,\"is_tarim_payment\":false,\"installment\":1,\"merchant_ip\":\"\",\"part_2\":\"cJ>_uWL@_fv<2ad9:tE@_:jocdjiBevAneTYND6J6mOg==\",\"part_1\":\"cJ>_uWL@_fv<2ad9:tE@_:oFAEwm\\/gdXomWrR\\/QofemQ==\"}",
"document": "",
"total_refunded_amount": 0,
"refund_reason": "",
"refund_request_date": "",
"admin_process_date": "",
"chargeback_reject_explanation": "",
"created_at": "2022-01-23T03:46:30.000000Z",
"updated_at": "2022-01-23T03:46:30.000000Z",
"currency_id": 1,
"currency_symbol": "₺",
"installment": 1,
"maturity_period": 0,
"payment_frequency": 0,
"ip": "::1",
"result": "",
"credit_card_no": "546938****2434",
"card_holder_bank": "",
"sale_version": 0,
"sale_type": 1,
"payment_source": 5,
"refunded_chargeback_fee": 0,
"is_bank_refund_failed": 0,
"recurring_id": 0,
"sale_web_hook_key": "",
"auth_code": "",
"migration_status": 3,
"is_comission_from_user": 0,
"sale_recurring": "",
"paymenttype": {
"id": 1,
"name": "Credit Card",
"created_at": "2019-07-31T02:52:28.000000Z",
"updated_at": "2019-07-31T02:52:28.000000Z"
},
"rolling_balance": "",
"sale_integrator": "",
"sale_billing": "",
"sale_property": ""
}
],
"first_page_url": "https://localhost/app.halkode.com.tr/ccpayment/api/alltransaction?page=1",
"from": 1,
"last_page": 1,
"last_page_url": "https://localhost/app.halkode.com.tr/ccpayment/api/alltransaction?page=1",
"next_page_url": "",
"path": "https://localhost/app.halkode.com.tr/ccpayment/api/alltransaction",
"per_page": "2",
"prev_page_url": "",
"to": 1,
"total": 1
}
}Başarısız Yanıt
json
{
"status_code": 99
"status_description": "failed",
"data": []
}Kod Örnekleri
PHP Örnek Kodu
PHP
<?php
if (isset($_POST['process_payment'])) {
$baseUrl = "https://staging.halkode.com.tr/ccpayment/api/alltransaction";
include 'degisken.php';
// 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" => $merchantKey,
);
// 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ı alt alta göstermek için tabloyu kullan
echo "<h3>Yanıt</h3>";
$decodedResponse = json_decode($response, true);
echo "<table class='table table-bordered'>
<thead>
<tr>
<th>Alan</th>
<th>Değer</th>
</tr>
</thead>
<tbody>";
// Yanıt dizisini tek tek işleyip her birini tabloya alt alta ekle
foreach ($decodedResponse as $key => $value) {
// Eğer değer bir dizi ise, onu JSON formatında string'e çevir
if (is_array($value)) {
$value = json_encode($value, JSON_PRETTY_PRINT);
}
echo "<tr>
<td>" . htmlspecialchars($key) . "</td>
<td>" . htmlspecialchars($value) . "</td>
</tr>";
}
echo "</tbody></table>";
}
function generateHashKey($total, $installment, $currency_code, $merchant_key, $invoice_id, $app_secret)
{
$data = $total . '|' . $installment . '|' . $currency_code . '|' . $merchant_key . '|' . $invoice_id;
$iv = substr(sha1(mt_rand()), 0, 16);
$password = sha1($app_secret);
$salt = substr(sha1(mt_rand()), 0, 4);
$saltWithPassword = hash('sha256', $password . $salt);
$encrypted = openssl_encrypt("$data", 'aes-256-cbc', "$saltWithPassword", 0, $iv);
$msg_encrypted_bundle = "$iv:$salt:$encrypted";
$msg_encrypted_bundle = str_replace('/', '__', $msg_encrypted_bundle);
return $msg_encrypted_bundle;
}
function getToken($app_id, $app_secret)
{
$baseUrl = "https://staging.halkode.com.tr/ccpayment/api/token";
$data = array('app_id' => $app_id, 'app_secret' => $app_secret);
$jsonData = json_encode($data);
$ch = curl_init($baseUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
?>C# /.NET Örnek Kodu
C#
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;
public class AlltransactionController : Controller
{
private const string URL = "api/alltransaction";
public readonly HttpClient _httpClient;
public readonly ApiSettings _apiSettings; // BASE_URL TANIMLAMASINI BU SINIFA YAPABİLİRSİNİZ.
public AlltransactionController()
{
_httpClient = new HttpClient();
_apiSettings = new ApiSettingConfiguration().Configuration();
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Index(string merchant_key)
{
if (string.IsNullOrEmpty(merchant_key))
{
ModelState.AddModelError("merchant_key", "merchantkey gereklidir.");
return View();
}
var token = await GetTokenAsync();
if (string.IsNullOrEmpty(token))
{
ViewBag.Error = "Token alınamadı. Lütfen bilgilerinizi kontrol ediniz.";
return View();
}
var data = new
{
merchant_key = merchant_key
};
ViewBag.RequestData = data;
var jsonResponse = await PostDataAsync($"{_apiSettings.BaseAddress}{URL}", data, token);
ViewBag.ResponseData = JsonConvert.DeserializeObject(jsonResponse);
return View();
}
private async Task<string> GetTokenAsync()
{
var tokenUrl = _apiSettings.TokenUrls;
var data = new
{
app_id = _apiSettings.AppId,
app_secret = _apiSettings.AppSecret
};
using (var client = new HttpClient())
{
var jsonRequest = JsonConvert.SerializeObject(data);
var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
var response = await client.PostAsync(tokenUrl, httpContent);
var jsonResponse = await response.Content.ReadAsStringAsync();
var tokenResponse = JsonConvert.DeserializeObject<dynamic>(jsonResponse);
if (tokenResponse.status_code == 100)
{
return tokenResponse.data.token;
}
return null;
}
}
private async Task<string> PostDataAsync(string url, object data, string token)
{
using (var client = new HttpClient())
{
var jsonRequest = JsonConvert.SerializeObject(data);
var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
var response = await client.PostAsync(url, httpContent);
return await response.Content.ReadAsStringAsync();
}
}
}JavaScript / NodeJs Örnek Kodu
JavaScript
async function sendMerchantKey(merchantKey) {
const apiUrl = "https://staging.halkode.com.tr/ccpayment/api/alltransaction";
// 1. REQUEST (İstek) Verisini Hazırla
const requestData = {
merchant_key: merchantKey
};
console.log("İstek gönderiliyor:", requestData);
try {
// 2. REQUEST Gönderimi (POST metodu ile)
const response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData) // Veriyi JSON metnine çevirir
});
// 3. RESPONSE (Yanıt) Karşılama
if (!response.ok) {
throw new Error(`Sunucu hatası: ${response.status}`);
}
const responseData = await response.json(); // Gelen yanıtı JSON olarak oku
console.log("Yanıt alındı:", responseData);
if (responseData.status_code === 100) {
console.log("İşlem Başarılı!");
}
return responseData;
} catch (error) {
console.error("Bir hata oluştu:", error.message);
}
}
