ESKİ PAYMENT BÖLÜMÜ
} else if ($this->config->item("payment_method") == "shipy" && !isset($_POST['coinbase'])) {
$return_id = $payment_id;
$user_ip = $_SERVER['REMOTE_ADDR'];
$amount = (int) $this->input->post('amount');
$apiKey = $this->config->item("shipy_api_key");
$user_name = $user["name"];
$user_address = "Istanbul Kadikoy 34001";
$user_phone = "05377411928";
$email = $user["email"];
$test_mode = 0;
$fields = array(
"user_ip" => $user_ip,
"user_name" => $user_name,
"user_address" => $user_address,
"user_phone" => $user_phone,
"email" => $email,
"amount" => $amount,
"return_id" => $return_id,
"apiKey" => $apiKey,
"test_mode" => $test_mode
);
$postvars = http_build_query($fields);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://api.shipy.net/pay/credit_card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($fields),
));
$result = curl_exec($ch);
$result = json_decode($result, true);
if ($result['status'] == "success") {
$link = $result['link'];
header("Location: $link");
} else print("Ödeme işlemi sırasında bir hata oluştu: " . $result["message"]);ESKİ CALLBACK BÖLÜMÜ
else if ($this->config->item("payment_method") == "shipy") {
if (isset($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
} elseif (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
if ($ip != "185.120.5.2") {
//exit();
}
if (
!isset($_POST["return_id"]) || !isset($_POST["payment_type"]) || !isset($_POST["payment_amount"]) ||
!isset($_POST["user_name"]) || !isset($_POST["user_address"]) || !isset($_POST["user_phone"]) ||
!isset($_POST["email"]) || !isset($_POST["test_mode"])
) { // Herhangi veri eksik ise, isteği sonlandırıyoruz.
exit();
}
if (!isset($_POST["return_id"]) || !isset($_POST["payment_type"]) || !isset($_POST["payment_amount"]) || !isset($_POST["user_name"]) || !isset($_POST["user_address"]) || !isset($_POST["user_phone"]) || !isset($_POST["email"]) || !isset($_POST["test_mode"])) {
exit();
}
$this->load->model("payment_model");
$return_id = $_POST["return_id"];
$user = $this->payment_model->getUserByEmail($this->input->post('email'));
$payment = $this->payment_model->getPendingPayment($return_id);
$this->payment_model->acceptPayment($payment["id"], $payment["amount"], "card", $user["id"]);
echo "OK";YENİ PAYMENT PAGE
<?php
/*
_____ __ _ __ ___ ____ ____
/ ___// /_ (_)___ __ __ ____ ___ / /_ / | / __ \/ _/
\__ \/ __ \/ / __ \/ / / / / __ \/ _ \/ __/ / /| | / /_/ // /
___/ / / / / / /_/ / /_/ / / / / / __/ /_ / ___ |/ ____// /
/____/_/ /_/_/ .___/\__, (_)_/ /_/\___/\__/ /_/ |_/_/ /___/
/_/ /____/
API Versiyon: 2
Güncelleme Tarihi: 27.07.2020
*/
$returnID = ""; // İşlem tamamlandığında size gönderilecek veri, INT veya STRING olabilir
$usrIp = ""; // Ödeme yapacak kullanıcının IP adresi
$amount = 1; // Kur bazlı ödenecek tutar
$currency = "TRY"; // Ödeme yapılacak para birimi. (TRY, EUR, USD, GBP)
$apiKey = "secret"; // Gizli API anahtarınız
$usrName = ""; // Ödeme yapacak kullanıcınızın adı, soyadı
$usrAddress = ""; // Ödeme yapacak kullanıcınızın adresi
$usrPhone = ""; // Ödeme yapacak kullanıcınızın telefon numarası
$usrEmail = ""; // Ödeme yapacak kullanıcınızın e-posta adresi
$pageLang = "TR"; // Ödeme sayfası dil seçeneği (TR, EN, DE, AR, ES, FR)
$mailLang = "TR"; // Ödeme sonra bilgilendirme e-maili dil seçeneği (TR, EN)
$installment = 0; // Taksit seçeneği tanımlaması (0: Tek Çekim, 3,6,9,12: Taksit Sayısı)
$fields = array(
"usrIp" => $usrIp,
"usrName" => $usrName,
"usrAddress" => $usrAddress,
"usrPhone" => $usrPhone,
"usrEmail" => $usrEmail,
"amount" => $amount,
"returnID" => $returnID,
"currency" => $currency,
"pageLang" => $pageLang,
"mailLang" => $mailLang,
"installment" => $installment,
"apiKey" => $apiKey
);
$postvars = http_build_query($fields);
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => "https://api.shipy.dev/pay/credit_card",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => http_build_query($fields),
));
$result = curl_exec($ch);
$result = json_decode($result, true);
if ($result['status'] == "success") {
$link = $result['link'];
header("Location: $link"); // Müşteriyi sistemin bize gönderdiği ödeme sayfasına yönlendiriyoruz.
} else print("Ödeme işlemi sırasında bir hata oluştu: " . $result["message"]);
curl_close($ch);
?>YENİ CALLBACK
<?php
/*
_____ __ _ __ ___ ____ ____
/ ___// /_ (_)___ __ __ ____ ___ / /_ / | / __ \/ _/
\__ \/ __ \/ / __ \/ / / / / __ \/ _ \/ __/ / /| | / /_/ // /
___/ / / / / / /_/ / /_/ / / / / / __/ /_ / ___ |/ ____// /
/____/_/ /_/_/ .___/\__, (_)_/ /_/\___/\__/ /_/ |_/_/ /___/
/_/ /____/
API Versiyon: 2
Güncelleme Tarihi: 27.07.2020
*/
if(isset($_SERVER["HTTP_CLIENT_IP"])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
} else if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$ip = $_SERVER["HTTP_CF_CONNECTING_IP"];
} else {
$ip = $_SERVER["REMOTE_ADDR"];
}
if ($ip != "144.91.111.2") { // IP Adresini kontrol ediyoruz, eğer istek shipy sunucusu üzerinden gelmemişse, sonlandırıyoruz.
exit("SHIPY: Request sent by wrong IP: " . $ip);
}
if (!isset($_POST["returnID"]) || !isset($_POST["paymentType"]) || !isset($_POST["paymentAmount"]) ||
!isset($_POST["paymentHash"]) || !isset($_POST["paymentID"]) || !isset($_POST["paymentCurrency"])) {
// Herhangi veri eksik ise, isteği sonlandırıyoruz.
exit("SHIPY: Missing value sent.");
}
$apiKey = "secret"; // Gizli API anahtarınız
$returnID = $_POST["returnID"]; // Ödeme isteğini gönderirken belirlediğiniz return id
$paymentID = $_POST["paymentID"]; // Shipy tarafından belirlenmiş işlem ID'si
$paymentType = $_POST["paymentType"]; // Ödeme kanalı. "eft" => Havale / EFT, "credit_card" => Kredi Kartı / Ön Ödemeli Kart, "mobile" => Mobil Ödeme
$paymentAmount = $_POST["paymentAmount"]; // Ödeme yapılan tutar
$paymentCurrency = $_POST["paymentCurrency"]; // Ödeme yapılan tutar
$paymentHash = $_POST["paymentHash"]; // Shipy tarafından gönderilen hash
$hashtr = $paymentID . $returnID . $paymentType . $paymentAmount . $paymentCurrency . $apiKey;
$hashbytes = mb_convert_encoding($hashtr, "ISO-8859-9");
$hash = base64_encode ( sha1 ( $hashbytes, true ) );
if($hash!=$paymentHash)
{
http_response_code(403);
exit(json_encode(array("status"=>"error","message"=>"paymentHash is not vaild.")));
}
// Her şey doğrulandı ve güvenli. Artık burada veritabanı işlemlerinizi yapabilirsiniz.
echo "OK"; // İşlem sonunda OK yazdırıyoruz. Eğer yazdırılmazsa, OK yanıtı gelene kadar tarafınıza istek gönderilecektir.
?>