İçeriğe geç

API Dokümanı - Taksit Bilgisi Size Ait

2 Çeşit Pay N Kolay API’si bulunmaktadır. Bu API’ler ile kendi ödeme form yapınızı oluşturabilirsiniz.

Section titled “2 Çeşit Pay N Kolay API’si bulunmaktadır. Bu API’ler ile kendi ödeme form yapınızı oluşturabilirsiniz.”

API’ler ile üye işyeri kendi ödeme formunu kullanır.

Postman collection’ını indirmek için tıklayınız. Örnek kodları Postman Code sinppet’inde görebilirsiniz.

Minimum TLS 1.2 kullanılmalıdır. TLS Bağlantı Sorunlarını Çözme Kılavuzu için tıklayınız.

1 - Pay N Kolay API ( Taksitleri kendi taksit tablolarınızdan getirmek isterseniz kullanacağınız versiyon )

image

  • Payment Servis test ortam linki: “https://paynkolaytest.nkolayislem.com.tr/Vpos/v1/Payment” İlgili tüm değişkenleri Postman collection’ından görebilirsiniz.
  • İşlem, 3D değilse ödeme alınır ve successURL sayfanıza response parametreleri dönülür. Response Dönüş Parametreleri
  • use3D “true” ise 3D formu gelecektir. Bu formu şu şekilde ekranda çalıştırabilirsiniz.

image

example.php
<?php
// 1. Secure your keys (These should ideally be in constants or config)
$merchantSecretKey = "_YckdxUbv4vrnMUZ6VQsr";
$sx = "118591467|bScbGDYCtPf7SS1N6PQ6/+58rFhW1WpsWINqvkJFaJlu6bMH2tgPKDQtjeA5vClpzJP24uA0vx7OX53cP3SgUspa4EvYix+1C3aXe++8glUvu9Oyyj3v300p5NP7ro/9K57Zcw==";
// 2. Prepare variables
$clientRefCode = "APP000000000017|82343"; // Unique reference
$amount = "10.00";
$successUrl = "https://paynkolay.com.tr/biz/success";
$failUrl = "https://paynkolay.com.tr/biz/fail";
$rnd = date("d-m-Y H:i:s");
$customerKey = "";
$merchantCustomerNo = "CUST0001";
// 3. Generate Hash
$hashstr = $sx . "|" . $clientRefCode . "|" . $amount . "|" . $successUrl . "|" . $failUrl . "|" . $rnd . "|" . $customerKey . "|" . $merchantSecretKey;
$hash = mb_convert_encoding($hashstr, 'UTF-8');
$hashedBytes = hash("sha512", $hash, true);
$hashDataV2 = base64_encode($hashedBytes);
/**
* IP detection
*/
function getClientIpAddress(): string {
$headers = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'];
foreach ($headers as $header) {
if (!empty($_SERVER[$header])) {
$ipList = explode(',', $_SERVER[$header]);
$ip = trim($ipList[0]);
if (filter_var($ip, FILTER_VALIDATE_IP)) return $ip;
}
}
return '127.0.0.1';
}
$cardHolderIP = getClientIpAddress();
// 4. API Request
$postData = [
'sx' => $sx,
'clientRefCode' => $clientRefCode,
'successUrl' => $successUrl,
'failUrl' => $failUrl,
'amount' => $amount,
'installmentNo' => '1',
'cardHolderName' => 'Tuna Cinar',
'month' => '12',
'year' => '2026',
'cvv' => '001',
'cardNumber' => '4546711234567894',
'use3D' => 'true',
'transactionType' => 'SALES',
'cardHolderIP' => $cardHolderIP,
'hashDatav2' => $hashDataV2,
'rnd' => $rnd,
'environment' => 'API',
'currencyNumber' => '949',
'MerchantCustomerNo' => $merchantCustomerNo
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://paynkolaytest.nkolayislem.com.tr/Vpos/v1/Payment',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($postData), // Cleaner than passing raw array
CURLOPT_TIMEOUT => 30,
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . htmlspecialchars($err);
} else {
$data = json_decode($response, true);
// 5. BANK_REQUEST_MESSAGE Output
echo $bankMessage = $data['BANK_REQUEST_MESSAGE'] ?? 'No message returned';
}
  • Gelen 3D form ekrana basıldığında ilgili bankanın 3D secure penceresi açılır ve burada 3D secure şifresi girilmesi beklenir.
3D Secure Window