$name=$_POST["name"];
$phone=$_POST["phone"];
$product= $_POST["product"];
$quantity=$_POST["quantity"];
$unique_id=uniqid();
if ($product == "Биолакт"){
if ($quantity == 1){
$price = 195;}
if ($quantity == 2){
$price = 338;}
if ($quantity == 3){
$price = 492;}
if ($quantity == 4){
$price = 649;}
if ($quantity == 5){
$price = 807;}
if ($quantity > 5){
$price = 1;}}
if ($product == "Биолакт Форте"){
if ($quantity == 1){
$price = 243;}
if ($quantity == 2){
$price = 434;}
if ($quantity == 3){
$price = 636;}
if ($quantity == 4){
$price = 841;}
if ($quantity == 5){
$price = 1047;}
if ($quantity > 5){
$price = 1;}}
$link = mysqli_connect("localhost", "eastph22_bio1", "2xui8fkY") or die (mysqli_error());
mysqli_select_db($link, "eastph22_bio") or die("Could not select database");
$query = "INSERT INTO `payment`(`name`, `phone`, `product`, `quantity`, `price`, `unique_id`) VALUES ('$name', '$phone', '$product', '$quantity', '$price', '$unique_id')";
mysqli_query($link, $query);
$query = "SELECT order_id FROM `payment` WHERE unique_id = '$unique_id'";
$order_id_raw = mysqli_fetch_row(mysqli_query($link, $query));
$order_id = $order_id_raw[0];
mysqli_close($link);
mail("[email protected]","Seems to be payment for Biolact","Check it!");
$private_key = "bo5PutFwQPMiQodsF4K31HXnsJk6ef7gzMHixRSE";
$public_key = "i40340255361";
$json_string = json_encode(
array(
"action" => "pay",
"version" => "3",
"public_key" => $public_key,
"amount" => $price,
"currency" => "UAH",
"description" => "Оплата заказа № ".$order_id." (".$product." x ".$quantity." уп.), включая доставку.",
"type" => "buy",
"order_id" => $order_id,
"result_url" => "https://biolact.ua/callback.php",
"server_url" => "https://biolact.ua/callback.php",
"sandbox" => "0"
)
);
$data = base64_encode( $json_string );
$signature = base64_encode( sha1(
$private_key .
$data .
$private_key
, 1 ));
header( 'Location: https://www.liqpay.ua/api/3/checkout?data='.$data.'&signature='.$signature, true, 301 );
?>