Integración avanzada
Las siguientes características son opcionales y las puedes utilizar en tus integraciones.
Para hacer un uso correcto de la API consultar base_url
en la sección Ambientes/Checkout.
Monto del envío
Al crear una orden desde el endpoint api/v2/orders, tienes la posibilidad de sumar el costo del envío y mostrarlo como un ítem dentro del detalle de elementos.
Configuración
Para configurarlo, basta con agregar el nodo shipping
con el nombre name
y el sub nodo price
con el valor del monto del envío y la moneda a utilizar.
"shipping": {
"name": "Envio por Correo Argentino",
"price": {
"currency": "032",
"amount": 601
}
}
Detalles
Field Name | Details |
---|---|
name | type="string", length=63, nullable=true |
currency | type="string", length=3, nullable=false |
amount | type="integer" |
Ejemplo
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{base_url}/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"currency": "032",
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 110000
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 120000
},
"quantity": 2
}
],
"shipping": {
"name": "Envio por Correo Argentino",
"price": {
"currency": "032",
"amount": 15000
}
}
}
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer {reemplazar_por_jwt}'
),
));
$response = curl_exec($curl);
$order = json_decode($response);
curl_close($curl);
URL de retorno
Al finalizar el proceso de pago, tienes la opción de redireccionar al comprador tanto para pagos aprobados como para pagos rechazados.
Configuración
Esta característica da la opción de sumar el nodo redirect_urls
y definir dentro un link para success
y un link para failed
.
"redirect_urls": {
"success": "https://www.mitienda.com/success",
"failed": "https://www.mitienda.com/failed"
}
Detalles
Field Name | Details |
---|---|
success | type="string", length=255, nullable=true |
failed | type="string", length=255, nullable=true |
Ejemplo
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{base_url}/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"currency": "032",
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 110000
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 120000
},
"quantity": 2
}
],
"redirect_urls": {
"success": "https://www.mitienda.com/success",
"failed": "https://www.mitienda.com/failed"
}
}
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer {reemplazar_por_jwt}'
),
));
$response = curl_exec($curl);
$order = json_decode($response);
curl_close($curl);
Webhook URL
Sirve para que al momento de finalizar un pago, notifiquemos el estado del mismo.
Configuración
Simplemente agregar la key webhookUrl
en la raíz de attributes
y colocar la URL al cual enviaremos la notificación.
"webhookUrl": "https://www.google.com/?q=soyunhook"
Detalles
Field Name | Details |
---|---|
webhookUrl | type="string", length=255, nullable=true |
Ejemplo
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{base_url}/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"currency": "032",
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 110000
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 120000
},
"quantity": 2
}
],
"redirect_urls": {
"success": "https://www.mitienda.com/success",
"failed": "https://www.mitienda.com/failed"
},
"webhookUrl": "https://webhook.com",
}
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer {reemplazar_por_jwt}'
),
));
$response = curl_exec($curl);
$order = json_decode($response);
curl_close($curl);
Ejemplo de POST al WebHook
{
"data": {
"type": "Payment",
"order": {
"uuid": "ea138a99-c9df-44a5-b2bf-09e5db6f8d0c",
"status": "SUCCESS",
"source": "app_payment_link"
},
"payment": {
"id": 1823,
"authorizationCode": "901159",
"refNumber": "62b4a8ff60fee",
"status": "APPROVED"
}
}
}
expireLimitMinutes
Establece un tiempo límite para realizar el pago. Una vez vencido dicho tiempo, el pago ya no podrá realizarse.
Configuración
Agregar la key expireLimitMinutes
en la raíz de attributes
y colocar el valor expresado en minutos.
"expireLimitMinutes": 14400
Detalles
Field Name | Details |
---|---|
expireLimitMinutes | type="integer" |
Ejemplo
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '{base_url}/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"currency": "032",
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 110000
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 120000
},
"quantity": 2
}
],
"expireLimitMinutes": 14400,
}
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer {reemplazar_por_jwt}'
),
));
$response = curl_exec($curl);
$order = json_decode($response);
curl_close($curl);