Ticket #757 -> El formulario de AMIGOS no hace nada al pulsar el botón de 'Enviar'
git-svn-id: https://192.168.0.254/svn/Proyectos.FundacionLQDVI_Web/trunk@54 77ab8c26-3d69-2c4d-86f2-786f4ba54905
This commit is contained in:
parent
2559f57705
commit
417d360549
@ -3,7 +3,9 @@
|
|||||||
add_filter('gform_confirmation', 'build_confirmation_1', 10, 4);
|
add_filter('gform_confirmation', 'build_confirmation_1', 10, 4);
|
||||||
|
|
||||||
function build_confirmation_1($confirmation, $form, $entry, $ajax) {
|
function build_confirmation_1($confirmation, $form, $entry, $ajax) {
|
||||||
$confirmation = llamar_pasarela_socio($entry);
|
if($form["id"] == "1"){
|
||||||
|
$confirmation = llamar_pasarela_socio($entry);
|
||||||
|
}
|
||||||
return $confirmation;
|
return $confirmation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
150
src/wp-content/themes/lqdvi/pasarela_tpv.php.produccion
Normal file
150
src/wp-content/themes/lqdvi/pasarela_tpv.php.produccion
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
add_filter('gform_confirmation', 'build_confirmation_1', 10, 4);
|
||||||
|
|
||||||
|
function build_confirmation_1($confirmation, $form, $entry, $ajax) {
|
||||||
|
if($form["id"] == "1"){
|
||||||
|
$confirmation = llamar_pasarela_socio($entry);
|
||||||
|
}
|
||||||
|
return $confirmation;
|
||||||
|
}
|
||||||
|
|
||||||
|
function llamar_pasarela_socio($entry) {
|
||||||
|
|
||||||
|
/*$file = fopen("tpv.log", "w");
|
||||||
|
fwrite ($file, "SOCIO\n");
|
||||||
|
foreach($entry as $k => $v) {
|
||||||
|
fwrite($file, "$k ==> $v\n");
|
||||||
|
}
|
||||||
|
fwrite ($file, "DATOS\n");*/
|
||||||
|
|
||||||
|
$nombre_cuotas = array('12' => 'mensual',
|
||||||
|
'4' => 'trimestral',
|
||||||
|
'2' => 'semestral',
|
||||||
|
'1' => 'anual');
|
||||||
|
|
||||||
|
$datos = array();
|
||||||
|
|
||||||
|
$datos['url_tpvv'] = 'https://sis.sermepa.es/sis/realizarPago'; //produccion
|
||||||
|
$datos['clave'] = 'Q00348RM5R930U08'; //produccion
|
||||||
|
$datos['code'] = '322204298'; //produccion
|
||||||
|
$datos['terminal'] = '1';
|
||||||
|
|
||||||
|
$datos['nombre_comercio'] = 'Fundacion Lo que de verdad importa';
|
||||||
|
$datos['url_comercio'] = 'http://www.loquedeverdadimporta.org/wp-content/themes/lqdvi/respuesta_pasarela_tpv.php';
|
||||||
|
$datos['titular'] = $entry[1] . ' ' . $entry[2];
|
||||||
|
|
||||||
|
|
||||||
|
$datos['num_orden'] = date('ymdHis');
|
||||||
|
$datos['moneda'] = '978'; //euros
|
||||||
|
$datos['URLOK'] = 'http://www.loquedeverdadimporta.org/quieres-ser-amigo/gracias-por-ser-nuestro-socio/';
|
||||||
|
$datos['URLKO'] = 'http://www.loquedeverdadimporta.org/se-ha-producido-un-error/';
|
||||||
|
|
||||||
|
// Convertir la cantidad
|
||||||
|
$cuota = explode("|", $entry[9]); //<- formato: Xfrecuencia_ano|cantidad_euros (X -> Cuota fija (una F) o cuota libre (una L)
|
||||||
|
$cuota[0] = str_replace("F", "", $cuota[0]);
|
||||||
|
$cuota[0] = str_replace("L", "", $cuota[0]);
|
||||||
|
$datos['frecuencia_ano'] = $cuota[0];
|
||||||
|
if ($datos['frecuencia_ano'] != 0) { // Es una cuota
|
||||||
|
//fwrite($file , "ES UNA CUOTA ==========\n");
|
||||||
|
//$datos['frecuencia_dias'] = round(365/$datos['frecuencia_ano']);
|
||||||
|
//$datos['frecuencia_fecha_limite'] = date("Y-m-d", strtotime('+10 Year')); // Mantener las cuotas 10 años a partir de hoy
|
||||||
|
|
||||||
|
// Puede ser una cuota fija o una cuota libre.
|
||||||
|
// Si es cuota fija -> $cuota[1] != 0
|
||||||
|
// Si es cuota libre -> $cuota[1] == 0
|
||||||
|
|
||||||
|
$datos['cantidad'] = $cuota[1] * 100;
|
||||||
|
if ($datos['cantidad'] == 0) {
|
||||||
|
//fwrite($file , "ES UNA CUOTA LIBRE ==========\n");
|
||||||
|
// Es una cuota libre. Hay que buscar el importe en los campos correspondientes
|
||||||
|
// Cuota libre mensual -> campo $entry[23]
|
||||||
|
// Cuota libre trimestral -> campo $entry[24]
|
||||||
|
// Cuota libre semestral -> campo $entry[25]
|
||||||
|
// Cuota libre anual -> campo $entry[26]
|
||||||
|
if ($datos['frecuencia_ano'] == 12) {
|
||||||
|
$datos['cantidad'] = ereg_replace("[^0-9]", "", $entry[23]);
|
||||||
|
}
|
||||||
|
if ($datos['frecuencia_ano'] == 4) {
|
||||||
|
$datos['cantidad'] = ereg_replace("[^0-9]", "", $entry[24]);
|
||||||
|
}
|
||||||
|
if ($datos['frecuencia_ano'] == 2) {
|
||||||
|
$datos['cantidad'] = ereg_replace("[^0-9]", "", $entry[25]);
|
||||||
|
}
|
||||||
|
if ($datos['frecuencia_ano'] == 1) {
|
||||||
|
$datos['cantidad'] = ereg_replace("[^0-9]", "", $entry[26]);
|
||||||
|
}
|
||||||
|
$datos['producto'] = 'Cuota ' . $nombre_cuotas[$datos['frecuencia_ano']] . ' libre LQDVI';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$datos['producto'] = 'Cuota ' . $nombre_cuotas[$datos['frecuencia_ano']] . ' LQDVI';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Método de pago:
|
||||||
|
* T: significa pago con tarjeta.
|
||||||
|
* D: significa pago por domiciliación bancaria.
|
||||||
|
* R: significa pago por transferencia.
|
||||||
|
*/
|
||||||
|
$datos['metodo_pago'] = 'D'; // <- Domiciliación
|
||||||
|
//$datos['suma_total'] = $datos['cantidad'] * ($datos['frecuencia_ano']*10); // Calcular el total de cuotas en 10 años
|
||||||
|
$datos['transaction_type'] = '0'; // <- Autorización ('5' <- Transacción recurrente)
|
||||||
|
} else { // Es una aportación puntual
|
||||||
|
$datos['cantidad'] = ereg_replace("[^0-9]", "", $entry[19]);
|
||||||
|
$datos['metodo_pago'] = 'T'; // <- Tarjeta
|
||||||
|
$datos['producto'] = 'Aportacion LQDVI';
|
||||||
|
$datos['transaction_type'] = '0'; // <- Autorización
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcular firma
|
||||||
|
/* if ($datos['frecuencia_ano'] != 0) { // Es una cuota
|
||||||
|
* $datos['mensaje'] = $datos['cantidad'].$datos['num_orden'].$datos['code'].$datos['moneda'].$datos['suma_total'].$datos['transaction_type'].$datos['url_comercio'].$datos['clave'];
|
||||||
|
*} else { // Es una aportación puntual
|
||||||
|
* $datos['mensaje'] = $datos['cantidad'].$datos['num_orden'].$datos['code'].$datos['moneda'].$datos['transaction_type'].$datos['url_comercio'].$datos['clave'];
|
||||||
|
*}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Calcular firma
|
||||||
|
$datos['mensaje'] = $datos['cantidad'].$datos['num_orden'].$datos['code'].$datos['moneda'].$datos['transaction_type'].$datos['url_comercio'].$datos['clave'];
|
||||||
|
$datos['firma'] = strtoupper(sha1($datos['mensaje']));
|
||||||
|
|
||||||
|
/*fwrite($file , "VOLCADO DE datos ==========\n");
|
||||||
|
foreach($datos as $k => $v)
|
||||||
|
fwrite($file, "$k ==> $v\n"); */
|
||||||
|
|
||||||
|
$confirmation = "<div id='gforms_confirmation_message' style='text-align:center; padding: 10px;'>";
|
||||||
|
$confirmation .= "Conectando con pasarela de pago...";
|
||||||
|
$confirmation .= "<form method='post' action='".$datos['url_tpvv']."' name='form_to_tpv' id='form_to_tpv'>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_Titular' value='".$datos['titular']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_Amount' value='".$datos['cantidad']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_Currency' value='".$datos['moneda']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_Order' value='".$datos['num_orden']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_MerchantCode' value='".$datos['code']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_Terminal' value='".$datos['terminal']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_TransactionType' value='".$datos['transaction_type']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_MerchantURL' value='".$datos['url_comercio']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_MerchantSignature' value='".$datos['firma']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_ProductDescription' value='".$datos['producto']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_UrlOK' value='".$datos['URLOK']."'/>";
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_UrlKO' value='".$datos['URLKO']."'/>";
|
||||||
|
|
||||||
|
/* if ($datos['frecuencia_ano'] != 0) { // Es una cuota
|
||||||
|
* $confirmation .= "<input type='hidden' name='Ds_Merchant_DateFrecuency' value='".$datos['frecuencia_dias']."'/>";
|
||||||
|
* $confirmation .= "<input type='hidden' name='Ds_Merchant_ChargeExpiryDate' value='".$datos['frecuencia_fecha_limite']."'/>";
|
||||||
|
* $confirmation .= "<input type='hidden' name='Ds_Merchant_SumTotal' value='".$datos['suma_total']."'/>";
|
||||||
|
*}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$confirmation .= "<input type='hidden' name='Ds_Merchant_PayMethods' value='".$datos['metodo_pago']."'/>";
|
||||||
|
$confirmation .= "</form>";
|
||||||
|
$confirmation .= "</div>";
|
||||||
|
$confirmation .= "<script type='text/javascript'>";
|
||||||
|
$confirmation .= "document.getElementById('form_to_tpv').submit();";
|
||||||
|
$confirmation .= "</script>";
|
||||||
|
|
||||||
|
/*fwrite($file, $confirmation);
|
||||||
|
fclose($file); */
|
||||||
|
return $confirmation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user