Yapı Kredi Posnet
Yapı Kredi, Posnet adlı sanal pos altyapısını sunar. XML tabanlı API ile ödeme alma, taksitlendirme ve iade işlemleri yapılabilir.
API Bilgileri
- Test URL: https://setmpos.ykb.com/PosnetWebService/XML
- Canlı URL: https://posnet.yapikredi.com.tr/PosnetWebService/XML
- MID: Üye işyeri numarası
- TID: Terminal numarası
1. Posnet Yapılandırma
$mid = '6706598320';
$tid = '67005551';
$posnet_id = '6879';
$enc_key = '10,10,10,10,10,10,10,10';
$amount = '1000';
$currency = 'TL';
$order_id = str_pad(rand(1,9999999999), 20, '0', STR_PAD_LEFT);
2. MAC Hesaplama ve 3D Başlatma
function calculate_posnet_mac($key_str, $data) {
$key = array_map('intval', explode(',', $key_str));
$result = array_fill(0, 8, 0);
for ($i = 0; $i < strlen($data); $i++) {
$current = ord($data[$i]);
$result[$i % 8] ^= $current;
}
$hex = '';
foreach ($result as $byte) {
$hex .= sprintf('%02X', $byte);
}
return $hex;
}
$mac_data = $mid . $tid . $amount . $order_id;
$mac = calculate_posnet_mac($enc_key, $mac_data);
3. XML İle Ödeme İsteği
$xml = '<?xml version="1.0" encoding="utf-8"?>
<posnetRequest>
<mid>' . $mid . '</mid>
<tid>' . $tid . '</tid>
<sale>
<amount>' . $amount . '</amount>
<currencyCode>TL</currencyCode>
<orderID>' . $order_id . '</orderID>
<ccno>4506349116608409</ccno>
<expDate>0730</expDate>
<cvc>000</cvc>
<mac>' . $mac . '</mac>
</sale>
</posnetRequest>';
$ch = curl_init('https://setmpos.ykb.com/PosnetWebService/XML');
curl_setopt($ch, CURLOPT_POSTFIELDS, 'xmldata=' . $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);