Non-Secure Ödeme (Pay Smart 2D)
Müşterilerin tek seferlik şifre girmeden ve güvenlik kontrolü olmadan ödeme yapmalarını sağlar. Bu yöntem, token almada is_3d değeri 0 veya 1 ise kullanılabilir.
İstek Bilgileri
- Metot:
POST - URL:
https://staging.halkode.com.tr/ccpayment/api/paySmart2D - CANLI URL:
https://app.halkode.com.tr/ccpayment/api/paySmart2D - Yetkilendirme:
Bearer {token}Token Alma servisinden alınan değer
İstek Parametreleri (Body)
| Parametre | Tip | Koşul | Açıklama |
|---|---|---|---|
cc_holder_name | string | Zorunlu | Kart sahibinin adı soyadı. |
cc_no | string | Zorunlu | Maskelenmiş kart numarası (Örn: 123456******1234). |
expiry_month | string | Zorunlu | İki haneli ay (Örn: 08). |
expiry_year | string | Zorunlu | Dört haneli yıl (Örn: 2028). |
cvv | string | Zorunlu | Kartın arkasındaki güvenlik kodu. |
total | double | Zorunlu | Toplam tutar (Nokta ile ayrılmalı). |
installments_number | integer | Zorunlu | Taksit Tutarı |
currency_code | string | Zorunlu | Para birimi kodu (Örn: TRY). |
merchant_key | string | Zorunlu | Üye işyeri anahtarınız. |
invoice_id | string | Zorunlu | Sizin tarafınızdaki tekil sipariş ID. |
invoice_description | string | Opsiyonel | Sizin tarafınızdaki tekil sipariş ID. |
hash_key | string | Zorunlu | Güvenlik imzası. |
name | string | Opsiyonel | İsim |
surname | string | Opsiyonel | Soyisim |
items | array | Zorunlu | Ürün Sepeti |
Hash-Key Oluşturma
Hash Key, istek parametrelerinde yer alan invoice_id, merchant_key,currency_code,installments_number,total değerleri ve size ait benzersiz app_secret değerini kullanarak oluşturulması gereken benzersiz bir anahtardır. Aşağıda hash_key oluşturma yöntemi verilmiştir.
PHP Örnek Kodu
PHP
public static function hashGenerator($currency_code,$merchant_key,$invoice_id,$app_secret,$total,$installments_number)
{
$data = $total . '|' . $installmentsNumber . '|' . $currency_code . '|' . $merchant_key . '|' . $invoice_id;
$iv = substr(sha1(mt_rand()), 0, 16);
$password = sha1($app_secret);
$salt = substr(sha1(mt_rand()), 0, 4);
$saltWithPassword = hash('sha256', $password . $salt);
$encrypted = openssl_encrypt(
$data, 'aes-256-cbc', $saltWithPassword, 0, $iv
);
$msg_encrypted_bundle = $iv . ':' . $salt . ':' . $encrypted;
$msg_encrypted_bundle = str_replace('/', '__', $msg_encrypted_bundle);
return response()->json(['Hash Key' =>$msg_encrypted_bundle ]);
}Örnek İstek (Request)
json
{
"cc_holder_name":"John Dao",
"cc_no":"4155141122223339",
"expiry_month":"12",
"expiry_year":"20",
"cvv":"555",
"currency_code":"TRY",
"installments_number": 1,
"invoice_id":"111112324115312",
"invoice_description":" INVOICE TEST DESCRIPTION",
"total":22.00,
"items": [
{
"name": "Item3",
"price": 22,
"quantity": 1,
"description": "item3 description"
}
],
"name" : "John",
"surname" : "Dao",
"merchant_key":"$2y$10$...",
"hash_key" : "hesaplanan hash "
}Başarılı Yanıt
json
{
"status_code": 100,
"status_description": "Payment process successful",
"data": {
"order_no": "VP17459141322115179",
"order_id": "VP17459141322115179",
"invoice_id": "1111125324115312",
"credit_card_no": "415514****3339",
"transaction_type": "Auth",
"payment_status": 1,
"payment_method": 1,
"error_code": 100,
"error": "Transaction Successful",
"auth_code": 396050,
"merchant_commission": 0,
"user_commission": 0,
"merchant_commission_percentage": 0,
"merchant_commission_fixed": 0,
"hash_key": "Hesaplanan hash",
"original_bank_error_code": "",
"original_bank_error_description": ""
}
}Başarısız Yanıt
json
{
"status_code": 41,
"status_description": "Gecersiz hesap numarasi.",
"data": {
"order_no": "VP17733132019692187",
"order_id": "VP17733132019692187",
"invoice_id": "Abcd1245671",
"credit_card_no": "413226****0003",
"transaction_type": "Auth",
"payment_status": 0,
"payment_method": 1,
"error_code": "14",
"error": "Gecersiz hesap numarasi.",
"auth_code": null,
"merchant_commission": 0.66,
"user_commission": 0,
"merchant_commission_percentage": 2.99,
"merchant_commission_fixed": 0,
"hash_key": "342fa9539f23ea16:5981:n8A4HxE2rGyk2RHp6J+L8M6PSOF1fnAzsGv4ybylad90oC6c5KjOxXKtI__RAjQmb",
"original_bank_error_code": "14",
"original_bank_error_description": "Gecersiz hesap numarasi."
}
}Kod Örnekleri
PHP Örnek Kodu
PHP
<?php
function sendRequest( $data, $token) {
$baseUrl = "https://staging.halkode.com.tr/ccpayment/api/paySmart2D"
$url = $baseUrl . $endpoint;
$ch = curl_init($url);
$payload = json_encode($data);
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer ' . $token
];
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return json_decode($response, true);
}
//Token get token servisinden alınır.
$authData = [
"cc_holder_name":"John Dao",
"cc_no":"4155141122223339",
"expiry_month":"12",
"expiry_year":"20",
"cvv":"555",
"currency_code":"TRY",
"installments_number": 1,
"invoice_id":"111112324115312",
"invoice_description":" INVOICE TEST DESCRIPTION",
"total":22.00,
"items": [
{
"name": "Item3",
"price": 22,
"quantity": 1,
"description": "item3 description"
}
],
"name" : "John",
"surname" : "Dao",
"merchant_key":"$2y$10$...",
"hash_key" : "hesaplanan hash "
];
$authResult = sendRequest($authData,$token);
print_r($authResult);
?>C# /.NET Örnek Kodu
C#
using System.Text;
using System.Text.Json;
using System.Net.Http.Headers;
public class HalkodeClient
{
private static readonly HttpClient client = new HttpClient();
public async Task<string> PaySmart2D(object paymentData, string token)
{
var url = "https://staging.halkode.com.tr/ccpayment/api/paySmart2D";
var json = JsonSerializer.Serialize(paymentData);
var content = new StringContent(json, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.PostAsync(url, content);
return await response.Content.ReadAsStringAsync();
}
}
// Örnek Kullanım
var paymentData = new {
cc_holder_name = "Test kart",
cc_no = "444444******4444",
expiry_month = "12",
expiry_year = "2024",
cvv = "555",
currency_code = "TRY",
installments_number = 1,
invoice_id = "Abcd1245671",
invoice_description = "INVOICE TEST DESCRIPTION",
total = 22.00,
items = new[] {
new { name = "Item3", price = 22, quantity = 1, description = "item3 description" }
},
name = "John",
surname = "Dao",
merchant_key = "$2y$10$WxwG144ioxqD77COQCNV0...",
hash_key = "d02ee95a43f3a1a2:d52a:EwVzFl..."
};
var halkode = new HalkodeClient();
var result = await halkode.PaySmart2D(paymentData, "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9...");JavaScript / NodeJs Örnek Kodu
JavaScript
const axios = require('axios');
async function paySmart2D(paymentData, token) {
try {
const config = {
method: 'post',
url: 'https://staging.halkode.com.tr/ccpayment/api/paySmart2D',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ' + token
},
data: paymentData
};
const response = await axios(config);
return response.data;
} catch (error) {
console.error('Hata:', error.response ? error.response.data : error.message);
}
}
const paymentData = {
"cc_holder_name": "Test kart",
"cc_no": "444444******4444",
"expiry_month": "12",
"expiry_year": "2024",
"cvv": "555",
"currency_code": "TRY",
"installments_number": 1,
"invoice_id": "Abcd1245671",
"invoice_description": "INVOICE TEST DESCRIPTION",
"total": 22.00,
"items": [
{
"name": "Item3",
"price": 22,
"quantity": 1,
"description": "item3 description"
}
],
"name": "John",
"surname": "Dao",
"merchant_key": "$2y$10$WxwG144ioxqD77COQCNV0...",
"hash_key": "d02ee95a43f3a1a2:d52a:EwVzFl..."
};
paySmart2D(paymentData, "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9...").then(console.log);
