Walidacja kodu rabatowego dla koszyka
curl --request POST \
--url https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate \
--header 'Content-Type: application/json' \
--data '
{
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
'import requests
url = "https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload = {
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'LATO10',
items: [
{
productId: '664f1a2b3c4d5e6f7a8b9c0d',
quantity: 1,
variantId: '664f1a2b3c4d5e6f7a8b9c11',
variant: '30 dni'
}
],
paymentMethodCode: 'imoje'
})
};
fetch('https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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' => 'LATO10',
'items' => [
[
'productId' => '664f1a2b3c4d5e6f7a8b9c0d',
'quantity' => 1,
'variantId' => '664f1a2b3c4d5e6f7a8b9c11',
'variant' => '30 dni'
]
],
'paymentMethodCode' => 'imoje'
]),
CURLOPT_HTTPHEADER => [
"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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload := strings.NewReader("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"valid": true,
"code": "LATO10",
"reason": null,
"subtotal": 39.98,
"discountAmount": 4,
"total": 35.98,
"currency": "PLN",
"lines": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"subtotal": 19.99,
"discountShare": 2,
"total": 17.99
}
]
}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}Storefront v1
Walidacja kodu rabatowego dla koszyka
Wycena serwerowa tą samą funkcją co kasa (cena wariantu/metody → rabat → VAT). Dla kilku pozycji rabat liczy się raz na koszyk i rozkłada proporcjonalnie na pozycje objęte kodem (lines[].discountShare, suma do grosza). Niepoprawny kod to valid: false, nie błąd. Nie rezerwuje użycia kodu.
POST
/
api
/
v2
/
storefront
/
v1
/
shops
/
{shopId}
/
discounts
/
validate
Walidacja kodu rabatowego dla koszyka
curl --request POST \
--url https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate \
--header 'Content-Type: application/json' \
--data '
{
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
'import requests
url = "https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload = {
"code": "LATO10",
"items": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"quantity": 1,
"variantId": "664f1a2b3c4d5e6f7a8b9c11",
"variant": "30 dni"
}
],
"paymentMethodCode": "imoje"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
code: 'LATO10',
items: [
{
productId: '664f1a2b3c4d5e6f7a8b9c0d',
quantity: 1,
variantId: '664f1a2b3c4d5e6f7a8b9c11',
variant: '30 dni'
}
],
paymentMethodCode: 'imoje'
})
};
fetch('https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/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' => 'LATO10',
'items' => [
[
'productId' => '664f1a2b3c4d5e6f7a8b9c0d',
'quantity' => 1,
'variantId' => '664f1a2b3c4d5e6f7a8b9c11',
'variant' => '30 dni'
]
],
'paymentMethodCode' => 'imoje'
]),
CURLOPT_HTTPHEADER => [
"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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate"
payload := strings.NewReader("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://itemshop.dev/api/v2/storefront/v1/shops/{shopId}/discounts/validate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"LATO10\",\n \"items\": [\n {\n \"productId\": \"664f1a2b3c4d5e6f7a8b9c0d\",\n \"quantity\": 1,\n \"variantId\": \"664f1a2b3c4d5e6f7a8b9c11\",\n \"variant\": \"30 dni\"\n }\n ],\n \"paymentMethodCode\": \"imoje\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"valid": true,
"code": "LATO10",
"reason": null,
"subtotal": 39.98,
"discountAmount": 4,
"total": 35.98,
"currency": "PLN",
"lines": [
{
"productId": "664f1a2b3c4d5e6f7a8b9c0d",
"subtotal": 19.99,
"discountShare": 2,
"total": 17.99
}
]
}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}{
"success": false,
"statusCode": 404,
"code": "SHOP_NOT_FOUND",
"message": "Shop not found",
"error": "Shop not found",
"timestamp": "2026-10-27T12:00:00.000Z",
"path": "/api/v2/storefront/v1/shops/moj-sklep",
"details": {}
}Parametry ścieżki
ID sklepu (ObjectId). Przyjmuje też uniqueName, aktywną własną domenę albo <uniqueName>.<domena hostingu>.
Przykład:
"664f1a2b3c4d5e6f7a8b9c0d"
Treść
application/json
Required string length:
1 - 50Pattern:
^[A-Za-z0-9_-]+$Przykład:
"LATO10"
Pozycje koszyka (1–20). Kilka pozycji = grupa płatności: jedno zamówienie na pozycję i jedna płatność na sumę (adr/0002)
Required array length:
1 - 20 elementsShow child attributes
Show child attributes
Metoda płatności — produkt może mieć dla niej inną cenę
Required string length:
1 - 100Przykład:
"imoje"
Czy ta strona była pomocna?
⌘I