Ödeme Sonrası İşlem Durumu Sorgulama
2D/3D kullanılarak ödeme başarıyla tamamlandıktan sonra yapılan işlemin durumunu kontrol etmek için bu API kullanılır.
İstek Bilgileri
- Metot:
POST - URL:
https://staging.halkode.com.tr/ccpayment/api/checkstatus - CANLI URL:
https://app.halkode.com.tr/ccpayment/api/checkstatus - Yetkilendirme:
Bearer {token}Token Alma servisinden alınan değer
İstek Parametreleri (Body)
| Parametre | Tip | Koşul | Açıklama |
|---|---|---|---|
invoice_id | string | Zorunlu | Sizin tarafınızdaki tekil sipariş ID. |
merchant_key | string | Zorunlu | Üye işyeri anahtarınız. |
Örnek İstek (Request)
json
{
"invoice_id":"111112324115312",
"merchant_key": "$2y$10$..."
}Başarılı Yanıt
Daha önceden başarılı bir şekilde gerçekleşen 'VP17744361965081111123' invoice_id bilgisine sahip işlem için sorgulama yapıldığında aşağıdaki örnekte görüldüğü gibi başarılı bir yanıt döner.
json
{
"status_code": 100,
"status_description": "An order has been taken place for this invoice id: VP17744361965081111123",
"transaction_status": "Completed",
"order_id": "VP17744362395298349",
"transaction_id": "TYrjV-YIc-TC10-73979-250326",
"message": "An order has been taken place for this invoice id: VP17744361965081111123",
"reason": "",
"bank_status_code": "",
"bank_status_description": "",
"invoice_id": "VP17744361965081111123",
"total_refunded_amount": 0,
"product_price": "216",
"transaction_amount": 216,
"ref_number": "",
"transaction_type": "Auth",
"original_bank_error_code": "",
"original_bank_error_description": "",
"cc_no": "454671****7894",
"merchant_commission": "0.00",
"user_commission": "0.00",
"settlement_date": "2026-03-26",
"installment": 2,
"pos_bank": "ZİRAAT BANKASI"
}Başarısız Yanıt
Rastgele yazılmış bir 'VP177443619650811111234' invoice_id bilgisi için işlem bulunamaz ve aşağıdaki örnekte görüldüğü gibi başarısız bir yanıt döner.
json
{
"status_code": 32,
"status_description": "Geçersiz fatura kimliği",
"transaction_status": "Failed",
"order_id": "",
"transaction_id": "",
"message": "Geçersiz fatura kimliği",
"reason": "No Request found for this invoice id",
"bank_status_code": "",
"bank_status_description": "",
"invoice_id": "VP177443619650811111234",
"total_refunded_amount": 0,
"product_price": "0",
"transaction_amount": 0,
"ref_number": "",
"transaction_type": "Auth",
"original_bank_error_code": "",
"original_bank_error_description": "",
"cc_no": ""
}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/checkstatus";
include 'degisken.php';
$invoice_id = $_POST['invoice_id'];
// 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(
"invoice_id" => $invoice_id,
"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ı göster
echo "<h3>Yanıt</h3>";
echo "<table class='table table-bordered'>";
echo "<thead><tr><th>Parametre</th><th>Değer</th></tr></thead><tbody>";
// Yanıtı JSON olarak işleyip tabloya ekle
$responseData = json_decode($response, true);
if ($responseData) {
foreach ($responseData as $key => $value) {
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
}
} else {
echo "<tr><td colspan='2'>Yanıt alınamadı.</td></tr>";
}
echo "</tbody></table>";
}
?>C# /.NET Örnek Kodu
C#
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;
public class CheckStatusController : Controller
{
private const string URL = "api/checkstatus";
private readonly HttpClient _httpClient;
private readonly ApiSettings _apiSettings;
public CheckStatusController()
{
_httpClient = new HttpClient();
_apiSettings = new ApiSettingConfiguration().Configuration();
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<IActionResult> ProcessPayment(string invoice_id)
{
var checkStatusRequest = CreateRequestParameter(_apiSettings, invoice_id);
var response = await GetAsync(checkStatusRequest);
ViewBag.RequestData = checkStatusRequest;
ViewBag.ResponseData = response;
return View("Index");
}
private async Task<CheckStatusResponse> GetAsync(CheckStatusRequest checkStatusRequest)
{
var tokenResponse = await new TokenController().GetAsync();
var jsonRequest = JsonSerializer.Serialize(checkStatusRequest);
var httpContent = new StringContent(jsonRequest, Encoding.UTF8, "application/json");
_httpClient.DefaultRequestHeaders.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", tokenResponse?.data?.token);
try
{
var httpResponse = await _httpClient.PostAsync($"{_apiSettings.BaseAddress}{URL}", httpContent);
var jsonResponse = await httpResponse.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize<CheckStatusResponse>(jsonResponse);
}
catch (Exception ex)
{
throw new Exception($"Hata: {ex.Message}");
}
}
private CheckStatusRequest CreateRequestParameter(ApiSettings apiSettings,string invoice_id)
{
var checkStatusRequest = new CheckStatusRequest
{
invoice_id = invoice_id,
merchant_key = apiSettings.MerchantKey,
};
return checkStatusRequest;
}
}JavaScript / NodeJs Örnek Kodu
JavaScript
const axios = require('axios');
async function checkPaymentStatus(invoiceId) {
const baseUrl = "https://staging.halkode.com.tr/ccpayment/api/checkstatus";
try {
// 1. Token İsteği
const tokenResponse = await fetch("https://staging.halkode.com.tr/ccpayment/api/getToken", {
method: 'POST',
body: JSON.stringify({
app_id: credentials.app_id,
app_secret: credentials.appSecret
}),
headers: { 'Content-Type': 'application/json' }
});
const tokenData = await tokenResponse.json();
if (tokenData.status_code !== 100) {
console.error("Hata: Token alınamadı.");
return;
}
const token = tokenData.data.token;
// 2. Gönderilecek Veri Paketi
const requestData = {
invoice_id: invoiceId,
merchant_key: credentials.merchantKey
};
console.log("--- Gönderilen Veriler ---");
console.log(JSON.stringify(requestData, null, 2));
// 3. CheckStatus API İsteği
const response = await fetch(baseUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(requestData)
});
const result = await response.json();
} catch (error) {
console.error("İşlem sırasında bir hata oluştu:", error);
}
}
