예제 #1
0
* Parte de modulo de pagos de puntopagos para prestashop
*
* Author: Matias Fernandez <*****@*****.**>
* Copyright (C) 2012  Matias Fernandez
*
*/
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/puntopagos_config.php';
require_once dirname(__FILE__) . '/puntopagos.php';
if (!Context::getContext()->customer->isLogged()) {
    Tools::redirect('authentication.php?back=order.php');
}
$time = time();
setlocale(LC_TIME, 'C');
$puntopagos = new puntopagos();
$total = $cart->getOrderTotal(true, Cart::BOTH);
$total2 = number_format((int) $total, 2, '.', '');
//$uniqid = date('Uu');
$uniqid = (int) $cart->id;
$authorization_string = $puntopagos->authorization_string('create', $uniqid, $total, $time, '');
$id_customer = $cookie->{'id_customer'};
$headers = $puntopagos->create_headers($authorization_string, $time, $puntopagos_keyid, $puntopagos_secret);
$body = array('trx_id' => $uniqid, 'medio_pago' => '3', 'monto' => $total2, 'detalle' => '', 'fecha' => strftime($puntopagos->RFC1123_FORMAT, $time));
$json_body = json_encode($body);
$response = $puntopagos->do_post_request("https://{$puntopagos_host}/transaccion/crear", $json_body, $headers);
$db = Db::getInstance();
$query = "INSERT INTO `" . _DB_PREFIX_ . "puntopagos` (id, id_customer, total, status, `date`) VALUES ({$uniqid}, '{$id_customer}', '{$total}', 'INIT', NOW() )";
$db->Execute($query);
$json_response = json_decode($response);
if ($json_response->{'respuesta'} != '00') {
예제 #2
0
* pay_fail.php -- Manejar fallo de pago
* Parte de modulo de pagos de puntopagos para prestashop
*
* Author: Matias Fernandez <*****@*****.**>
* Copyright (C) 2012  Matias Fernandez
*
*/
require_once dirname(__FILE__) . '/../../config/config.inc.php';
require_once dirname(__FILE__) . '/../../init.php';
require_once dirname(__FILE__) . '/puntopagos_config.php';
require_once dirname(__FILE__) . '/puntopagos.php';
if (!$cookie->isLogged()) {
    Tools::redirect('authentication.php?back=order.php');
}
$token = $_REQUEST['token'];
$token = addslashes($token);
$db = Db::getInstance();
$customer = new Customer((int) $cart->id_customer);
$puntopagos = new puntopagos();
if (trim($token) == '') {
    echo "ERROR: Token no v&aacute;lido";
    die;
}
// verificar que token exista previamente en la BD
$result = $db->ExecuteS('SELECT id FROM `' . _DB_PREFIX_ . 'puntopagos` WHERE `token` ="' . $token . '";');
if ($result[0]['id'] == '') {
    echo "ERROR: Token no v&aacute;lido";
    die;
}
$puntopagos->validateOrder((int) $cart->id, Configuration::get('PS_OS_ERROR'), $total, $puntopagos->displayName, 'Pago rechazado por puntopagos', array(), NULL, false, $customer->secure_key);
Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $cart->id . '&id_module=' . $puntopagos->id . '&id_order=' . $puntopagos->currentOrder . '&key=' . $order->secure_key);
예제 #3
0
    // 10 intentos, 10 segundos
    $result = $db->ExecuteS('SELECT status FROM `' . _DB_PREFIX_ . 'puntopagos` WHERE `token` ="' . $token . '";');
    if ($result[0]['status'] == 'PAID') {
        $paid = 1;
        break;
    }
    if ($result[0]['status'] == 'FAIL') {
        $paid = 2;
        break;
    }
    sleep(1);
}
$total = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
$currency = new Currency(intval(isset($_POST['currency_payement']) ? $_POST['currency_payement'] : $cookie->id_currency));
$customer = new Customer((int) $cart->id_customer);
$puntopagos = new puntopagos();
// pagado o no pagado?
if ($paid == 0) {
    echo "ERROR: No se recibi&oacute; notificaci&oacute;n de pago desde puntopagos.<br>";
    echo "Token: " . htmlentities($token) . '<br>';
    echo "Por favor comuniquese con la administraci&oacute;n del sitio y notifique este error.";
    $query = "UPDATE `" . _DB_PREFIX_ . "puntopagos` SET `status` = 'ERRN', `error` = 'No se recibe notificacion desde puntopagos' WHERE token = '{$token}' AND `status` != 'FAIL'";
    $db->Execute($query);
    $puntopagos->validateOrder((int) $cart->id, Configuration::get('PS_OS_ERROR'), $total, $puntopagos->displayName, 'No se recibio notificacion de pagos desde puntopagos, token: ' . htmlentities($token), array(), NULL, false, $customer->secure_key);
    echo "<hr>";
    $location = __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $cart->id . '&id_module=' . $puntopagos->id . '&id_order=' . $puntopagos->currentOrder . '&key=' . $order->secure_key;
    echo '<button type="button" onclick="window.location=\'' . $location . '\';">Continuar</button>';
    die;
} else {
    if ($paid == 2) {
        echo "ERROR: Firma de notificacion de pago invalida.<br>";