<?php
//ini_set('display_errors',1);
//ini_set('display_startup_erros',1);
//error_reporting(E_ALL);

include("db_config.php");


cors();
function cors() {
    
    // Allow from any origin
    if (isset($_SERVER['HTTP_ORIGIN'])) {
        // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one
        // you want to allow, and if so:
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        header('Access-Control-Max-Age: 86400');    // cache for 1 day
    }
    
    // Access-Control headers are received during OPTIONS requests
    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
        
        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
            // may also be using PUT, PATCH, HEAD etc
            header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
        
        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
            header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    
        exit(0);
    }
    
    //echo "You have CORS!";
}

$identificador=$_GET["identificador"];

$str = strtoupper($identificador);



    $busca = mysqli_query($conexao,"SELECT * FROM deposits WHERE identifier = '$identificador'");
      while ($anu = mysqli_fetch_array($busca)){
      $id = $anu[id];
      $user_id = $anu[user_id];
      $gateway_id = $anu[gateway_id];
      $trx = $anu[transaction_id];
      $amount = $anu[amount];
      $dep_payment_status = $anu[payment_status];
      $charge = $anu[charge];
      $final_amount = $anu[final_amount]; 
      $currency = "BRL"; 
      $details = "PIX";
      $type = "+";
      $payment_status = "1";
      $gateway_transaction = $anu[identifier];

    };

echo $amount . "<br>";
echo $charge . "<br>";
echo $final_amount . "<br>";
$valorf = number_format($final_amount, 2, '.', '.');
$valorm = str_replace(".", "", $valorf);
echo $valorf . "<br>";
echo $valorm;
 



?>