Ejecuciones
10 min
Monto de la operación. Formato XXX.xx donde el PUNTO es el separador decimal.
Ejecutar Suscripción Manualmente
GET
https://api.unicobros.com.ar/p/subscriptions/{id}/subscriber/{sid}/execution
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.unicobros.com.ar/p/subscriptions/T691POMK62SGC7CHAK/subscriber/Y7B3P541B9VFBYTHSZ/execution',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'x-api-key: zJ8LFTBX6Ba8D611e9io13fDZAwj0QmKO1Hn1yIj',
'x-access-token: d31f0721-2f85-44e7-bcc6-15e19d1a53cc'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Ejecutar Suscripción Manualmente con Monto Diferenciado
El monto con el que se ejecuta la suscripción puede ser diferente al definido en la suscripción o el suscriptor.
POST
https://api.unicobros.com.ar/p/subscriptions/{id}/subscriber/{sid}/execution
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.unicobros.com.ar/p/subscriptions/R89BLVMZRPDH3GMRH9/subscriber/Y7B3P541B9VFBYTHSZ/execution',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"total": 150,
"reference": "230320211305",
"description": "Cobro con una descripción diferente"
}',
CURLOPT_HTTPHEADER => array(
'x-api-key: zJ8LFTBX6Ba8D611e9io13fDZAwj0QmKO1Hn1yIj',
'x-access-token: d31f0721-2f85-44e7-bcc6-15e19d1a53cc',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Ejecutar cobros manuales masivamente
Permite ejecutar cobros masivos dentro de una misma suscripción. Tenga en cuenta que esta API solamente retornará que el proceso fue aceptado exitosamente. La ejecución se realizará de fondo y se notificará via Webhooks.
POST
https://api.unicobros.com.ar/p/subscriptions/{id}/action/execute
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.unicobros.com.ar/p/subscriptions/R89BLVMZRPDH3GMRH9/action/execute',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'[
{
"sid": "Y7B3P541B9VFBYTHSZ",
"total": 10,
"reference": "230320211348"
}
]',
CURLOPT_HTTPHEADER => array(
'x-api-key: zJ8LFTBX6Ba8D611e9io13fDZAwj0QmKO1Hn1yIj',
'x-access-token: d31f0721-2f85-44e7-bcc6-15e19d1a53cc',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Programar una ejecución a futuro
POST
https://api.unicobros.com.ar/p/subscriptions/{id}/subscriber/{sid}/action/schedule
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.unicobros.com.ar/p/subscriptions/u5485JkgTy/subscriber/5sfTy4iPlT/action/schedule',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"date": {
"day": 10,
"month": 4,
"year": 2021
}
}',
CURLOPT_HTTPHEADER => array(
'x-api-key: zJ8LFTBX6Ba8D611e9io13fDZAwj0QmKO1Hn1yIj',
'x-access-token: d31f0721-2f85-44e7-bcc6-15e19d1a53cc',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Acciones sobre una ejecución
Reintentar una Ejecución
GET
https://api.unicobros.com.ar/p/subscriptions/{id}/subscriber/{sid}/execution/{eid}/action/retry
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.unicobros.com.ar/p/subscriptions/R89BLVMZRPDH3GMRH9/subscriber/Y7B3P541B9VFBYTHSZ/execution/JS73P5HG8AVFBYT45Z/action/retry',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"date": {
"day": 28,
"month": 5,
"year": 2021
}
}',
CURLOPT_HTTPHEADER => array(
'x-api-key: zJ8LFTBX6Ba8D611e9io13fDZAwj0QmKO1Hn1yIj',
'x-access-token: d31f0721-2f85-44e7-bcc6-15e19d1a53cc',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Marcar una ejecución como Paga
GET
https://api.unicobros.com.ar/p/subscriptions/{id}/subscriber/{sid}/execution/{eid}/action/paid
fetch("https://api.cakes.com", {
"method": "GET",
"headers": {
"Accept": "application/json"
}
})
.then(response => {
console.log(response);
})
.catch(err => {
console.error(err);
});WebHooks
Los webhooks siempre serán enviados en formato application/x-www-form-urlencoded
Nueva Suscripción
{
"type": "subscription:registration",
"data": {
"result": true,
"view": {
"type": "card"
},
"payment": {
"id": "ABABBB78798",
"description": "Esto es un registro!",
"operation": {
"type": "validation"
},
"status": {
"code": "200",
"text": "Aprobado",
"message": "Transacción Aprobada"
},
"total": 14.3,
"currency": {
"code": "ARS",
"text": "Peso Argentino",
"symbol": "$"
},
"riskAnalysis": {
"band": "N/A",
"level": "N/A"
},
"created": "2020-12-02T18:12:11.122Z",
"updated": "2020-12-02T18:12:12.768Z",
"reference": "extenal_reference",
"source": {
"name": "Visa Débito",
"type": "card",
"reference": "visa.debit",
"number": "4515 00** **** 1234",
"expiration": {
"month": "01",
"year": "26"
},
"installment": {
"description": "Débito",
"amount": 14.3,
"count": 1,
"reference": "1"
}
}
},
"entity": {
"name": "Demo Entity",
"uid": "demo_entity"
},
"customer": {
"uid": "12123123",
"name": "Juan Perez Wayne",
"phone": "12123123",
"identification": "110303456",
"email": "[email protected]"
},
"user": {
"name": "Juan Perez Wayne",
"email": "[email protected]"
},
"source": {
"name": "Visa Débito",
"type": "card",
"reference": "visa.debit"
},
"subscription": {
"uid": "DRXR14KIUC4V8TFBRL",
"interval": "1m",
"limit": 4,
"name": "El nombre de mi suscripción",
"description": "Esto es GENIAL",
"reference": "external_reference",
"total": 1595
},
"subscriber": {
"uid": "RLY80US2JZ8ZHTSCPH",
"reference": "3447",
"customer": {
"identification": "12123123",
"email": "[email protected]",
"name": "Juan Perez Wayne"
}
},
"context": {
"status": "success"
},
"execution": {}
}
}Cambio de Método de Pago
{
"type": "subscription:change_source",
"data": {
"result": true,
"view": {
"type": "card"
},
"payment": {
"id": "ABC123123",
"description": "Validación de Tarjeta.",
"operation": {
"type": "validation"
},
"status": {
"code": "410",
"text": "Denegada, Fondos insuficientes",
"message": "Denegada, fondos insuficientes. (Cod. 51)"
},
"total": 17.15,
"currency": {
"code": "ARS",
"text": "Peso Argentino",
"symbol": "$"
},
"riskAnalysis": {
"band": "N/A",
"level": "N/A"
},
"created": "2020-12-02T11:31:56.544Z",
"updated": "2020-12-02T11:31:58.243Z",
"reference": "external_reference",
"source": {
"name": "Visa",
"type": "card",
"reference": "visa",
"number": "4515 00** **** 1234",
"expiration": {
"month": "01",
"year": "24"
},
"installment": {
"description": "1 Cuota",
"amount": 17.15,
"count": 1,
"reference": "1"
}
}
},
"entity": {
"name": "Demo Entity",
"uid": "demo_entity"
},
"customer": {
"uid": "12123123",
"name": "Juan Perez Wayne",
"phone": "12123123",
"identification": "110303456",
"email": "[email protected]"
},
"user": {
"name": "Juan Perez Wayne",
"email": "[email protected]"
},
"source": {
"name": "Visa",
"type": "card",
"reference": "visa"
},
"subscription": {
"uid": "4546465465465",
"interval": "1m",
"limit": 0,
"name": "Mi Suscripción",
"description": "Débitos automáticos? Todavía existe eso?",
"reference": "external_reference",
"total": 8000.14
},
"subscriber": {
"uid": "Fvon4enAv5",
"reference": "5defe0af-e9be-4288-bed1-423a5cc41920",
"customer": {
"email": "[email protected]",
"name": "Juan Perez Wayne",
"identification": "12123123",
"phone": "1112341234"
}
},
"context": {
"status": "success"
},
"execution": {}
}
}
}Suscripción Ejecutada
El servicio para este Webhook utiliza los webhooks estandares descriptos en la sección Webhooks de esta documentación agregando los nodos "subscription" y "subscriber"
{
"type": "subscription:execution",
"data": {
"result": true,
"view": {
"type": "card"
},
"payment": {
"id": "ABC121232",
"description": "Cobro Ejecutado",
"operation": {
"type": "payment.v2"
},
"status": {
"code": "410",
"text": "Denegada, Fondos insuficientes",
"message": "Denegada, fondos insuficientes. (Cod. 51)"
},
"total": 1533.11,
"currency": {
"code": "ARS",
"text": "Peso Argentino",
"symbol": "$"
},
"riskAnalysis": {
"band": "N/A",
"level": "N/A"
},
"created": "2020-12-02T01:00:55.994Z",
"updated": "2020-12-02T01:00:57.091Z",
"reference": "external_reference",
"source": {
"name": "Visa Débito",
"type": "card",
"reference": "visa.debit",
"number": "4515 00** **** 1234",
"expiration": {
"month": "02",
"year": "26"
},
"installment": {
"description": "Débito",
"amount": 1546.55,
"count": 1,
"reference": "1"
}
}
},
"entity": {
"name": "Demo Entity",
"uid": "demo_entity"
},
"customer": {
"uid": "12123123",
"name": "Juan Perez Wayne",
"phone": "12123123",
"identification": "110303456",
"email": "[email protected]"
},
"user": {
"name": "Juan Perez Wayne",
"email": "[email protected]"
},
"source": {
"name": "Visa Débito",
"type": "card",
"reference": "visa.debit"
},
"subscription": {
"uid": "fdSxU7RbC",
"interval": "1m",
"limit": 5,
"name": "Mi Suscripción",
"description": "Dinosaurios",
"reference": "external_reference",
"total": 1547
},
"subscriber": {
"uid": "CBA456456",
"reference": "exernal_reference",
"period": -1,
"customer": {
"identification": "123123132",
"email": "[email protected]",
"name": "Juan Perez Wayne"
}
},
"context": {
"status": "success"
},
"execution": {
"uid": "54Z45DRXEZ01QWYLUL"
}
}
}Suscriptor Suspendido
{
"type": "subscription:subscriber:suspended",
"data": {
"subscription": {
"uid": "JmfI3Ml3D",
"interval": "1m",
"limit": 0,
"name": "Nombre de la Suscripción",
"description": "Descripción de la Suscripción",
"total": 500
},
"subscriber": {
"uid": "qy82noStM",
"reference": "qy82noStM",
"customer": {
"name": "Juan Batman",
"identification": "999999",
"email": "[email protected]"
}
}
}
}Suscriptor Activado
{
"type": "subscription:subscriber:active",
"data": {
"subscription": {
"uid": "JmfI3Ml3D",
"interval": "1m",
"limit": 0,
"name": "Nombre de la Suscripción",
"description": "Descripción de la Suscripción",
"total": 500
},
"subscriber": {
"uid": "qy82noStM",
"reference": "qy82noStM",
"customer": {
"name": "Juan Batman",
"identification": "999999",
"email": "[email protected]"
}
}
}
}Redirección
Cuando el servicio redirige al suscriptor a la return_url definida al crear la suscripción, se agregan un conjunto de parámetros en la url para indicarle al sitio el resultado de la suscripción.
Los parámetros de tipo query que se agregan a la url definida son:
- reference: referencia asignada al suscriptor.
- status: estado de la transacción asociada a la operación de suscripción.
- uid: ID de la suscripción.
- sid: ID del suscriptor.
Cuando se cancela el proceso de suscripción, el status será 0.