AZA-ZPayA-ZPay banka transferi API’si

Authentication

A-ZPay public entegrasyon authentication modeli imzalı partner API’dir. Partner portal login ve oyuncu handoff akışları makineden makineye API route’u değildir; casino entegrasyonları yalnızca bu dokümantasyondaki endpoint’leri imzalamalıdır.

Partner API imzası

Her partner API isteği şu header’ları içermelidir:

X-Api-Key: pk_live_xxx
X-Timestamp: 1778940000
X-Signature: <hex hmac>

Her casino partner panelinde üç entegrasyon değeri görür:

  • apiKey: X-Api-Key olarak gönderilir.
  • apiSecret: HMAC anahtarıdır.
  • hashSecret: canonical string’in son segmenti olarak eklenir.

İmza, şu metnin HMAC-SHA256 değeridir:

<timestamp>.<METHOD>.<path>.<raw_body>.<hashSecret>

GET isteklerinde raw body boş stringdir; canonical string yine de .<hashSecret> ile biter.

Örnek canonical string:

1778940000.POST./v1/deposits.{"amount":"100.00"}.hs_live_xxx

hashSecret içermeyen eski imzalar reddedilir.

Tekrar kullanılabilir istek imzalayıcı
import crypto from 'node:crypto';

const apiKey = process.env.AZPAY_API_KEY;
const apiSecret = process.env.AZPAY_API_SECRET;
const hashSecret = process.env.AZPAY_HASH_SECRET;

export function signAZPayRequest(method, path, rawBody = '') {
const timestamp = Math.floor(Date.now() / 1000).toString();
const canonical = [timestamp, method.toUpperCase(), path, rawBody, hashSecret].join('.');
const signature = crypto.createHmac('sha256', apiSecret).update(canonical).digest('hex');

return {
  'content-type': 'application/json',
  'x-api-key': apiKey,
  'x-timestamp': timestamp,
  'x-signature': signature,
};
}

const body = JSON.stringify({ amount: '100.00', currency: 'TRY' });
const headers = signAZPayRequest('POST', '/v1/deposits', body);
<?php
function signAZPayRequest(string $method, string $path, string $rawBody = ''): array {
  $apiKey = getenv('AZPAY_API_KEY');
  $apiSecret = getenv('AZPAY_API_SECRET');
  $hashSecret = getenv('AZPAY_HASH_SECRET');
  $timestamp = (string) time();
  $canonical = implode('.', [$timestamp, strtoupper($method), $path, $rawBody, $hashSecret]);
  $signature = hash_hmac('sha256', $canonical, $apiSecret);

  return [
      'content-type: application/json',
      'x-api-key: ' . $apiKey,
      'x-timestamp: ' . $timestamp,
      'x-signature: ' . $signature,
  ];
}

$body = json_encode(['amount' => '100.00', 'currency' => 'TRY'], JSON_UNESCAPED_SLASHES);
$headers = signAZPayRequest('POST', '/v1/deposits', $body);

Timestamp toleransı

X-Timestamp saniye cinsinden Unix timestamp’tir. İzin verilen saat farkının dışındaki istekler reddedilir; partner sunucuları NTP ile senkron tutulmalıdır.

İmzalı GET isteği örneği
const path = '/partner/balance';
const response = await fetch('https://api.azpay.example' + path, {
method: 'GET',
headers: signAZPayRequest('GET', path, ''),
});

if (!response.ok) {
throw new Error('A-ZPay isteği reddetti: ' + response.status);
}

const balance = await response.json();
<?php
$path = '/partner/balance';
$ch = curl_init('https://api.azpay.example' . $path);
curl_setopt_array($ch, [
  CURLOPT_HTTPHEADER => signAZPayRequest('GET', $path, ''),
  CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status < 200 || $status >= 300) {
  throw new RuntimeException('A-ZPay isteği reddetti: ' . $status);
}
$balance = json_decode($response, true);