Skip to content

Commit

Permalink
ePayco plugin zen cart
Browse files Browse the repository at this point in the history
  • Loading branch information
epayco committed Jul 16, 2016
0 parents commit 7f39120
Show file tree
Hide file tree
Showing 19 changed files with 779 additions and 0 deletions.
Empty file added README.md
Empty file.
Binary file added zen-cart-payco/.DS_Store
Binary file not shown.
16 changes: 16 additions & 0 deletions zen-cart-payco/LEEME.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DIST -> PLUGIN EN RAR
SRC -> PLUGIN SIN COMPRIMIR

***-PLUGIN DE PAYCO PARA ZEN CART-***

*El plugin se instala de manera manual ya que zen cart no cuenta con un wizard para instalar plugin, asi que si tiene el plugin en rar debe descomprimirlo y realizar lo siguiente:

*ubiquese en el directorio raiz de zen cart,asi mismo ubiquese en el directorio raiz del plugin, inicie copiando los archivos del plugin en su respectiva ubicacion
por ejemplo:

PLUGIN:
plugin/confirmacion.php

teniendo encuenta esa ubicacion asi mismo debera copiarla en el zen-car quedando el archivo confirmacion.php en raiz del zen- cart

ZEN-CART: zen-cart/confirmacion.php
179 changes: 179 additions & 0 deletions zen-cart-payco/checkout_process_pol.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">

//funcion para enviar los datos del formulario
function submitform(){
document.params_form.submit();
}
</script>
</head>


<body onLoad="submitform()">

<?php

/**
* module to process a completed checkout
*
* @package procedureCheckout
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: checkout_process_pol.php 4865 2006-10-31 07:44:40Z drbyte $
* @version Plugin 1.0 del modulo de pagos de Payco
*/



include('includes/application_top.php');
require_once(DIR_WS_LANGUAGES . $_SESSION['language'] . '/'. "checkout_process.php");


// This should be first line of the script:
$zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_PROCESS');

if (!defined('IS_ADMIN_FLAG')) {
die('Illegal Access');
}

//notifica el comienzo del checkout
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEGIN');

//incluye los lenguajes
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

// if the customer is not logged on, redirect them to the time out page
if (!$_SESSION['customer_id']) {
zen_redirect(zen_href_link(FILENAME_TIME_OUT));
} else {
// validate customer
if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_SHIPPING));
zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
}
}

// confirm where link came from
if (!strstr($_SERVER['HTTP_REFERER'], FILENAME_CHECKOUT_CONFIRMATION)) {
zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT,'','SSL'));
}

// load selected payment module
require(DIR_WS_CLASSES . 'payment.php');
$payment_modules = new payment($_SESSION['payment']);

// load the selected shipping module
require(DIR_WS_CLASSES . 'shipping.php');
$shipping_modules = new shipping($_SESSION['shipping']);

require(DIR_WS_CLASSES . 'order.php');
$order = new order;

// prevent 0-entry orders from being generated/spoofed
if (sizeof($order->products) < 1) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}


require(DIR_WS_CLASSES . 'order_total.php');
$order_total_modules = new order_total;

$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PRE_CONFIRMATION_CHECK');

$order_totals = $order_total_modules->pre_confirmation_check();

$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_BEFORE_ORDER_TOTALS_PROCESS');
$order_totals = $order_total_modules->process();
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_TOTALS_PROCESS');

if (!isset($_SESSION['payment']) && !$credit_covers) {
zen_redirect(zen_href_link(FILENAME_DEFAULT));
}

// load the before_process function from the payment modules
$payment_modules->before_process();
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_BEFOREPROCESS');

