🛠️Guía de Integración: API Users
🧩API Users/{id payphone}/region/{código país}
Este método te permite consultar la información de un usuario registrado en Payphone Personal. Para utilizar el método Users, debes realizar una solicitud GET a la siguiente URL:
URL de la solicitud GET:
https://pay.payphonetodoesposible.com/api/Users/0984112233/region/593
- {id Payphone Personal}: El número de teléfono del usuario catalogado como id de Payphone Personal (debe incluir el cero inicial, ejemplo: 0984112233).
- {código País}: El código del país correspondiente al número de teléfono (por ejemplo, para Ecuador, el código sería
593
).
🔐Cabeceras Requeridas
Se debe incluir las siguientes cabeceras HTTP:
Authorization: bearer TU_TOKEN
(Token de autenticación de la aplicación, precedido por la palabra "Bearer". )Content-type: application/json
(Formato de los datos: JSON).
📬Respuesta a la solicitud GET
- ✅Respuesta exitosa: Si el número de teléfono está registrado en Payphone, la respuesta será un JSON con la información del usuario de Payphone
{
"documentId": "1234567890",
"name": "ELISABETH",
"lastName": "SOBECK",
"email": "aloy@mail.com",
"phoneNumbers": [
"********1333"
]
}
- ❌Respuesta fallida: Si el número de teléfono NO está registrado en Payphone, la respuesta será un JSON con el mensaje "Lo sentimos, este número no está registrado en Payphone"
{
"message": "Lo sentimos, este número no está registrado en Payphone",
"errorCode": 120
}
🧱 Ejemplos de solicitudes GET para API Users
A continuación, se presenta varios ejemplos de cómo realizar solicitudes GET:
<?php
//Funcion q ejecuta una solicitud http GET
function curlGet($urlAPI, $headers) {
//Iniciar solicitud curl: GET
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $urlAPI);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
//Respuesta en formato JSON
$curl_response = curl_exec($curl);
//Finaliza solicitud curl: GET
curl_close($curl);
return json_decode($curl_response);
}
/*## Preparar informacion del usuario Payphone ##*/
$phoneNumber = "0984111333";//ID Payphone Personal.
$countryCode = "593";//Código de país.
$token="your_token_API";
$url="https://pay.payphonetodoesposible.com/api/Users/".$phoneNumber."/region/".$countryCode;
//Preparar cabecera para la solicitud
$headers[] = 'Authorization: Bearer '.$token ;//CREDENCIALES DE CONFIGURACION
$headers[] = 'Content-Type: application/json' ;//TIPO DE APLICACION
//realizar solicitud http GET
$result=curlGet($url, $headers);
//Mostrar Resultado en Pantalla
echo "<h1>Usuario Registrado</h1>";
echo "<a>Usuario Payphone:<strong>".$phoneNumber."<strong></a><br>";
echo "Respuesta : <pre>".json_encode($result,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT )."</pre>";
?>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Usuario Registrado</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
<h1>Usuario Registrado</h1>
<a>Usuario Payphone: <strong id="phoneNumber"></strong></a><br>
<div id="resultado"></div>
<script>
/*## Preparar credenciales como variables para la solicitud ##*/
const token="your_token_API";
/*## Preparar informacion del usuario Payphone ##*/
const phoneNumber="0984111333"; //ID Payphone Personal.
const countryCode="593"; //Codigo Pais
$(document).ready(function() {
$.ajax({
url: "https://pay.payphonetodoesposible.com/api/Users/"+phoneNumber+"/region/"+countryCode,
type: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer "+token
},
success: function(response) {
$("#resultado").html(
"Respuesta : <pre>" + JSON.stringify(response, null, 2) + "</pre>"
);
},
error: function(error) {
$("#resultado").html(
"Error en la solicitud : <pre>" + JSON.stringify(error, null, 2) + "</pre>"
);
}
});
});
// Mostrar en pantalla datos relevantes
document.getElementById("phoneNumber").innerHTML=phoneNumber;
</script>
</body>
</html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Usuario Registrado</title>
</head>
<body>
<h1>Usuario Registrado</h1>
<a>Usuario Payphone: <strong id="phoneNumber"></strong></a><br>
<a>Respuesta: </a><br>
<script>
/*## Preparar credenciales como variables para la solicitud ##*/
const token="your_token_API";
const headers = {
"Content-Type": "application/json",
"Authorization": "Bearer "+token
};
/*## Preparar informacion del usuario Payphone ##*/
const phoneNumber="0984111333"; //ID Payphone Personal.
const countryCode="593"; //Codigo Pais
/*## Preparar informacion para la solicitud GET ##*/
//URL del servicio payphone
const url = "https://pay.payphonetodoesposible.com/api/Users/"+phoneNumber+"/region/"+countryCode;
fetch(url, {
method: "GET",
headers: headers
})
.then((res) => res.json())
.catch((error) => {
// Creamos las etiquetas <a>
const jsonResult = document.createElement("pre");
jsonResult.textContent = JSON.stringify(error, null, 2);
// Mostrar los enlaces en el documento con un salto de línea entre ellos
const container = document.createElement("div");
container.appendChild(jsonResult);
// Agregar los enlaces al body del documento o a un contenedor específico
document.body.appendChild(container);
})
.then((data) => {
// Creamos las etiquetas <a>
const jsonResult = document.createElement("pre");
jsonResult.textContent = JSON.stringify(data, null, 2);
// Mostrar los enlaces en el documento con un salto de línea entre ellos
const container = document.createElement("div");
container.appendChild(jsonResult);
// Agregar los enlaces al body del documento o a un contenedor específico
document.body.appendChild(container);
});
// Mostrar en pantalla datos relevantes
document.getElementById("phoneNumber").innerHTML=phoneNumber;
</script>
</body>
</html>