<?php
include('../includes/validador.php');
include('../conexiones/conex.php');
include('../includes/funciones.php');
	
    $id = $_POST['id'];
    $op = $_POST['op'];

    if($op == '2'){
        $op = 'confirmado';
    }else{
        $op = 'cancelado';
    }

    try {
        $con->autocommit(FALSE);

        $query="UPDATE pagos_matriculas SET estadoPago = '$op' WHERE idPago = '$id'";
        $con->query($query) or throw_ex(mysqli_error($con));
        
        $con->commit();
                $datos = array(
                    0 => 1
                    );
        echo json_encode($datos);
        $con->close();

    } catch (Exception $e) {  

        $con->rollback();
        $datos = array(
            0 => 2,
            1 => $e
            );
        echo json_encode($datos);
        $con->close(); 

    }
?>