Validar un cupón
curl --request POST \
--url https://app.fooddelivery.cl/api/v1/coupons/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"location_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subtotal": 1,
"items": [
{
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 1,
"unit_price": 1
}
],
"shipping_fee": 1,
"customer_phone": "<string>"
}
'import requests
url = "https://app.fooddelivery.cl/api/v1/coupons/validate"
payload = {
"code": "<string>",
"location_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subtotal": 1,
"items": [
{
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 1,
"unit_price": 1
}
],
"shipping_fee": 1,
"customer_phone": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
location_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
subtotal: 1,
items: [
{product_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', quantity: 1, unit_price: 1}
],
shipping_fee: 1,
customer_phone: '<string>'
})
};
fetch('https://app.fooddelivery.cl/api/v1/coupons/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.fooddelivery.cl/api/v1/coupons/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'location_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'subtotal' => 1,
'items' => [
[
'product_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 1,
'unit_price' => 1
]
],
'shipping_fee' => 1,
'customer_phone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.fooddelivery.cl/api/v1/coupons/validate"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.fooddelivery.cl/api/v1/coupons/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.fooddelivery.cl/api/v1/coupons/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"valid": true,
"code": "<string>",
"discount_type": "percentage",
"discount_amount": 123,
"message": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}Pedidos
Validar un cupón
Vista previa para el checkout: dice si el cupón vale para este carrito y cuánto descuenta. No registra ningún canje. El monto que se cobra lo recalcula POST /orders con coupon_code. Un cupón que no vale responde 200 con valid: false y el motivo en message, que se puede mostrar al cliente. Sin customer_phone no se revisa el tope por cliente (se revisa al crear el pedido).
POST
/
coupons
/
validate
Validar un cupón
curl --request POST \
--url https://app.fooddelivery.cl/api/v1/coupons/validate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"location_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subtotal": 1,
"items": [
{
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 1,
"unit_price": 1
}
],
"shipping_fee": 1,
"customer_phone": "<string>"
}
'import requests
url = "https://app.fooddelivery.cl/api/v1/coupons/validate"
payload = {
"code": "<string>",
"location_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subtotal": 1,
"items": [
{
"product_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": 1,
"unit_price": 1
}
],
"shipping_fee": 1,
"customer_phone": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
location_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
subtotal: 1,
items: [
{product_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a', quantity: 1, unit_price: 1}
],
shipping_fee: 1,
customer_phone: '<string>'
})
};
fetch('https://app.fooddelivery.cl/api/v1/coupons/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.fooddelivery.cl/api/v1/coupons/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'location_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'subtotal' => 1,
'items' => [
[
'product_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'quantity' => 1,
'unit_price' => 1
]
],
'shipping_fee' => 1,
'customer_phone' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.fooddelivery.cl/api/v1/coupons/validate"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.fooddelivery.cl/api/v1/coupons/validate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.fooddelivery.cl/api/v1/coupons/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"location_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"subtotal\": 1,\n \"items\": [\n {\n \"product_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"quantity\": 1,\n \"unit_price\": 1\n }\n ],\n \"shipping_fee\": 1,\n \"customer_phone\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"valid": true,
"code": "<string>",
"discount_type": "percentage",
"discount_amount": 123,
"message": "<string>"
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}{
"error": {
"code": "invalid_request",
"message": "<string>"
}
}Authorizations
Body
application/json
