function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id) { $order = new VirtueMartModelOrders(); $my_order = $order->getOrder($virtuemart_order_id); $html = ''; $htmlStatus = ''; $gettpstatus = vRequest::getString('gettpstatus', 0); if ($gettpstatus == 1) { $method = $this->getVmPluginMethod($payment_method_id); require_once 'cs/TPConnector.php'; $tpconnector = new TPConnector(); $connector_data = $tpconnector->createTPConnector($method); $connector = $connector_data['connector']; $security_code = $connector_data['security']; $merchant = $connector_data['merchant']; $optionsGS = array('MERCHANT' => $merchant, 'OPERATIONID' => $my_order['details']['BT']->order_number); $status = $connector->getStatus($optionsGS); if (isset($status['Operations'])) { if (is_array($status['Operations'])) { foreach ($status['Operations'] as $index => $value) { $htmlStatus .= '<tr>'; $htmlStatus .= '<td>'; $htmlStatus .= '' . $index . ': '; $htmlStatus .= '</td>'; $htmlStatus .= '<td>'; $htmlStatus .= '' . $value . ''; $htmlStatus .= '</td>'; $htmlStatus .= '</tr>'; } } } } $html = '<table class="adminlist table ">' . "\n"; $html .= '<thead>' . "\n"; $html .= '<tr>' . "\n"; $html .= '<th colspan="2">' . "\n"; $html .= 'TodoPago Status' . "\n"; $html .= '</th>' . "\n"; $html .= '</tr>' . "\n"; $html .= '</thead>' . "\n"; $html .= '<tr>' . "\n"; $html .= '<td colspan="2">' . "\n"; $html .= '<input onclick="getTPStatus()" style="cursor:pointer;width: 300px; margin-left: auto; display: block; margin-right: auto; height: 50px;" id="updateTPStatus" type="button" value="Get TodoPago Status">' . "\n"; $html .= '</td>' . "\n"; $html .= '</tr>' . "\n"; $html .= $htmlStatus; $html .= '</table>' . "\n"; $js = '<script type="text/javascript"> function getTPStatus(){ window.location.href = window.location.href+"&gettpstatus=1"; } </script>'; $html .= $js; return $html; }
function plgVmOnShowOrderBEPayment($virtuemart_order_id, $payment_method_id) { $order = new VirtueMartModelOrders(); $my_order = $order->getOrder($virtuemart_order_id); $method = $this->getVmPluginMethod($payment_method_id); require_once 'cs/TPConnector.php'; $tpconnector = new TPConnector(); $connector_data = $tpconnector->createTPConnector($method); $connector = $connector_data['connector']; $security_code = $connector_data['security']; $merchant = $connector_data['merchant']; $optionsGS = array('MERCHANT' => $merchant, 'OPERATIONID' => $my_order['details']['BT']->order_number); if ($merchant == "") { } else { $status = $connector->getStatus($optionsGS); include_once "views/get_status_view.php"; echo "<hr />"; include_once "views/get_devoluciones_view.php"; // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select all records from the user profile table where key begins with "custom.". // Order it by the ordering field. $query->select($db->quoteName(array('tp_security_code_prod'))); $query->from($db->quoteName('#__virtuemart_payment_plg_todopago')); $query->where($db->quoteName("virtuemart_order_id") . "=" . $db->quote($_GET['virtuemart_order_id'])); // Reset the query using our newly populated query object. $db->setQuery($query); // Load the results as a list of stdClass objects (see later for more options on retrieving data). $payment_element = $db->loadObjectList(); $_requestKey = $payment_element[0]->tp_security_code_prod; /////devoluciones if ($_POST["dev_params"] == "dev_params") { if ($method->tp_ambiente == "test") { $security = $method->tp_security_code_test; $merchant = $method->tp_id_site_test; $rest_end_point = "https://developers.todopago.com.ar/t/1.1/api/Authorize"; } else { $security = $method->tp_security_code_prod; $merchant = $method->tp_id_site_prod; $rest_end_point = "https://api.todopago.com.ar/t/1.1/api/Authorize"; } $data = array("RequestType" => "ReturnRequest", "Security" => $security, "RequestKey" => $_requestKey, "Merchant" => $merchant, "Amount" => $_POST["ReturnRequestAmount"]); $data_string = json_encode($data); $ch = curl_init($rest_end_point); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', "Authorization: {$method->tp_auth_http}")); $result = curl_exec($ch); $rta = json_decode($result); echo "<h4>" . $rta->ReturnResponse->StatusMessage . "</h4>"; if ($rta->ReturnResponse->StatusCode == 2011) { echo '<h4 style="color:red">' . "DEVOLUCION OK!" . '</h4>'; echo '<script>alert("Su devolucion se ha realizado con exito")</script>'; } else { echo '<h4 style="color:red">' . "NO SE PUDO REALIZAR DEVOLUCION INTENTE MAS TARDE!" . '</h4>'; } } } ////devoluciones }