# 1) Taksitleri sorgula
curl -X POST https://api.yucepay.com/api/payment/installment-options \
-H "X-Api-Key: pk_live_..." -H "Content-Type: application/json" \
-d '{ "binNumber": "411111", "amount": 149.90 }'
# 2) 3D ödeme başlat
curl -X POST https://api.yucepay.com/api/payment/pay3d \
-H "X-Api-Key: pk_live_..." -H "Content-Type: application/json" \
-d '{ "idempotencyKey":"ord-1", "amount":149.90, "cardNo":"4111111111111111",
"cardHolderName":"AHMET YILMAZ", "expireMonth":"12", "expireYear":"28",
"cvv":"123", "products":[{"id":"1","name":"Ürün","amount":149.90}] }'
# → data.redirectHtml tarayıcıda render edilir
public class YucePayClient {
private readonly HttpClient _http;
public YucePayClient(string apiKey) {
_http = new HttpClient { BaseAddress = new Uri("https://api.yucepay.com") };
_http.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
}
public Task<HttpResponseMessage> Pay3d(object body) =>
_http.PostAsJsonAsync("/api/payment/pay3d", body);
// Webhook imza doğrulama
public static bool Verify(string payload, string sig, string secret) {
using var h = new System.Security.Cryptography.HMACSHA256(
System.Text.Encoding.UTF8.GetBytes(secret));
var hex = Convert.ToHexString(
h.ComputeHash(System.Text.Encoding.UTF8.GetBytes(payload))).ToLower();
return System.Security.Cryptography.CryptographicOperations.FixedTimeEquals(
System.Text.Encoding.UTF8.GetBytes(hex),
System.Text.Encoding.UTF8.GetBytes(sig));
}
}
<?php
class YucePay {
public function __construct(private string $apiKey) {}
public function pay3d(array $body): array {
$ch = curl_init('https://api.yucepay.com/api/payment/pay3d');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["X-Api-Key: {$this->apiKey}", 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($body),
]);
return json_decode(curl_exec($ch), true);
}
public static function verify(string $payload, string $sig, string $secret): bool {
return hash_equals(hash_hmac('sha256', $payload, $secret), $sig);
}
}
class YucePay {
constructor(apiKey) { this.apiKey = apiKey; }
async pay3d(body) {
const res = await fetch('https://api.yucepay.com/api/payment/pay3d', {
method: 'POST',
headers: { 'X-Api-Key': this.apiKey, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
return res.json();
}
static verify(payload, sig, secret) {
const crypto = require('crypto');
const hex = crypto.createHmac('sha256', secret).update(payload).digest('hex');
return crypto.timingSafeEqual(Buffer.from(hex), Buffer.from(sig));
}
}