Plugin Directory

Changeset 807735


Ignore:
Timestamp:
11/20/2013 07:41:07 PM (12 years ago)
Author:
ctala
Message:

V2.0 - Agregado el shortcode [webpay-thankyou] para realizar automáticamente las validaciones de transbank

Location:
webpay-woocommerce-plugin
Files:
1 added
4 edited
4 copied

Legend:

Unmodified
Added
Removed
  • webpay-woocommerce-plugin/trunk/README.md

    r760404 r807735  
    68684. La página usada por HTML_TR_NORMAL = http://DIRECCIONDETUPAGINA/?page_id=xt_compra&pay=webpay&wc-api=WC_Webpay
    6969
     705. Es necesario cambiar en la página de recepción del pedido [woocommerce-thankyou] por [webpay-thankyou].
     71
    7072# Ejemplo **tbk_config.dat**. #
    7173
     
    9496```
    9597#CHANGELOG
     98* V2.2 : Se establece el short-code [webpay-thankyou] para realizar las validaciones necesarias por parte de transbank. Es necesario cambiar en la página de recepción del pedido por [woocommerce-thankyou].
     99* V2.1.9 : Se usa el estandar definido por woocommerce para los códigos de estado.
     100* V2.1.8 : Arreglada posible duplicidad cuando la orden pasa a on-hold.
     101* V2.1.7 :
     102* V2.1.6 : Modificado para que funcionara con versiones más antiguas de php.
    96103* V2.1.5 : Se cambian los permisos por defecto de la carpeta común. Con esto se deben asegurar que el usuario que ejecuta los CGI sea el mismo que crea los archivos.
    97104* V2.1.2 : Se externaliza la carpeta común al directorio de uploads. De esta manera no se borra la información al actualizar el plugin.
  • webpay-woocommerce-plugin/trunk/php/thankYouPage.php

    r804502 r807735  
    11<?php
     2if (isset($_REQUEST['status'])):
     3    if ($_REQUEST['status'] == "failure"):
     4        //echo '<h2>' . __('Un error ha ocurrido', 'webpay') . '</h2>';
    25
    3             if (isset($_REQUEST['status'])):
    4                 if ($_REQUEST['status'] == "failure"):
    5                     echo '<h2>' . __('Un error ha ocurrido', 'webpay') . '</h2>';
     6        $TBK_ID_SESION
     7                = $_REQUEST["TBK_ID_SESION"];
     8        $TBK_ORDEN_COMPRA
     9                = $_REQUEST["TBK_ORDEN_COMPRA"];
     10        ?>
     11        <h2>Transacción Fracasada - Orden <?=$_REQUEST['order']?></h2>
    612
    7                     $TBK_ID_SESION
    8                             = $_REQUEST["TBK_ID_SESION"];
    9                     $TBK_ORDEN_COMPRA
    10                             = $_REQUEST["TBK_ORDEN_COMPRA"];
    11                     ?>
    12                     <CENTER>
    13                         <B>TRANSACCIÓN FRACASADA !!!</B>
    14                         <TABLE>
    15                             <TR><TH>FRACASO</TH></TR>
    16                             <TR><TD>
    17                                     TBK_ID_SESION=<?php echo $TBK_ID_SESION; ?><BR>
    18                                     TBK_ORDEN_COMPRA=<?php echo $TBK_ORDEN_COMPRA; ?><BR>
    19                                 </TD></TR>
    20                         </TABLE>
    21                     </CENTER>
    22                     <?php
    23                 else:
    24                     //IF IT IS A WEBPAY PAYMENT
    25                     global $webpay_table_name;
    26                     global $wpdb;
    27                     $order_id = explode('_', $_REQUEST['order']);
    28                     $order_id = (int) $order_id[0];
    29                     $paramArr = array();
    30                     $myOrderDetails = $wpdb->get_row("SELECT * FROM $webpay_table_name WHERE idOrder = $order_id", ARRAY_A);
    31                     if ($myOrderDetails):
    32                         ?>
    33                         <h2 class="related_products_title order_confirmed"><?= "Información Extra de la Transacción"; ?></h2>
    34                         <div class="clear"></div>
    35                         <table class="shop_table order_details">
    36                             <thead>
    37                                 <tr>
    38                                     <th class="product-name"><?php echo "Dato" ?></th>
    39                                     <th class="product-quantity"><?php echo "Valor"; ?></th>
     13        </h3>Las posibles causas de este rechazo son:</h3>
     14
     15        <ul style="margin-left: 50px">
     16            <li>      Error en el ingreso de los datos de su tarjeta de crédito o Debito (fecha y/o código de seguridad).</li>
     17            <li>      Su tarjeta de crédito o debito no cuenta con el cupo necesario para cancelar la compra.</li>
     18            <li>      Tarjeta aún no habilitada en el sistema financiero. </li>
     19            <li>      Si el problema persiste favor comunicarse con su Banco emisor. </li>
     20        </ul>
     21
     22        <?php
     23    else:
     24        //IF IT IS A WEBPAY PAYMENT
     25        global $webpay_table_name;
     26        global $wpdb;
     27        $order_id = explode('_', $_REQUEST['order']);
     28        $order_id = (int) $order_id[0];
     29        $paramArr = array();
     30        $myOrderDetails = $wpdb->get_row("SELECT * FROM $webpay_table_name WHERE idOrder = $order_id", ARRAY_A);
     31        if ($myOrderDetails):
     32            ?>
     33            <h2 class="related_products_title order_confirmed"><?= "Información Extra de la Transacción"; ?></h2>
     34            <div class="clear"></div>
     35            <table class="shop_table order_details">
     36                <thead>
     37                    <tr>
     38                        <th class="product-name"><?php echo "Dato" ?></th>
     39                        <th class="product-quantity"><?php echo "Valor"; ?></th>
    4040
    4141
    42                                 </tr>
    43                             </thead>
    44                             <tfoot>
     42                    </tr>
     43                </thead>
     44                <tfoot>
    4545
    46                                 <tr>
    47                                     <th>Tipo de Transacción</th>
    48                                     <th>Venta</th>
     46                    <tr>
     47                        <th>Tipo de Transacción</th>
     48                        <th>Venta</th>
    4949
    50                                 </tr>
    51                                 <tr>
    52                                     <th>Nombre del Comercio</th>
    53                                     <th><?php echo $this->settings['trade_name']; ?></th>
     50                    </tr>
     51                    <tr>
     52                        <th>Nombre del Comercio</th>
     53                        <th><?php echo $this->settings['trade_name']; ?></th>
    5454
    55                                 </tr>
    56                                 <tr>
    57                                     <th>URL Comercio</th>
    58                                     <th><?php echo $this->settings['url_commerce']; ?></th>
     55                    </tr>
     56                    <tr>
     57                        <th>URL Comercio</th>
     58                        <th><?php echo $this->settings['url_commerce']; ?></th>
    5959
    60                                 </tr>
     60                    </tr>
    6161
    62                                 <tr>
    63                                     <th>Código de Autorización</th>
    64                                     <th><?php echo $myOrderDetails['TBK_CODIGO_AUTORIZACION'] ?></th>
     62                    <tr>
     63                        <th>Código de Autorización</th>
     64                        <th><?php echo $myOrderDetails['TBK_CODIGO_AUTORIZACION'] ?></th>
    6565
    6666
    67                                 </tr>
     67                    </tr>
    6868
    69                                 <tr>
    70                                     <th>Final de Tarjeta</th>
    71                                     <th><?php echo $myOrderDetails['TBK_FINAL_NUMERO_TARJETA'] ?></th>
     69                    <tr>
     70                        <th>Final de Tarjeta</th>
     71                        <th><?php echo $myOrderDetails['TBK_FINAL_NUMERO_TARJETA'] ?></th>
    7272
    7373
    74                                 </tr>
     74                    </tr>
    7575
    76                                 <tr>
    77                                     <th>Tipo de pago</th>
    78                                     <th><?php
    79                         if ($myOrderDetails['TBK_TIPO_PAGO'] == "VD") {
    80                             echo "Redcompra </th></tr>";
    81                             echo "<tr><td>Tipo de Cuota</td><td>Débito</td></tr>";
    82                         } else {
    83                             echo "Crédito </th></tr>";
    84                             echo '<tr><td>Tipo de Cuota</td><td>';
    85                             switch ($myOrderDetails['TBK_TIPO_PAGO']) {
    86                                 case 'VN':
    87                                     echo 'Sin Cuotas';
    88                                     break;
    89                                 case 'VC':
    90                                     echo 'Cuotas Normales';
    91                                     break;
    92                                 case 'SI':
    93                                     echo 'Sin interés';
    94                                     break;
    95                                 case 'CI':
    96                                     echo 'Cuotas Comercio';
    97                                     break;
     76                    <tr>
     77                        <th>Tipo de pago</th>
     78                        <th><?php
     79            if ($myOrderDetails['TBK_TIPO_PAGO'] == "VD") {
     80                echo "Redcompra </th></tr>";
     81                echo "<tr><td>Tipo de Cuota</td><td>Débito</td></tr>";
     82            } else {
     83                echo "Crédito </th></tr>";
     84                echo '<tr><td>Tipo de Cuota</td><td>';
     85                switch ($myOrderDetails['TBK_TIPO_PAGO']) {
     86                    case 'VN':
     87                        echo 'Sin Cuotas';
     88                        break;
     89                    case 'VC':
     90                        echo 'Cuotas Normales';
     91                        break;
     92                    case 'SI':
     93                        echo 'Sin interés';
     94                        break;
     95                    case 'CI':
     96                        echo 'Cuotas Comercio';
     97                        break;
    9898
    99                                 default:
    100                                     echo $myOrderDetails['TBK_TIPO_PAGO'];
    101                                     break;
    102                             }
    103                         }
     99                    default:
     100                        echo $myOrderDetails['TBK_TIPO_PAGO'];
     101                        break;
     102                }
     103            }
     104            ?>
     105
     106                            </td>
     107
     108                    </tr>
     109
     110                    <?php
     111                    if (!($myOrderDetails['TBK_TIPO_PAGO'] == "VD") || true):
    104112                        ?>
     113                        <tr>
     114                            <th>Número de Cuotas</th>
     115                            <th><?php
     116                if (!($myOrderDetails['TBK_NUMERO_CUOTAS'] == "0")) {
     117                    echo $myOrderDetails['TBK_NUMERO_CUOTAS'];
     118                } else {
     119                    echo "00";
     120                }
     121                        ?></th>
    105122
    106                                         </td>
    107 
    108                                 </tr>
    109 
    110                                 <?php
    111                                 if (!($myOrderDetails['TBK_TIPO_PAGO'] == "VD") || true):
    112                                     ?>
    113                                     <tr>
    114                                         <th>Número de Cuotas</th>
    115                                         <th><?php
    116                             if (!($myOrderDetails['TBK_NUMERO_CUOTAS'] == "0")) {
    117                                 echo $myOrderDetails['TBK_NUMERO_CUOTAS'];
    118                             } else {
    119                                 echo "00";
    120                             }
    121                                     ?></th>
    122 
    123                                     </tr>
    124                                     <?php
    125                                 endif;
    126                                 ?>
    127                             </tfoot>
    128                         </table>
     123                        </tr>
    129124                        <?php
    130125                    endif;
    131                 endif;
    132             endif;
     126                    ?>
     127                </tfoot>
     128            </table>
     129            <?php
     130        endif;
     131    endif;
     132endif;
    133133?>
  • webpay-woocommerce-plugin/trunk/readme.txt

    r804502 r807735  
    1111Tested up to: 3.6
    1212
    13 Stable tag: 2.1.8
     13Stable tag: 2.2
    1414
    1515== Description ==
     
    1919Wiki Home : https://bitbucket.org/ctala/woocommerce-webpay/wiki/Home
    2020
     21Ya ha sido bastante tiempo en el que me han preguntado por esto en los comentarios y al fin decidí liberar el código de manera OpenSource.
     22
     23Algunos de ustedes se preguntarán el por qué no cobro por este plugin, tomando en consideración que mucha gente ofrece una buena cantidad por el servicio. Bueno, la respuesta es simple; Creo que junto a la comunidad de desarrolladores podemos mejorar mucho más este código y así todos tener un plugin de una calidad mucho mayor que por la que podríamos pagar ( Suena bien no ? ).
    2124
    2225
     26A considerar :
     27
     28*El Código se distribuye bajo GPLV3.
     29*Este código YA es compatible con la última versión de WooCommerce (Version 2.0.12)
     30*El código no presenta garantía de ningún tipo.
     31*Se puso a disposición un Wiki para la instalación
     32*Se puso a disposición un BugTracker para que podamos ver los problemas que vayan saliendo en conjunto.
     33*Se asume que ya se hizo la configuración de los CGI para Transbank
     34*Si necesitan los CGI de Transbank los pueden descargar de : https://bitbucket.org/ctala/webpayconector. Ya deberían estar listos para usarlos. Con estos parto para generar un eCommerce.
     35*Para los que quieren mejorar el código, y nunca han ocupado una herramienta de control de versiones, les recomiendo que lean sobre GIT, además de lo que es un FORK.
     36
     37Recuerden cambiar el shortcode de [woocommerce-thankyou] por [webpay-thankyou] cuando corresponda.
    2338
    2439== Changelog ==
    2540
     41= 2.2 =
     42
     43Se establece el short-code [webpay-thankyou] para realizar las validaciones necesarias por parte de transbank. Es necesario cambiar en la página de recepción del pedido por [woocommerce-thankyou].
     44
     45
     46= 2.1.9 =
     47Se cambian y estandarizan las recepciones de los status según el manual de woocommerce.
     48*Pending – Order received (unpaid)
     49*Failed – Payment failed or was declined (unpaid)
     50*Processing – Payment received and stock has been reduced- the order is awaiting fulfilment
     51*Completed – Order fulfilled and complete – requires no further action
     52*On-Hold – Awaiting payment – stock is reduced, but you need to confirm payment
     53*Cancelled – Cancelled by an admin or the customer – no further action required
     54*Refunded – Refunded by an admin - no further action required
    2655
    2756= 2.1.8 =
    2857Arreglada posible duplicidad cuando la orden pasa a on-hold.
     58
     59= 2.1.7 =
     60Arreglado el error de callback con las direcciones web largas. Se usan los shortlinks para no tener problemas.
    2961
    3062= 2.1.6 =
  • webpay-woocommerce-plugin/trunk/webpay.php

    r804502 r807735  
    44  Description: Sistema de pagos de WooCommerce con WebPay
    55  Author: Cristian Tala Sánchez
    6   Version: 2.1.8
     6  Version: 2.1.9-DEV
    77  Author URI: www.cristiantala.cl
    88  Plugin URI: https://bitbucket.org/ctala/woocommerce-webpay/wiki/Home
     
    2828register_activation_hook(__FILE__, 'webpay_install');
    2929add_action('plugins_loaded', 'init_woocommerce_webpay');
     30add_shortcode('webpay_thankyou', 'webpayThankYou');
     31
     32
     33
     34/*
     35 * La siguiente función  hace posible filtrar el acceso a la página de éxito de woocommerce.
     36 */
     37
     38function webpayThankYou() {
     39    global $woocommerce;
     40    $SUFIJO = "[WEBPAY-THANKYOU]";
     41    /*
     42     * Revisamos si los parametros necesarios para ver la página existen.
     43     * El plugin en general pasa los parametros de id de la orden, la llave y el status.
     44     */
     45    log_me("Entrando al ThankYouPage", $SUFIJO);
     46
     47    if (!(isset($_GET['order']) && isset($_GET['status']) && isset($_GET['key']))) {
     48        ?>
     49        <p><?= "No puedes acceder a esta página de manera directa"; ?></p>
     50
     51        <?
     52        break;
     53    } else {
     54        /*
     55         * Si los parametros existen muestro la información si es que el status no es fallido.
     56         * Además de la recepción, se que es fallido cuando NO es pagado.
     57         * Para los siguientes status NO puedo mostrar esta página si es que el pago es con webpay.
     58         *
     59          - Pending – Order received (unpaid)
     60          - Failed – Payment failed or was declined (unpaid)
     61          - On-Hold – Awaiting payment – stock is reduced, but you need to confirm payment
     62          - Cancelled – Cancelled by an admin or the customer – no further action required
     63          - Refunded – Refunded by an admin - no further action required
     64         *
     65         * Por lo que solo se puede mostrar si la orden está completada o en proceso Si es que la orden es exitosa.
     66         *
     67         */
     68        $order_id = explode('_', $_GET['order']);
     69        $order_id = (int) $order_id[0];
     70
     71        if (!is_numeric($order_id)) {
     72            echo "<p>Acaba de ocurrir un error tratando de recuperar la información de la orden</p>";
     73        }
     74        $order = new WC_Order($order_id);
     75        if ($order) {
     76            log_me("ORDEN EXISTENTE", $SUFIJO);
     77            if (in_array($order->status, array('failed'))) {
     78                log_me("La orden está fallida, se carga la página de manera normal", $SUFIJO);
     79                echo do_shortcode('[woocommerce_thankyou]');
     80            } else {
     81                /*
     82                 * Debo corroborar que la orden este en proceso o completada si el pago es con webpay.
     83                 */
     84                log_me("La transacción no debería ser fallida, se verifica", $SUFIJO);
     85                $paymentMethod = $order->order_custom_fields[_payment_method][0];
     86                if ($paymentMethod == "webpay") {
     87                    log_me("\t -> El pago de la orden fue con WebPay", $SUFIJO);
     88                    if ($order->status == "completed" || $order->status == "processing") {
     89                        echo do_shortcode('[woocommerce_thankyou]');
     90                    } else {
     91                        /*
     92                         * Si este es el caso, se está intentando acceder a la página sin pasar por el ciclo regular.
     93                         */
     94                        echo "<h2>No te encuentras autorizado para acceder a esta página</h2>";
     95                        return;
     96                    }
     97                } else {
     98                    log_me("\t -> El pago de la orden NO fue con WebPay o no se a realizado: $paymentMethod ", $SUFIJO);
     99
     100                    if ($paymentMethod !== null) {
     101                        echo do_shortcode('[woocommerce_thankyou]');
     102                    } else {
     103                        echo "Esta orden aún no ha sido pagada o procesada. Por favor vuleve cuando lo hayas hecho.";
     104                        return;
     105                    }
     106                }
     107            }
     108        } else {
     109            //La orden no existía.
     110            log_me("ORDEN NO EXISTENTE", $SUFIJO);
     111            echo "<p>Lamentablemente la orden buscada no existe o no coincide con la información ingresada</p>";
     112            return;
     113        }
     114    }
     115    log_me("Saliendo al ThankYouPage", $SUFIJO);
     116}
    30117
    31118/*
     
    62149        public function __construct() {
    63150
     151
    64152            if (isset($_REQUEST['page_id'])):
     153
    65154                if ($_REQUEST['page_id'] == 'xt_compra') {
    66155                    add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'xt_compra'));
    67156                } else {
    68                     //add_action('init', array(&$this, 'check_webpay_response'));
     157
    69158                    $this->check_webpay_response();
    70159                }
     
    90179// Actions
    91180            add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
    92            
     181
    93182            add_action('woocommerce_thankyou_webpay', array(&$this, 'thankyousuccess_page'));
    94183            add_action('woocommerce_receipt_webpay', array(&$this, 'receipt_page'));
    95 
    96184        }
    97185
     
    186274         * @return void
    187275         */
    188      
    189 
    190276        function thankyousuccess_page() {
    191277            include_once plugin_dir_path(__FILE__) . '/php/thankYouPage.php';
     
    196282            echo $this->generate_webpay_form($order);
    197283        }
    198 
    199 
    200284
    201285        function process_payment($order_id) {
     
    335419                        if ($order->status !== 'completed') {
    336420                            if ($status == 'success') {
    337                                 /* $order -> payment_complete();
    338                                   $woocommerce -> cart -> empty_cart();
    339                                   $order -> update_status('completed'); */
    340 
    341                                 // Mark as on-hold (we're awaiting the cheque)
    342                                 $order->update_status('on-hold');
     421                                $woocommerce->cart->empty_cart();
     422                                // Mark as Processing, we already received the money.
     423                                $order->update_status('processing');
    343424
    344425                                // Reduce stock levels
     
    387468                                );
    388469
    389                                 //                                log_me("INICIO INFO PARA AGREGAR A LA DB EN CHECK RESPONSE");
    390                                 //                                log_me($TBK); 
    391                                 //                                log_me("FIN INFO PARA AGREGAR A LA DB EN CHECK RESPONSE");
    392                                 //                               
     470
    393471                                log_me("INSERTANDO EN LA BDD");
    394472                                woocommerce_payment_complete_add_data_webpay($order_id, $TBK);
     
    406484                        }
    407485                    } catch (Exception $e) {
    408                        
     486
    409487                        $this->msg = "Ha ocurrido un error procesando el pago.";
    410488                        add_action('the_content', array(&$this, 'thankyouContent'));
    411489                    }
    412                    
    413490                }
    414491            } else {
     
    418495        }
    419496
    420    
    421497        function thankyouContent($content) {
    422498            echo $this->msg;
     
    495571            } else {
    496572                log_me("ORDEN EXISTENTE " . $order_id, $sufijo);
    497                 //CUANDO UNA ORDEN ES PAGADA SE VA A ON HOLD.
    498 
    499                 if ($order->status == 'completed'||$order->status == 'on-hold') {
    500                     log_me("ORDEN YA PAGADA (COMPLETED) EXISTENTE " . $order_id, "\t" . $sufijo);
     573                //CUANDO UNA ORDEN ES PAGADA SE VA A PROCESSING.
     574
     575                if ($order->status == 'completed' || $order->status == 'processing' || $order->status == 'refunded' || $order->status == 'canceled') {
     576                    log_me("ORDEN YA PAGADA (" . $order->status . ") EXISTENTE " . $order_id, "\t" . $sufijo);
    501577                    die('RECHAZADO');
    502578                } else {
    503579
    504580                    if ($order->status == 'pending' || $order->status == 'failed') {
    505                         log_me("ORDEN DE COMPRA NO PAGADA (PENDING). Se procede con el pago de la orden " . $order_id, $sufijo);
     581                        log_me("ORDEN DE COMPRA NO PAGADA (" . $order->status . "). Se procede con el pago de la orden " . $order_id, $sufijo);
    506582                    } else {
    507583                        log_me("ORDEN YA PAGADA (" . $order->status . ") EXISTENTE " . $order_id, "\t" . $sufijo);
     
    536612            }
    537613            fclose($fp);
    538             //Validacin de respuesta de Transbank, solo si es 0 continua con la pagina de cierre
     614            //Validación de respuesta de Transbank, solo si es 0 continua con la pagina de cierre
    539615            if ($TBK_RESPUESTA == "0") {
    540616                $acepta = true;
     
    542618                $acepta = false;
    543619            }
    544             //validacin de monto y Orden de compra
     620            //validación de monto y Orden de compra
    545621            if ($TBK_MONTO == $monto && $TBK_ORDEN_COMPRA == $ordenCompra && $acepta == true) {
    546622                $acepta = true;
     
    549625            }
    550626
    551             //Validacin MAC
     627            //Validación MAC
    552628            if ($acepta == true) {
    553629                exec($cmdline, $result, $retint);
     
    559635            ?>
    560636            <html>
     637                <?php
     638                if ($acepta == true) {
     639                    ?>
     640                    ACEPTADO
     641                <?php } else { ?>
     642                    RECHAZADO
     643                <?php } exit; ?>
     644            </html>
     645
    561646            <?php
    562             if ($acepta == true) {
    563                 ?>
    564                     ACEPTADO
    565             <?php } else { ?>
    566                     RECHAZADO
    567             <?php } exit; ?>
    568             </html>
    569 
    570                 <?php
    571                 log_me("FINALIZANDO XT_COMPRA", $sufijo);
    572             }
    573 
    574         }
    575 
    576         //End of the GateWay Class
    577 
    578         function woocommerce_payment_complete_add_data_webpay($order_id, $TBK) {
    579             global $webpay_table_name;
    580             global $wpdb;
    581 
    582             $order = new WC_Order($order_id);
    583             $order->add_order_note("Pago Completado. Transacción : " . $TBK['TBK_CODIGO_AUTORIZACION'][1]);
    584 
    585             log_me("idOrden : ");
    586             log_me($order_id);
    587             log_me('TBK:');
    588             log_me($TBK);
    589             $rows_affected = $wpdb->insert($webpay_table_name, array(
    590                 'idOrder' => $order_id,
    591                 'TBK_ORDEN_COMPRA' => $TBK['TBK_ORDEN_COMPRA'][1],
    592                 'TBK_TIPO_TRANSACCION' => $TBK['TBK_TIPO_TRANSACCION'][1],
    593                 'TBK_RESPUESTA' => $TBK['TBK_RESPUESTA'][1],
    594                 'TBK_MONTO' => $TBK['TBK_MONTO'][1],
    595                 'TBK_CODIGO_AUTORIZACION' => $TBK['TBK_CODIGO_AUTORIZACION'][1],
    596                 'TBK_FINAL_NUMERO_TARJETA' => $TBK['TBK_FINAL_NUMERO_TARJETA'][1],
    597                 'TBK_FECHA_CONTABLE' => $TBK['TBK_FECHA_CONTABLE'][1],
    598                 'TBK_FECHA_TRANSACCION' => $TBK['TBK_FECHA_TRANSACCION'][1],
    599                 'TBK_HORA_TRANSACCION' => $TBK['TBK_HORA_TRANSACCION'][1],
    600                 'TBK_ID_TRANSACCION' => $TBK['TBK_ID_TRANSACCION'][1],
    601                 'TBK_TIPO_PAGO' => $TBK['TBK_TIPO_PAGO'][1],
    602                 'TBK_NUMERO_CUOTAS' => $TBK['TBK_NUMERO_CUOTAS'][1],
    603                     )
    604             );
    605         }
    606 
    607         add_action('woocommerce_payment_complete', 'woocommerce_payment_complete_add_data_webpay', 10, 1);
     647            log_me("FINALIZANDO XT_COMPRA", $sufijo);
     648        }
     649
    608650    }
    609     ?>
     651
     652    //End of the GateWay Class
     653
     654    function woocommerce_payment_complete_add_data_webpay($order_id, $TBK) {
     655        global $webpay_table_name;
     656        global $wpdb;
     657
     658        $order = new WC_Order($order_id);
     659        $order->add_order_note("Pago Completado. Transacción : " . $TBK['TBK_CODIGO_AUTORIZACION'][1]);
     660
     661        log_me("idOrden : ");
     662        log_me($order_id);
     663        log_me('TBK:');
     664        log_me($TBK);
     665        $rows_affected = $wpdb->insert($webpay_table_name, array(
     666            'idOrder' => $order_id,
     667            'TBK_ORDEN_COMPRA' => $TBK['TBK_ORDEN_COMPRA'][1],
     668            'TBK_TIPO_TRANSACCION' => $TBK['TBK_TIPO_TRANSACCION'][1],
     669            'TBK_RESPUESTA' => $TBK['TBK_RESPUESTA'][1],
     670            'TBK_MONTO' => $TBK['TBK_MONTO'][1],
     671            'TBK_CODIGO_AUTORIZACION' => $TBK['TBK_CODIGO_AUTORIZACION'][1],
     672            'TBK_FINAL_NUMERO_TARJETA' => $TBK['TBK_FINAL_NUMERO_TARJETA'][1],
     673            'TBK_FECHA_CONTABLE' => $TBK['TBK_FECHA_CONTABLE'][1],
     674            'TBK_FECHA_TRANSACCION' => $TBK['TBK_FECHA_TRANSACCION'][1],
     675            'TBK_HORA_TRANSACCION' => $TBK['TBK_HORA_TRANSACCION'][1],
     676            'TBK_ID_TRANSACCION' => $TBK['TBK_ID_TRANSACCION'][1],
     677            'TBK_TIPO_PAGO' => $TBK['TBK_TIPO_PAGO'][1],
     678            'TBK_NUMERO_CUOTAS' => $TBK['TBK_NUMERO_CUOTAS'][1],
     679                )
     680        );
     681    }
     682
     683    add_action('woocommerce_payment_complete', 'woocommerce_payment_complete_add_data_webpay', 10, 1);
     684}
     685?>
Note: See TracChangeset for help on using the changeset viewer.