PHPackages                             tahsilat/tahsilat-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tahsilat/tahsilat-php

ActiveLibrary[API Development](/categories/api)

tahsilat/tahsilat-php
=====================

Tahsilat Payment Gateway PHP SDK

v1.2.2(2w ago)044MITPHPPHP &gt;=7.4.0

Since Jun 10Pushed 2w agoCompare

[ Source](https://github.com/tahsilatdev/tahsilat-php)[ Packagist](https://packagist.org/packages/tahsilat/tahsilat-php)[ Docs](https://github.com/tahsilat/tahsilat-php)[ RSS](/packages/tahsilat-tahsilat-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (15)Used By (0)

Tahsilat PHP SDK
================

[](#tahsilat-php-sdk)

Tahsilat Payment Gateway için resmi PHP SDK.

> ⚠️ **Önemli:** Bu SDK, güvenlik nedeniyle PHP 7.4 ve üzeri sürümleri desteklemektedir. PHP 7.3 ve altı sürümler bilinen güvenlik açıkları içerdiğinden artık desteklenmemektedir. Eğer eski PHP sürümlerinde kullanmanız gerekiyorsa [v1.1.9](https://github.com/tahsilatdev/tahsilat-php/releases/tag/v1.1.9) sürümünü kullanabilirsiniz, ancak bu sürüm artık güncelleme almamaktadır ve kullanımı önerilmemektedir.

Gereksinimler
-------------

[](#gereksinimler)

- **PHP 7.4.0 veya üzeri** (güvenlik nedeniyle 7.4'ün altındaki sürümler desteklenmemektedir)
- cURL extension
- JSON extension
- mbstring extension
- OpenSSL extension

Kurulum
-------

[](#kurulum)

### Composer ile kurulum (Önerilen):

[](#composer-ile-kurulum-önerilen)

```
composer require tahsilat/tahsilat-php
```

### Manuel kurulum:

[](#manuel-kurulum)

```
require_once '/path/to/tahsilat-php/init.php';
```

Hızlı Başlangıç
---------------

[](#hızlı-başlangıç)

### Client Başlatma

[](#client-başlatma)

```
$tahsilat = new \Tahsilat\TahsilatClient('sk_test_YOUR_SECRET_KEY');
```

> **Önemli:** Sadece secret key'ler (`sk_test_*` veya `sk_live_*`) kabul edilir. Public key'ler (`pk_*`) server-side API çağrıları için kullanılamaz.

### Müşteri Oluşturma

[](#müşteri-oluşturma)

```
$customer = $tahsilat->customers->create([
    'name' => 'John',
    'lastname' => 'Doe',
    'email' => 'john.doe@example.com',
    'phone' => '5551234567',
    'country' => 'TR',
    'city' => 'Istanbul',
    'district' => 'Kadıköy',
    'address' => '123 Main St',
    'zip_code' => '34710',
    'metadata' => [
        'customer_type' => 'premium',
        'source' => 'website'
    ]
]);

echo $customer->id;
```

### Ürün Oluşturma

[](#ürün-oluşturma)

```
$product = $tahsilat->products->create([
    'product_name' => 'Premium Subscription',
    'price' => 9999, // kuruş cinsinden (99.99 TL)
    'description' => 'Aylık premium üyelik',
    'metadata' => [
        'category' => 'subscription'
    ]
]);

echo $product->id;
```

### Ödeme Oluşturma

[](#ödeme-oluşturma)

#### Ürün Bilgileri ile

[](#ürün-bilgileri-ile)

```
$payment = $tahsilat->payments->create([
    'amount' => 20000, // kuruş cinsinden (200.00 TL)
    'currency' => 'TRY',
    'redirect_url' => 'https://example.com/payment/callback',
    'products' => [
        [
            'product_name' => 'Ürün 1',
            'price' => 10000,
            'description' => 'Birinci ürün'
        ],
        [
            'product_name' => 'Ürün 2',
            'price' => 10000,
            'description' => 'İkinci ürün'
        ]
    ],
    'metadata' => [
        'order_id' => 'order_12345'
    ],
    'description' => 'Sipariş #12345'
]);

echo $payment->payment_page_url; // Ödeme sayfası URL'i
echo $payment->transaction_id;   // İşlem ID
```

#### Kayıtlı Ürün ID'leri ile

[](#kayıtlı-ürün-idleri-ile)

```
$payment = $tahsilat->payments->create([
    'amount' => 20000,
    'currency' => 'TRY',
    'redirect_url' => 'https://example.com/payment/callback',
    'product_ids' => [55437751141488, 84920468860151],
    'customer_id' => 20585467989184
]);
```

### İşlem Sorgulama

[](#i̇şlem-sorgulama)

```
$transaction = $tahsilat->transactions->retrieve(78810412652494);

echo $transaction->transaction_id;
echo $transaction->payment_status_text; // success, fail, incomplete
echo $transaction->transaction_status_text; // completed, pending, cancelled
echo $transaction->amount;

// Başarı kontrolü
if ($transaction->isSuccess()) {
    echo "Ödeme başarılı!";
}

if ($transaction->isFail()) {
    echo "Ödeme başarısız: " . $transaction->transaction_message;
}
```

### İade İşlemi

[](#i̇ade-i̇şlemi)

```
$refund = $tahsilat->transactions->refund([
    'transaction_id' => 78810412652494,
    'amount' => 5000, // Kısmi iade (50.00 TL)
    'description' => 'Müşteri talebi ile iade'
]);
```

### BIN Sorgulama

[](#bin-sorgulama)

```
$bin = $tahsilat->binLookup->detail([
    'bin_number' => '489455'
]);

echo $bin->bank_name;
echo $bin->card_type;    // credit, debit
echo $bin->card_brand;   // visa, mastercard
```

### Komisyon Sorgulama

[](#komisyon-sorgulama)

```
$commissions = $tahsilat->commissions->search();
```

Response Kullanımı
------------------

[](#response-kullanımı)

Tüm API yanıtları resource objeleri olarak döner. Bu objeler üzerinde çeşitli metodlar kullanabilirsiniz:

```
$transaction = $tahsilat->transactions->retrieve(11810465249113);

// Tek değer alma
echo $transaction->amount;
echo $transaction->get('amount');
echo $transaction->get('transaction_id');

// Tüm veriyi array olarak alma
$data = $transaction->toArray();
print_r($data);

// JSON olarak alma
echo $transaction->toJson();
echo $transaction->toJson(JSON_PRETTY_PRINT);

// Değer kontrolü
if ($transaction->has('metadata')) {
    // metadata alanı mevcut
}

if ($transaction->isNull('transaction_code')) {
    // transaction_code null
}
```

Konfigürasyon
-------------

[](#konfigürasyon)

```
$tahsilat = new \Tahsilat\TahsilatClient('sk_test_YOUR_SECRET_KEY', [
    'max_retries' => 5,
    'timeout' => 120,
    'connect_timeout' => 60,
    'verify_ssl_certs' => true
]);

// Veya setter ile
$tahsilat->setConfig('timeout', 120);
```

Hata Yönetimi
-------------

[](#hata-yönetimi)

```
use Tahsilat\Exception\ApiErrorException;
use Tahsilat\Exception\AuthenticationException;
use Tahsilat\Exception\InvalidRequestException;
use Tahsilat\Exception\NetworkException;
use Tahsilat\Exception\TahsilatException;

try {
    $payment = $tahsilat->payments->create([
        'amount' => 10000,
        'currency' => 'TRY'
    ]);
} catch (AuthenticationException $e) {
    // Geçersiz API key
    echo 'Kimlik doğrulama hatası: ' . $e->getMessage();
} catch (InvalidRequestException $e) {
    // Geçersiz istek (örn: işlem bulunamadı)
    echo 'Geçersiz istek: ' . $e->getMessage();
} catch (ApiErrorException $e) {
    // API hatası
    echo 'API Hatası: ' . $e->getMessage();
    echo 'Hata Kodu: ' . $e->getErrorCode();
    print_r($e->getResponseData());
} catch (NetworkException $e) {
    // Ağ hatası
    echo 'Ağ Hatası: ' . $e->getMessage();
} catch (TahsilatException $e) {
    // Genel SDK hatası
    echo 'Hata: ' . $e->getMessage();
}
```

API Key Türleri
---------------

[](#api-key-türleri)

Key TürüFormatKullanımSecret Test`sk_test_*`Test ortamı - tam erişimSecret Live`sk_live_*`Canlı ortam - tam erişim> **Not:** Public key'ler (`pk_test_*`, `pk_live_*`) bu SDK ile kullanılamaz. Client-side işlemler için JavaScript SDK kullanın.

Webhook Doğrulama
-----------------

[](#webhook-doğrulama)

> **Uyarı:** Webhook endpoint'iniz harici bir POST isteği aldığı için CSRF korumasından muaf tutulmalıdır. Laravel kullanıyorsanız webhook route'unu CSRF doğrulamasından hariç tutun, aksi takdirde 419 hatası alırsınız.

Her webhook isteği `X-Tahsilat-Signature` başlığı ile HMAC-SHA256 imzası içerir. İmza formatı: `t=timestamp,v1=signature`.

```
use Tahsilat\Util\Webhook;

$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_TAHSILAT_SIGNATURE'] ?? '';
$webhookSecret = 'whsec_your_webhook_secret';

try {
    $event = Webhook::constructEvent($payload, $signature, $webhookSecret);

    // Event tipine göre işlem yapın
    if ($event->isSuccess()) {
        $transactionId = $event->getTransactionId();
        // Ödeme başarılı işlemleri
    }

    if ($event->isFail()) {
        // Ödeme başarısız işlemleri
    }

    http_response_code(200);
} catch (\Tahsilat\Exception\SignatureVerificationException $e) {
    http_response_code(400);
    echo 'Geçersiz imza';
}
```

```
- **HMAC-SHA256 webhook imzası** - Webhook istekleri timestamp ve payload ile imzalanır
```

PHP Sürüm Uyumluluğu
--------------------

[](#php-sürüm-uyumluluğu)

Bu SDK PHP 7.4'den PHP 8.4'e kadar tüm sürümlerle uyumludur.

PHP SürümüDurum5.x - 7.3❌ Desteklenmiyor7.4 - 8.5✅ DestekleniyorGüvenlik
--------

[](#güvenlik)

Bu SDK aşağıdaki güvenlik önlemlerini içerir:

- **Minimum PHP 7.4 gereksinimi**
- **SSL sertifika doğrulama** - Varsayılan olarak aktif
- **HMAC-SHA256 webhook imzası** - Webhook istekleri timestamp ve payload ile imzalanır
- **Timing-safe string comparison** - Webhook imza doğrulamasında timing attack koruması
- **Header injection koruması** - HTTP header'larında CR/LF karakterleri temizlenir
- **SSRF koruması** - HTTP redirect'ler devre dışı

Lisans
------

[](#lisans)

MIT License - detaylar için LICENSE dosyasına bakın.

Destek
------

[](#destek)

- Dokümantasyon:
- E-posta:

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance96

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Total

11

Last Release

19d ago

PHP version history (2 changes)v1.1.2PHP &gt;=5.6.0

v1.2.0PHP &gt;=7.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/56b4637a6e19a7ec95294b6d833cf210eec79cc32a08cd68b26bf4b20eebbcf1?d=identicon)[berkfuat](/maintainers/berkfuat)

---

Top Contributors

[![berkfuat](https://avatars.githubusercontent.com/u/93516491?v=4)](https://github.com/berkfuat "berkfuat (24 commits)")[![br9](https://avatars.githubusercontent.com/u/106991787?v=4)](https://github.com/br9 "br9 (1 commits)")

---

Tags

apipaymentgatewayposcredit-card3dstahsilat

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tahsilat-tahsilat-php/health.svg)

```
[![Health](https://phpackages.com/badges/tahsilat-tahsilat-php/health.svg)](https://phpackages.com/packages/tahsilat-tahsilat-php)
```

###  Alternatives

[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60216.0M85](/packages/mollie-mollie-api-php)[mollie/magento2

Mollie Payment Module for Magento 2

1131.9M16](/packages/mollie-magento2)[camcima/redecard-komerci-client

Client for Redecard Gateway - Komerci

1110.6k](/packages/camcima-redecard-komerci-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
