Apply voucher
curl --request POST \
--url https://b.anny.co/api/v1/order/voucher \
--header 'Content-Type: application/vnd.api+json' \
--data '
{
"voucher_code": "20OFF"
}
'import requests
url = "https://b.anny.co/api/v1/order/voucher"
payload = { "voucher_code": "20OFF" }
headers = {"Content-Type": "application/vnd.api+json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/vnd.api+json'},
body: JSON.stringify({voucher_code: '20OFF'})
};
fetch('https://b.anny.co/api/v1/order/voucher', 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://b.anny.co/api/v1/order/voucher",
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([
'voucher_code' => '20OFF'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/vnd.api+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://b.anny.co/api/v1/order/voucher"
payload := strings.NewReader("{\n \"voucher_code\": \"20OFF\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/vnd.api+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://b.anny.co/api/v1/order/voucher")
.header("Content-Type", "application/vnd.api+json")
.body("{\n \"voucher_code\": \"20OFF\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://b.anny.co/api/v1/order/voucher")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n \"voucher_code\": \"20OFF\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "orders",
"id": "2013266",
"attributes": {
"number": "BO95786261",
"currency": "EUR",
"total": 277,
"net_amount": 232.77,
"tax_amount": 44.23,
"discount_amount": 0,
"status": "draft",
"access_token": "e04NrT789XmaGvYopaflM5Kp1byLt0",
"expires_at": "2021-09-24T14:48:51+00:00",
"created_at": "2021-09-24T14:33:51+00:00",
"updated_at": "2021-09-24T14:34:08+00:00"
},
"relationships": {
"bookings": {
"data": [
{
"type": "bookings",
"id": "3718347"
}
]
},
"customer": {
"data": null
},
"sub_orders": {
"data": [
{
"type": "orders",
"id": "2013267"
}
]
}
},
"links": {
"self": "https://b.anny.co/api/v1/orders/2013266"
},
"meta": {
"download_url": "https://b.anny.co/downloads/order-confirmation/2013266?access_token=e04NrT789XmaGvYopaflM5Kp1byLt0",
"voucher_code": "20OFF",
"is_base_order": true,
"payment_flow": "pay-offline",
"pay_now_amount": 0
}
}
}{
"errors": [
{
"status": "404",
"code": "voucher_not_found",
"title": "Gutschein nicht gefunden",
"detail": "Der Gutschein konnte nicht gefunden werden"
}
]
}Orders & Checkout
Apply voucher
This endpoint allows to apply a voucher code to an order. The server side will validate this voucher and return error messages if needed.
POST
/
api
/
v1
/
order
/
voucher
Apply voucher
curl --request POST \
--url https://b.anny.co/api/v1/order/voucher \
--header 'Content-Type: application/vnd.api+json' \
--data '
{
"voucher_code": "20OFF"
}
'import requests
url = "https://b.anny.co/api/v1/order/voucher"
payload = { "voucher_code": "20OFF" }
headers = {"Content-Type": "application/vnd.api+json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/vnd.api+json'},
body: JSON.stringify({voucher_code: '20OFF'})
};
fetch('https://b.anny.co/api/v1/order/voucher', 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://b.anny.co/api/v1/order/voucher",
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([
'voucher_code' => '20OFF'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/vnd.api+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://b.anny.co/api/v1/order/voucher"
payload := strings.NewReader("{\n \"voucher_code\": \"20OFF\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/vnd.api+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://b.anny.co/api/v1/order/voucher")
.header("Content-Type", "application/vnd.api+json")
.body("{\n \"voucher_code\": \"20OFF\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://b.anny.co/api/v1/order/voucher")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/vnd.api+json'
request.body = "{\n \"voucher_code\": \"20OFF\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"type": "orders",
"id": "2013266",
"attributes": {
"number": "BO95786261",
"currency": "EUR",
"total": 277,
"net_amount": 232.77,
"tax_amount": 44.23,
"discount_amount": 0,
"status": "draft",
"access_token": "e04NrT789XmaGvYopaflM5Kp1byLt0",
"expires_at": "2021-09-24T14:48:51+00:00",
"created_at": "2021-09-24T14:33:51+00:00",
"updated_at": "2021-09-24T14:34:08+00:00"
},
"relationships": {
"bookings": {
"data": [
{
"type": "bookings",
"id": "3718347"
}
]
},
"customer": {
"data": null
},
"sub_orders": {
"data": [
{
"type": "orders",
"id": "2013267"
}
]
}
},
"links": {
"self": "https://b.anny.co/api/v1/orders/2013266"
},
"meta": {
"download_url": "https://b.anny.co/downloads/order-confirmation/2013266?access_token=e04NrT789XmaGvYopaflM5Kp1byLt0",
"voucher_code": "20OFF",
"is_base_order": true,
"payment_flow": "pay-offline",
"pay_now_amount": 0
}
}
}{
"errors": [
{
"status": "404",
"code": "voucher_not_found",
"title": "Gutschein nicht gefunden",
"detail": "Der Gutschein konnte nicht gefunden werden"
}
]
}⌘I