// create the order record
$insert_id = $order->create($order_totals, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE');
$payment_modules->after_order_create($insert_id);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_PAYMENT_MODULES_AFTER_ORDER_CREATE');

// store the product info to the order
$order->create_add_products($insert_id);
$_SESSION['order_number_created'] = $insert_id;
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_CREATE_ADD_PRODUCTS');

//send email notifications
$order->send_order_email($insert_id, 2);
$zco_notifier->notify('NOTIFY_CHECKOUT_PROCESS_AFTER_SEND_ORDER_EMAIL');


// load the after_process function from the payment modules

$_SESSION['cart']->reset(true);

// unregister session variables used during checkout
unset($_SESSION['sendto']);
unset($_SESSION['billto']);
unset($_SESSION['shipping']);
unset($_SESSION['payment']);
unset($_SESSION['comments']);
$order_total_modules->clear_posts();//ICW ADDED FOR CREDIT CLASS SYSTEM


// This should be before the zen_redirect:
$zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_PROCESS');


?>


<form name="params_form" method="post" action= <?= MODULE_PAYMENT_PAYCO_URL; ?> >
<?php
$payco = new payco();
//$procees = new process_button();
//$datos = $payco->payco;
//var_export($order);

$pkey = sha1($payco->clave_secreta.$payco->usuario_id);

if($payco->prueba =="1"){
$test = "TRUE";
}else{
$test = "FALSE";
}

?>

<!-- Se construye el boton de pago con todos los campos que estan en payco del plugin-->
<input type="hidden" name="p_cust_id_cliente" value="<?php echo $payco->usuario_id; ?>">
<input type="hidden" name="p_key" value="<?php echo $pkey; ?>">
<input type="hidden" name="p_test_request" value="<?php echo $test; ?>">
<input type="hidden" name="p_email" value="<?php echo $order->customer['email_address']; ?>">
<input type="hidden" name="p_tax" value="0">
<input type="hidden" name="p_currency_code" value="<?php echo $order->info['currency']; ?>">
<input type="hidden" name="p_description" value="<?php echo $payco->description; ?>">
<input type="hidden" name="p_extra1" value="0">
<input type="hidden" name="p_extra2" value="0">
<input type="hidden" name="p_extra3" value="0">
<input type="hidden" name="p_url_respuesta" value="<?php echo HTTP_SERVER.DIR_WS_CATALOG."confirmacion.php"; ?>">
<input type="hidden" name="p_amount" value="<?php echo round($order->info['subtotal'],2); ?>">
<input type="hidden" name="p_id_factura" value="<?php echo $insert_id; ?>">
<input type="hidden" name="p_amount_base" value="0">

</form>


<?php
//termina el aplicativo
require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
</body>
</html>
131 changes: 131 additions & 0 deletions zen-cart-payco/confirmacion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?php

/*osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Payco Payment Module
Copyright (c) 2007 Payco software
Released under the GNU General Public License
*/

//se incluyen archivos de la aplicacion y de la orden
include_once('includes/application_top.php');
include(DIR_WS_CLASSES . 'order.php');

//var_export($_POST);
//Se verifica si se esta enviando informacion por el metodo Post y si no es así no se permite ver la pagina por navegador.
if($_POST['x_respuesta']){

// se verifica los estados de la transaccion para asi actualizar el nombre en la orden
$estado = $_POST['x_respuesta'];


$ultimo_estado = "select max(orders_status_id) as id from " . TABLE_ORDERS_STATUS ;
$ultimo_estado_zencart = $db->Execute($ultimo_estado);
// $ultimo_estado_zencart = mysql_fetch_assoc($ultimo_estado_zencart);

$id1 = ($ultimo_estado_zencart->fields['id']+1);
$id2 = ($ultimo_estado_zencart->fields['id']+2);
$id3 = ($ultimo_estado_zencart->fields['id']+3);


$verificar = " select count(orders_status_id) as cantidad from " . TABLE_ORDERS_STATUS." where orders_status_name ='Aceptada' or orders_status_name ='Rechazada' or orders_status_name ='Pendiente'" ;
$verificar_estados = $db->Execute($verificar);

if($verificar_estados->fields['cantidad'] == "0"){
$order_status_payco = "insert into " . TABLE_ORDERS_STATUS . " (orders_status_id,language_id,orders_status_name) values (".$id1.",'0','Aceptada'),(".$id2.",'0','Rechazada'),(".$id3.",'0','Pendiente')";
$db->Execute($order_status_payco);
}


//consulta para encontrar el id del estado de las transacciones
$order_status_query = "select orders_status_id from " . TABLE_ORDERS_STATUS . " where orders_status_name like '%" . $estado . "%'";
$order_status = $db->Execute($order_status_query);


//consulta para actualizar el estado del pago respecto a la informacion que envia payco
$update_order_status_query = "update " . TABLE_ORDERS_STATUS_HISTORY . " set orders_status_id = '"
. $order_status->fields['orders_status_id'] . "' where orders_id = '" . $_POST['x_id_factura'] . "'";
$db->Execute($update_order_status_query);

//actualiza el estado del pago en la orden
$update_order_query = "update " . TABLE_ORDERS . " set orders_status = '" . $order_status->fields['orders_status_id']
. "' where orders_id = '" . $_POST['x_id_factura'] . "'";

$db->Execute($update_order_query);


//si payco envia la variable con este valor es que se aprobo el pago y luego se redirecciona al checkout
/*if($_POST['x_respuesta']) {
header("Location: ".DIR_WS_MODULES."checkout_process.php");
}*/

echo '<html>
<head>
<link href="default.css" type=text/css rel=stylesheet>
</head>
<body>
<div class="">
<h1> Transaccion '.$_REQUEST['x_respuesta'].'</h1>
<h3> Apreciado cliente, la transaccion No.'. $_REQUEST['x_transaction_id'].'
fue recibida por nuestro sistema.</h3>
<h2>Datos de compra:</h3>
<table >
<tbody>
<tr>
<th width="240"><strong> Codigo de Referencia: </strong>&nbsp;</th>
<td width="240">'.$_REQUEST['x_id_factura'].'</td>
</tr>
<tr>
<th><strong> Valor: </strong></th>
<td>'.$_REQUEST['x_amount'].'</td>
</tr>
<tr>
<th><strong> Moneda: </strong></th>
<td>'.$_REQUEST['x_currency_code'].'</td>
</tr>
</tbody>
</table>
<h2>Datos de la transaccion:</h2>
<table>
<tbody>
<tr>
<th width="240"><strong> Fecha de Procesamiento: </strong>&nbsp;</th>
<td width="240">'.$_REQUEST['x_fecha_transaccion'].'</td>
</tr>
<tr>
<th><strong> Recibo No.: </strong></th>
<td>'.$_REQUEST['x_transaction_id'].'</td>
</tr>
<tr>
<th><strong> Transaccion No.: </strong></th>
<td>'.$_REQUEST['x_ref_payco'].'</td>
</tr>
<tr>
<th><strong> Banco o Franquicia: </strong></th>
<td>'.$_REQUEST['x_franchise'].'</td>
</tr>
<tr>
<th><strong> Codigo de aprobacion: </strong></th>
<td>'.$_REQUEST['x_aproval_code'].'</td>
</tr>
<tr>
<th><strong> Codigo de Respuesta POL: </strong></th>
<td>'.$_REQUEST['x_response_reason_text'].'</td>
</tr>
<tr>
<td><a href="/">Regresar a la tienda</a></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>';

//no permite que puedan acceder a la pagina desde el explorador
}else{
echo "<br>Usted no esta autorizado para ver esta pagina.";
}


?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<dwsync>
<file name="define_checkout_success.php" local="128427539645625000" remote="128427716400000000" testing="0" />
</dwsync>
Loading

0 comments on commit 7f39120

Please sign in to comment.