Skip to content

Token İşlemleri ​

Ödeme işlemlerine başlamadan önce sistemin sizi tanıması ve güvenli bir oturum açılması için bir Token (Erişim Anahtarı) almanız gerekmektedir. Bu token, diğer tüm API çağrılarında yetkilendirme amacıyla kullanılacaktır.

1. Token Alma ​

Bu servis, uygulama kimlik bilgilerinizle (app_id ve app_secret) bir oturum anahtarı üretir. Ayrıca, hesabınıza tanımlı olan 3D Secure ayarlarını da bu aşamada öğrenebilirsiniz.

İstek Bilgileri ​

  • Metot: POST
  • URL: https://staging.halkode.com.tr/ccpayment/api/token
  • CANLI URL: https://app.halkode.com.tr/ccpayment/api/token

İstek Parametreleri (Body) ​

ParametreTipKoşulAçıklama
app_idstringZorunluUygulama Anahtarı
app_secretstringZorunluUygulama Parolası

3D Secure Modları (is_3d)

Yanıt içerisinde dönen is_3d değeri, ödeme akışınızın nasıl olacağını belirler:

  • 0: Yalnızca Whitelabel 2D
  • 1: Whitelabel 2D veya 3D (Seçimli)
  • 2: Yalnızca Whitelabel 3D
  • 4: Markalı ödeme çözümü

Örnek İstek ​

json
{
    "app_id": "YOUR_APP_ID",
    "app_secret": "YOUR_APP_SECRET"
}

Başarılı Yanıt ​

json
{
    "status_code": 100,
    "status_description": "Successfully Generated token",
    "data": {
        "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9...",
        "is_3d": 1,
        "expires_at": "2026-03-10 13:42:54"
    }
}

Başarısız Yanıt ​

json
{
    "status_code": 30,
    "status_description": "Geçersiz kimlik bilgileri"
}

Kod Örnekleri ​

PHP Örnek Kodu
PHP

<?php

function sendRequest($data) {
    
    $url = "https://staging.halkode.com.tr/ccpayment/api/token";
    
    $ch = curl_init($url);
    $payload = json_encode($data);
    
    $headers = [
        'Content-Type: application/json',
        'Accept: application/json'
    ];
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    return json_decode($response, true);
}

$authData = [
    "app_id" => "YOUR_APP_ID",
    "app_secret" => "YOUR_APP_SECRET"
];
$authResult = sendRequest($authData);
print_r($authResult);
?>
C# / .NET Örnek Kodu
C#

using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;

public class HalkodeClient
{
    private static readonly HttpClient client = new HttpClient();

    public async Task<string> GetToken(string appId, string appSecret)
    {
        var url = "https://staging.halkode.com.tr/ccpayment/api/token";
        
        var requestBody = new {
            app_id = appId,
            app_secret = appSecret 
        };
        var json = JsonSerializer.Serialize(requestBody);
        var content = new StringContent(json, Encoding.UTF8, "application/json");

        client.DefaultRequestHeaders.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        var response = await client.PostAsync(url, content);
        return await response.Content.ReadAsStringAsync();
    }
}


var halkode = new HalkodeClient();
var result = await halkode.GetToken("YOUR_APP_ID", "YOUR_APP_SECRET");
Javascript / NodeJs Örnek Kodu
Javascript

const axios = require('axios');

async function getToken(appId, appSecret) {
    try {
        const config = {
            method: 'post',
            // URL doğrudan tam yol olarak belirtilmiştir
            url: 'https://staging.halkode.com.tr/ccpayment/api/token',
            headers: { 
                'Content-Type': 'application/json', 
                'Accept': 'application/json'
            },
            data: {
               "app_id": appId,
               "app_secret": appSecret
            }
        };

        const response = await axios(config);
        return response.data;
    } catch (error) {
        console.error('Hata:', error.response ? error.response.data : error.message);
    }
}

getToken("YOUR_APP_ID", "YOUR_APP_SECRET").then(console.log);