<?php
session_start();
$orderid = mt_rand(1000,9000);
$_SESSION['orderid'] = $orderid;
$ucret = $_POST['ucret'];
$url= 'https://payid19.com/api/v1/create_invoice';
$post = [
'public_key' => 'buraya sitenin verdiği pub keyi giriyorum.',
'private_key' => 'buraya sitenin verdiği private keyi giriyorum',
'email' => 'email@email.com',
'price_amount' => $ucret,
'price_currency' => 'TRY',
'merchant_id' => 5,
'order_id' => $orderid,
'customer_id' => 12,
'test' => 1,
'title' => 'test',
'description' => 'test',
'add_fee_to_price' => 1,
'cancel_url' => 'http://localhost:8080/deneme/',
'success_url' => 'http://localhost:8080/deneme/',
'callback_url' => 'http://localhost:8080/deneme/odemekontrol.php',
'expiration_date' => 6,
//'margin_ratio' => 1
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
$result = curl_exec($ch);
curl_close($ch);
if(json_decode($result)->status=='error'){
//error
echo json_decode($result)->message[0];
}else{
//success
$mesaj = json_decode($result)->message;
header("Location: $mesaj");
}