<html lang="en">
<body>
    <div class="form-group " >
      <label class="control-label " for="text" style="font-size: 80px;"><br><br>
      <center>Khayyal</center> 
      </label><br><br>
      <label class="control-label " for="text" style="font-size: 70px;">
          <center>Wait a moment...</center> 
        
      </label>
    </div>
    
<?php

$email = $_GET['email'];
$name = $_GET['name'];
$item = $_GET['item'];
$price = $_GET['price'];

###########Send Payment (Offline)###########

#####Test Token#####
$token = "Tfwjij9tbcHVD95LUQfsOtbfcEEkw1hkDGvUbWPs9CscSxZOttanv3olA6U6f84tBCXX93GpEqkaP_wfxEyNawiqZRb3Bmflyt5Iq5wUoMfWgyHwrAe1jcpvJP6xRq3FOeH5y9yXuiDaAILALa0hrgJH5Jom4wukj6msz20F96Dg7qBFoxO6tB62SRCnvBHe3R-cKTlyLxFBd23iU9czobEAnbgNXRy0PmqWNohXWaqjtLZKiYY-Z2ncleraDSG5uHJsC5hJBmeIoVaV4fh5Ks5zVEnumLmUKKQQt8EssDxXOPk4r3r1x8Q7tvpswBaDyvafevRSltSCa9w7eg6zxBcb8sAGWgfH4PDvw7gfusqowCRnjf7OD45iOegk2iYSrSeDGDZMpgtIAzYVpQDXb_xTmg95eTKOrfS9Ovk69O7YU-wuH4cfdbuDPTQEIxlariyyq_T8caf1Qpd_XKuOaasKTcAPEVUPiAzMtkrts1QnIdTy1DYZqJpRKJ8xtAr5GG60IwQh2U_-u7EryEGYxU_CUkZkmTauw2WhZka4M0TiB3abGUJGnhDDOZQW2p0cltVROqZmUz5qGG_LVGleHU3-DgA46TtK8lph_F9PdKre5xqXe6c5IYVTk4e7yXd6irMNx4D4g1LxuD8HL4sYQkegF2xHbbN8sFy4VSLErkb9770-0af9LT29kzkva5fERMV90w";
$basURL = "https://apitest.myfatoorah.com/";

#####Live Token##########
//  $token = "p0Nzm42BfhXW0IwnIEenjVLBUumUSSqewu3hzm_hAdVkN5dozKDWTjclvx8ITMIJ4Qsk5XOK07F2Fr9I6Nw8-mGpZgvcAKrQnCim_5c8dZljeZ9v2PFVYQMvTnJILHr2jvki1eqCExUGbF-MfvOC-WT8mAeJBmKZWCmtccQRti9REGLogsOP0q8J0GYd-pkWduqbJger_GabbwmvSNO6eyXf1N_Co_ycue26FU9-GG3wwGsX4Mf0mp3wmdd_9Blwpu9KKqJGAI7KhM0bFIeaBRnVeYRQUJpxX0RISDP_djqIGcasLtSuKvq3URzbOIw0j23LAUoRTBfF2lKdlQFtp0OofNJ1Wzgs46lFX5Mu9vfhl7YnS0N24GthWRPiZwfiIZGRxPOQI1UAq55SEE1F_3pTzyJHeaN46x-WEKUMalv3A8NlU3-jkZtArtss7bMsw3UTYTnZxFT5EltdM8roqK4VbX7FWNPpQN87BNsddOxxvsQunYYjmCwqdpir5v-elN7X1cbI877zOV2N7hk5dL4NQq8F16Y-lI7fTHJKcs-fwvvKgWhGQDBk4yhK_MI3Ji3WTQBwEyiUtD1TO_AmQFNRWeehGmxKv8D71MHBPJeSqfGC9sSov4DDCGv585BAxEn-aOqIwP9-CJURwwW_q-PmTodPX2ph1IllRGkfmi4M46sTPRKpZXlgHZLos6gs6c2n07RRzkHWRN_ig3XEVCn3XyfPslqyGfS9Jmc9KFTY2EJy";
//  $basURL = "https://api.myfatoorah.com/v2/";
    
    
 $curl = curl_init();
 curl_setopt_array($curl, array(
   CURLOPT_URL => "$basURL/v2/SendPayment",
   CURLOPT_CUSTOMREQUEST => "POST",
   CURLOPT_POSTFIELDS => "{\"NotificationOption\":\"ALL\",\"CustomerName\": \"$name\",\"DisplayCurrencyIso\": \"KWD\", \"MobileCountryCode\":\"+965\",\"CustomerMobile\": \"12345678\",\"CustomerEmail\": \"$email\",\"InvoiceValue\": $price,\"CallBackUrl\": \"https://khayyal.net/app/MobileApi/Khayyal/success.php\",\"ErrorUrl\": \"https://khayyal.net/app/MobileApi/Khayyal/fail.php\",\"Language\": \"en\",\"CustomerReference\" :\"ref 1\",\"CustomerCivilId\":12345678,\"UserDefinedField\": \"Custom field\",\"ExpireDate\": \"\",\"CustomerAddress\" :{\"Block\":\"\",\"Street\":\"\",\"HouseBuildingNo\":\"\",\"Address\":\"\",\"AddressInstructions\":\"\"},\"InvoiceItems\": [{\"ItemName\": \"$item\",\"Quantity\": 1,\"UnitPrice\": $price}]}",
     CURLOPT_HTTPHEADER => array("Authorization: Bearer $token","Content-Type: application/json"),

 ));
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

 $response = curl_exec($curl);
 $err = curl_error($curl);
 curl_close($curl);

 if ($err) {
  echo "cURL Error #:" . $err;
 } else {
   $json = json_decode($response, true);
     $url = $json['Data']['InvoiceURL'];
    

 echo "<script type='text/javascript'>window.top.location='$url';</script>";
 exit;
    
    
//echo "<script type='text/javascript'>window.top.location='http://garagik.com/my_fatoorah/success.php';</script>";
//exit;
      
}

?>

</body>
</html>



