Cambios en formulario de registro de usuarios
This commit is contained in:
12
.env
12
.env
@@ -4,7 +4,7 @@
|
||||
APP_MODE = 0
|
||||
|
||||
#Variables HMNGY Middleware productivo
|
||||
API_URL = https://apis.hmngyportal.com
|
||||
API_URL = https://gateway.calidadbmasconsulting.com
|
||||
#API_URL=https://apihmngy.stofactura.com
|
||||
API_KEY_DEFINITION = x-api-key
|
||||
API_KEY = jNJdG9zBY92NSAALgnEdsoEIRycJiAScB6pBgIADsyg=
|
||||
@@ -15,16 +15,16 @@ DEV_API_KEY_DEFINITION = x-api-key
|
||||
DEV_API_KEY = jNJdG9zBY92NSAALgnEdsoEIRycJiAScB6pBgIADsyg=
|
||||
|
||||
#VARIABLES DB
|
||||
DB_HOST = 122.8.178.132
|
||||
DB_USER = adminHMNGY
|
||||
DB_PASS = h$yoLrombE36Vgn
|
||||
DB_NAME = apirest
|
||||
DB_HOST = 192.168.100.127
|
||||
DB_USER = gateway
|
||||
DB_PASS = 7Zrs5447JkLReHH
|
||||
DB_NAME = gateway
|
||||
|
||||
#VARIABLES DB
|
||||
DEV_DB_HOST = 127.0.0.1
|
||||
DEV_DB_USER = root
|
||||
DEV_DB_PASS =
|
||||
DEV_DB_NAME = apirest_dev
|
||||
DEV_DB_NAME = gateway
|
||||
|
||||
#SAP PROD
|
||||
SAP_URL=122.8.178.132
|
||||
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"editor.stickyScroll.enabled": false
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
var apiKey = "hmngy-yxZHKAcUkSHiET17TlJ_v3qrbIo5JGMr";
|
||||
var apiKey = "hmngy-TGFNKK1ZDpj7fUe41OOlh9k-CoYss53A";
|
||||
|
||||
function stripeTokenHandler(token) {
|
||||
let form = document.getElementById("payment-form");
|
||||
@@ -11,11 +11,11 @@ function stripeTokenHandler(token) {
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
fetch("http://127.0.0.1:8000/stripe/obtLavePublicaStripe", {
|
||||
fetch("https://gateway.calidadbmasconsulting.com/api/obtLavePublicaStripe", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Accept": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ apiKey: apiKey }),
|
||||
})
|
||||
@@ -104,7 +104,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
`;
|
||||
|
||||
fetch("http://127.0.0.1:8000/stripe/createPayment", {
|
||||
fetch("https://gateway.calidadbmasconsulting.com/api/createPayment", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
var apiKey="hmngy-yxZHKAcUkSHiET17TlJ_v3qrbIo5JGMr";
|
||||
var apiKey = "hmngy-TGFNKK1ZDpj7fUe41OOlh9k-CoYss53A";
|
||||
|
||||
function stripeTokenHandler(token) {
|
||||
// Insert the token ID into the form so it gets submitted to the server
|
||||
@@ -14,11 +14,11 @@ function stripeTokenHandler(token) {
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
fetch(`http://127.0.0.1:8000/stripe/obtLavePublicaStripe`, {
|
||||
fetch(`https://gateway.calidadbmasconsulting.com/api/obtLavePublicaStripe`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Accept": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
apiKey: apiKey,
|
||||
@@ -26,7 +26,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
|
||||
console.log(data);
|
||||
stripeLlave = data[0].clave_publica;
|
||||
if(data[0].clave_publica==undefined || data[0].clave_publica==[])
|
||||
{
|
||||
@@ -113,7 +113,7 @@ form.addEventListener("submit", function (event) {
|
||||
<div class='spinner-border text-warning' role='status'><span class='sr-only'></span></div>
|
||||
`;
|
||||
|
||||
fetch("http://127.0.0.1:8000/stripe/createPayment", {
|
||||
fetch("https://gateway.calidadbmasconsulting.com/api/createPayment", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
@@ -147,7 +147,6 @@ form.addEventListener("submit", function (event) {
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
//console.error("Error al obtener usuarios:", error);
|
||||
showToast('Error: ApiKey no encontrado', "error");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -232,7 +232,8 @@
|
||||
integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous">
|
||||
</script>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
<script src="js/scriptPasarela.js"></script>
|
||||
<script src="assets/js/hmngypasarela.js"></script>
|
||||
<!--script src="js/scriptPasarela.js"></script-->
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -35,3 +35,52 @@
|
||||
{"timestamp":"2025-08-04 14:44:12","level":"success","message":"Usuario enviado a API","context":{"usuario":"admin","empresa":"KINGDOM PROJECT A.C","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-08-04 14:54:08","level":"success","message":"Usuario enviado a API","context":{"usuario":"admin","empresa":"KINGDOM PROJECT A.C","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-08-04 23:34:12","level":"success","message":"Usuario enviado a API","context":{"usuario":"LuisAngel","empresa":"KINGDOM PROJECT A.C","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-21 18:37:36","level":"success","message":"Usuario enviado a API","context":{"usuario":"Kingdom_Project","empresa":"KINGDOM PROJECT A.C","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-21 19:33:46","level":"success","message":"Usuario enviado a API","context":{"usuario":"Kingdom_Project","empresa":"KINGDOM PROJECT A.C","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-23 22:32:28","level":"error","message":"Error general en process_user.php","context":{"error":"Error de conexi\u00f3n con la API: SSL connection timeout","trace":"#0 C:\\laragon\\www\\hmnypasarela\\php\\process_user.php(37): sendToLaravelAPI(Array, Array)\n#1 {main}","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:31:48","level":"success","message":"Usuario enviado a API","context":{"usuario":"DEMO1","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:34:53","level":"success","message":"Usuario enviado a API","context":{"usuario":"admin","empresa":"Demo","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:45:02","level":"success","message":"Usuario enviado a API","context":{"usuario":"admin","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:46:12","level":"success","message":"Usuario enviado a API","context":{"usuario":"134234r","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:47:40","level":"success","message":"Usuario enviado a API","context":{"usuario":"123","empresa":"Demo123","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:48:54","level":"success","message":"Usuario enviado a API","context":{"usuario":"lugel_sa","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:52:00","level":"success","message":"Usuario enviado a API","context":{"usuario":"123123","empresa":"demo29182","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-27 23:56:07","level":"success","message":"Usuario enviado a API","context":{"usuario":"12313","empresa":"Demo123","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 00:00:09","level":"success","message":"Usuario enviado a API","context":{"usuario":"12313","empresa":"DEMO12123","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 00:01:27","level":"success","message":"Usuario enviado a API","context":{"usuario":"1231414124","empresa":"Demo987","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 00:27:47","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwdqwd1","empresa":"dqwdwdqwd","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 00:29:46","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 00:29:46","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php13CE.tmp","exists":true,"readable":true,"size":181622,"error":0}}
|
||||
{"timestamp":"2025-10-28 00:29:48","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwdqwdqo","empresa":"wdoqiwjdoqiwdo","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:41:48","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:41:48","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php22A1.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:41:50","level":"error","message":"Error general en process_user.php","context":{"error":"Error de conexi\u00f3n con la API: Failed to connect to 127.0.0.1 port 8000 after 2027 ms: Couldn't connect to server","trace":"#0 C:\\laragon\\www\\hmnypasarela\\php\\process_user.php(37): sendToLaravelAPI(Array, Array)\n#1 {main}","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:43:42","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:43:42","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\phpE14A.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:43:44","level":"error","message":"Error general en process_user.php","context":{"error":"Error de conexi\u00f3n con la API: Failed to connect to 127.0.0.1 port 8000 after 2046 ms: Couldn't connect to server","trace":"#0 C:\\laragon\\www\\hmnypasarela\\php\\process_user.php(37): sendToLaravelAPI(Array, Array)\n#1 {main}","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:44:39","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:44:39","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\phpBDA0.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:44:47","level":"success","message":"Usuario enviado a API","context":{"usuario":"12e12e12e1","empresa":"Demo12","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:49:44","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:49:44","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php65A5.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:49:47","level":"success","message":"Usuario enviado a API","context":{"usuario":"qweqweqweqw","empresa":"wqqwdwqe","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:52:02","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada"]}}
|
||||
{"timestamp":"2025-10-28 14:52:04","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwdqw","empresa":"qwdqwd","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:54:45","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:54:45","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\phpFCE1.tmp","exists":true,"readable":true,"size":181622,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:54:47","level":"success","message":"Usuario enviado a API","context":{"usuario":"1231","empresa":"Demo123","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 14:59:41","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 14:59:41","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php8326.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 14:59:44","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwd","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 15:00:59","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada"]}}
|
||||
{"timestamp":"2025-10-28 15:01:02","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwqwqwq","empresa":"qwq","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 15:01:41","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 15:01:41","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php5842.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 15:01:44","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwdqwd","empresa":"qwd","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 15:03:06","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada"]}}
|
||||
{"timestamp":"2025-10-28 15:03:09","level":"success","message":"Usuario enviado a API","context":{"usuario":"wdwqd","empresa":"DEMO1","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 15:10:34","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","colorBrand","logo","logo_name","logo_type"]}}
|
||||
{"timestamp":"2025-10-28 15:10:34","level":"debug","message":"Estado logo antes de cURL","context":{"tmp_name":"C:\\Windows\\Temp\\php78B7.tmp","exists":true,"readable":true,"size":1373518,"error":0}}
|
||||
{"timestamp":"2025-10-28 15:10:37","level":"success","message":"Usuario enviado a API","context":{"usuario":"qwsqws","empresa":"awqsws","ip":"127.0.0.1"}}
|
||||
{"timestamp":"2025-10-28 15:11:52","level":"debug","message":"Preparando campos para enviar a API","context":{"url":"http:\/\/127.0.0.1:8000\/api\/regUsuario","post_keys":["empresa","usuario","email","platf_pago","clavePublica","clavePrivada","colorBrand"]}}
|
||||
{"timestamp":"2025-10-28 15:11:54","level":"success","message":"Usuario enviado a API","context":{"usuario":"wdqdqw","empresa":"Demo","ip":"127.0.0.1"}}
|
||||
|
||||
@@ -23,7 +23,7 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
|
||||
// Configuración de la API Laravel
|
||||
$API_CONFIG = [
|
||||
'base_url' => $ruta.'/stripe', // Cambiar por tu URL de Laravel
|
||||
'base_url' => $ruta.'/api', // Cambiar por tu URL de Laravel
|
||||
'endpoint' => '/regUsuario', // Tu endpoint de Laravel
|
||||
'timeout' => 30, // Timeout en segundos
|
||||
'auth_token' => '', // Token de autenticación si es necesario
|
||||
@@ -78,7 +78,7 @@ try {
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Error interno del servidor. Por favor intente nuevamente.'
|
||||
'message' => 'Error interno del servidor. Por favor intente nuevamente.'.$e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,8 @@ function validateAndProcessForm() {
|
||||
'usuario' => 'Nombre de Usuario',
|
||||
'email' => 'Correo Electrónico',
|
||||
'clavePublica' => 'Clave Pública',
|
||||
'clavePrivada' => 'Clave Privada'
|
||||
'clavePrivada' => 'Clave Privada',
|
||||
'colorValue' => 'Color de Branding'
|
||||
];
|
||||
|
||||
// Validar campos requeridos
|
||||
@@ -133,10 +134,15 @@ function validateAndProcessForm() {
|
||||
'email' => strtolower(trim($_POST['email'])),
|
||||
'platf_pago' => !empty($_POST['platf_pago']) ? $_POST['platf_pago'] : 'stripe',
|
||||
'clavePublica' => formatKey($_POST['clavePublica']),
|
||||
'clavePrivada' => formatKey($_POST['clavePrivada'])
|
||||
'clavePrivada' => formatKey($_POST['clavePrivada']),
|
||||
'colorBrand' => formatKey($_POST['colorValue']),
|
||||
];
|
||||
|
||||
|
||||
|
||||
// Procesar logo si se envió
|
||||
if (isset($_FILES['logo']) && isset($_FILES['logo']['error']) && $_FILES['logo']['error'] !== UPLOAD_ERR_NO_FILE) {
|
||||
// processLogo validará el archivo y devolverá la info necesaria
|
||||
$formData['logo'] = processLogo($_FILES['logo']);
|
||||
}
|
||||
|
||||
return $formData;
|
||||
}
|
||||
@@ -149,15 +155,43 @@ function sendToLaravelAPI($formData, $config) {
|
||||
|
||||
// Inicializar cURL
|
||||
$ch = curl_init();
|
||||
|
||||
// Preparar datos para envío
|
||||
$postData = [];
|
||||
|
||||
// Preparar campos para envío multipart/form-data
|
||||
$postFields = [];
|
||||
foreach ($formData as $key => $value) {
|
||||
if ($key === 'logo' && is_array($value) && isset($value['tmp_name'])) {
|
||||
// Verificar que el archivo existe y es legible
|
||||
if (!is_readable($value['tmp_name'])) {
|
||||
throw new Exception('No se puede leer el archivo de logo');
|
||||
}
|
||||
// Crear CURLFile para enviar el archivo
|
||||
$postFields['logo'] = new CURLFile(
|
||||
$value['tmp_name'],
|
||||
$value['type'],
|
||||
$value['name']
|
||||
);
|
||||
// Agregar información adicional del archivo
|
||||
$postFields['logo_name'] = $value['name'];
|
||||
$postFields['logo_type'] = $value['type'];
|
||||
} else {
|
||||
$postFields[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Cabeceras - NO establecer 'Content-Type: multipart/form-data' manualmente
|
||||
// cURL añadirá la cabecera Content-Type con el boundary correcto cuando se use CURLFile
|
||||
$headers = [
|
||||
'Accept: application/json',
|
||||
'X-Requested-With: XMLHttpRequest'
|
||||
];
|
||||
if (!empty($config['auth_token'])) {
|
||||
$headers[] = 'Authorization: Bearer ' . $config['auth_token'];
|
||||
}
|
||||
|
||||
// Configurar cURL
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $formData,
|
||||
CURLOPT_POSTFIELDS => $postFields,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => $config['timeout'],
|
||||
CURLOPT_CONNECTTIMEOUT => 10,
|
||||
@@ -165,20 +199,24 @@ function sendToLaravelAPI($formData, $config) {
|
||||
CURLOPT_MAXREDIRS => 3,
|
||||
CURLOPT_SSL_VERIFYPEER => false, // Solo para desarrollo
|
||||
CURLOPT_USERAGENT => 'PHP-FormProcessor/1.0',
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Accept: application/json',
|
||||
'X-Requested-With: XMLHttpRequest'
|
||||
]
|
||||
CURLOPT_HTTPHEADER => $headers
|
||||
]);
|
||||
|
||||
// Agregar token de autenticación si existe
|
||||
if (!empty($config['auth_token'])) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge(
|
||||
curl_getopt($ch, CURLOPT_HTTPHEADER),
|
||||
['Authorization: Bearer ' . $config['auth_token']]
|
||||
));
|
||||
// Log de depuración: claves y estado del archivo (no logeamos contenido binario)
|
||||
logActivity('debug', 'Preparando campos para enviar a API', [
|
||||
'url' => $url,
|
||||
'post_keys' => array_keys($postFields)
|
||||
]);
|
||||
if (isset($postFields['logo']) && isset($formData['logo'])) {
|
||||
$tmp = $formData['logo']['tmp_name'] ?? null;
|
||||
logActivity('debug', 'Estado logo antes de cURL', [
|
||||
'tmp_name' => $tmp,
|
||||
'exists' => $tmp ? file_exists($tmp) : false,
|
||||
'readable' => $tmp ? is_readable($tmp) : false,
|
||||
'size' => $formData['logo']['size'] ?? null,
|
||||
'error' => $formData['logo']['error'] ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// Ejecutar petición
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
@@ -191,6 +229,8 @@ function sendToLaravelAPI($formData, $config) {
|
||||
throw new Exception("Error de conexión con la API: $error");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Decodificar respuesta JSON
|
||||
$decodedResponse = json_decode($response, true);
|
||||
|
||||
@@ -259,11 +299,22 @@ function processLogo($logoFile) {
|
||||
throw new ValidationException(['logo' => ['El logo no puede ser mayor a 2MB']]);
|
||||
}
|
||||
|
||||
// Verificar que el archivo se subió correctamente
|
||||
if (!is_uploaded_file($logoFile['tmp_name'])) {
|
||||
throw new ValidationException(['logo' => ['Error al subir el archivo']]);
|
||||
}
|
||||
|
||||
// Verificar que podemos leer el archivo
|
||||
if (!is_readable($logoFile['tmp_name'])) {
|
||||
throw new ValidationException(['logo' => ['No se puede leer el archivo subido']]);
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $logoFile['name'],
|
||||
'type' => $logoFile['type'],
|
||||
'tmp_name' => $logoFile['tmp_name'],
|
||||
'size' => $logoFile['size']
|
||||
'size' => $logoFile['size'],
|
||||
'error' => $logoFile['error']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
include "header.php";
|
||||
include __DIR__ . "/php/funciones.php";
|
||||
//include "header.php";
|
||||
//include __DIR__ . "/php/funciones.php";
|
||||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http";
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
|
||||
|
||||
109
regUsuario.php
109
regUsuario.php
@@ -143,6 +143,29 @@ function obtenerNombreCursoPorId($cursos, $idBuscado) {
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.form-input.color-group {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.form-input.color-group input[type="color"] {
|
||||
width: 50px;
|
||||
height: 40px;
|
||||
padding: 0;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.form-input.color-group input[type="text"] {
|
||||
flex: 1;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
padding: 0.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.form-input:focus {
|
||||
outline: none;
|
||||
border-color: #4c51bf;
|
||||
@@ -226,6 +249,31 @@ function obtenerNombreCursoPorId($cursos, $idBuscado) {
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
}
|
||||
.color-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 6px;
|
||||
padding: 5px;
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
.color-input input[type="color"] {
|
||||
border: none;
|
||||
background: none;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
padding: 0;
|
||||
margin-right: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.color-input input[type="text"] {
|
||||
border: none;
|
||||
outline: none;
|
||||
width: 100%;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
@@ -276,6 +324,24 @@ function obtenerNombreCursoPorId($cursos, $idBuscado) {
|
||||
placeholder="-----BEGIN PRIVATE KEY----- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC... -----END PRIVATE KEY-----"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="logo" class="form-label">Logo (opcional) — JPG, PNG o SVG, max 2MB</label>
|
||||
<div class="file-input-wrapper">
|
||||
<input type="file" id="logo" name="logo" accept="image/png,image/jpeg,image/jpg,image/svg+xml" class="file-input">
|
||||
<label for="logo" id="logoLabel" class="file-input-label">Seleccione un archivo</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="brand" class="form-label">Selecciona el color del branding <small>(ocupa el selector de color)</small></label>
|
||||
|
||||
<div class="form-input color-group">
|
||||
<input type="color" id="colorPicker" value="#0072ff">
|
||||
<input type="text" id="colorValue" name="colorValue" value="#0072ff">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="submit-btn">
|
||||
✨ Registrar Usuario
|
||||
</button>
|
||||
@@ -285,6 +351,20 @@ function obtenerNombreCursoPorId($cursos, $idBuscado) {
|
||||
<!--end::App Main-->
|
||||
<div id="toast" class="toast"></div>
|
||||
</main>
|
||||
<script>
|
||||
const picker = document.getElementById('colorPicker');
|
||||
const value = document.getElementById('colorValue');
|
||||
|
||||
picker.addEventListener('input', () => {
|
||||
value.value = picker.value;
|
||||
});
|
||||
|
||||
value.addEventListener('input', () => {
|
||||
if (/^#[0-9A-Fa-f]{6}$/.test(value.value)) {
|
||||
picker.value = value.value;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// ============================================================================
|
||||
// JAVASCRIPT PARA ENVÍO DE FORMULARIO A ARCHIVO PHP
|
||||
@@ -412,6 +492,19 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
const clavePublica = formData.get('clavePublica');
|
||||
const clavePrivada = formData.get('clavePrivada');
|
||||
|
||||
// Validación de logo (opcional)
|
||||
const logo = formData.get('logo');
|
||||
if (logo && typeof logo === 'object' && logo.size && logo.name) {
|
||||
const allowedTypes = ['image/jpeg', 'image/png', 'image/jpg', 'image/svg+xml'];
|
||||
const maxSize = 2 * 1024 * 1024; // 2MB
|
||||
if (!allowedTypes.includes(logo.type)) {
|
||||
errors.push('El logo debe ser un archivo JPG, PNG o SVG');
|
||||
}
|
||||
if (logo.size > maxSize) {
|
||||
errors.push('El logo no puede ser mayor a 2MB');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Mostrar errores si los hay
|
||||
if (errors.length > 0) {
|
||||
@@ -422,6 +515,22 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Mostrar nombre de archivo seleccionado y cambiar estilo
|
||||
const logoInput = document.getElementById('logo');
|
||||
const logoLabel = document.getElementById('logoLabel');
|
||||
if (logoInput) {
|
||||
logoInput.addEventListener('change', (e) => {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
logoLabel.textContent = `${file.name} (${Math.round(file.size/1024)} KB)`;
|
||||
logoLabel.classList.add('has-file');
|
||||
} else {
|
||||
logoLabel.textContent = 'Seleccione un archivo';
|
||||
logoLabel.classList.remove('has-file');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Manejar respuesta exitosa
|
||||
*/
|
||||
|
||||
@@ -55,4 +55,4 @@ $cfdi_xml_path = $env_vars['CFDI_XML_FILE_URL'] ?? '';
|
||||
|
||||
$ruta = $api_url;
|
||||
|
||||
$loginUser = "$ruta/stripe/accessUser";
|
||||
$loginUser = "$ruta/api/accessUserStripe";
|
||||
|
||||
@@ -14,7 +14,7 @@ function obtenerNombreCursoPorId($cursos, $idBuscado) {
|
||||
}
|
||||
|
||||
|
||||
$url = $ruta.'/stripe/verUsuarios';
|
||||
$url = $ruta.'/api/verUsuarios';
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user