How to check deliverability before payment and reject orders for postcodes outside your active delivery zones.
Call the API when the customer enters their delivery address. If canDeliver is false, disable the submit button and display the reason code.
// Server-side only — never expose your API key in browser code
async function checkDelivery(postcode, basketValueCents) {
const res = await fetch("https://api.deliveryzone.fi/api/v1/delivery/check", {
method: "POST",
headers: {
"X-Api-Key": process.env.DZ_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ destinationPostcode: postcode, basketValueCents }),
});
return res.json();
}