Integración avanzada
Las siguientes características son opcionales y las podés utilizar en tus integraciones.
Monto del envío
Al crear una orden desde el endpoint api/v2/orders, tenes 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 => 'https://api.viumi.com.ar/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 574
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 544
},
"quantity": 2
}
],
"shipping": {
"name": "Envio por Correo Argentino",
"price": {
"currency": "032",
"amount": 601
}
}
}
}
}',
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.
Configuracion
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 => 'https://api.viumi.com.ar/api/v2/orders',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": {
"attributes": {
"accountId": 1,
"items": [
{
"id": 1,
"name": "Chicken roll",
"unitPrice": {
"currency": "032",
"amount": 574
},
"quantity": 1
},
{
"id": 3,
"name": "Porto cheese burger",
"unitPrice": {
"currency": "032",
"amount": 544
},
"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);