<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include_once '../config/database.php';
include_once '../objects/payment.php';
 
$database = new Database();
$db = $database->getConnection();

$payment = new Payment($db);
$data = json_decode(file_get_contents("php://input"));

$payment->invoice_no = $data->ino;

$arr = array();
$stmt = $payment->getOnePayment();
$num = $stmt->rowCount();
if($num>0){
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        extract($row);

		$detail=array(
            "id" => (int)$id,
            "date" => $date,
            "payment_type" => $payment_type,
            "amount" => number_format($amount)
        );
        array_push($arr, $detail);
    }
}


echo json_encode($arr);
?>