Medienwerft Punchout — Developer Guide
How to connect a storefront to Medienwerft Punchout, so that buyers arriving from IDS-Connect, SAP OCI or cXML procurement systems can fill your cart and send it back.
Your shop never speaks any of those protocols. It receives a neutral basket, and it hands one back; the service does the rest. On your side that is two pieces of code — a page a punchout lands on, and a binding to your cart — plus a server route that exchanges a token.
Part A is framework-neutral and uses @medienwerft/punchout-client, which has no dependencies and runs in any browser and any server runtime with fetch. Part B does the same with the React components in @medienwerft/punchout-react. Read Part A first even if you use React: the components are Part A, done for you.
Packages
| Package | What it is | Runtime deps |
|---|---|---|
@medienwerft/punchout-client |
Wire types, the token exchange, session storage, the return payload. | none |
@medienwerft/punchout-react |
<PunchoutResume>, usePunchoutSession(), <PunchoutCheckout>. |
react (peer), @medienwerft/punchout-client |
Getting the SDK
The service distributes the SDK itself. /sdk lists the current release — each package's version, its tarball and the npm integrity your lockfile will record — together with ready-to-paste install commands:
# Any framework
npm install https://api.punchout.medienwerft.de/api/sdk/medienwerft-punchout-client-1.1.0.tgz
# React: both packages, in one command
npm install https://api.punchout.medienwerft.de/api/sdk/medienwerft-punchout-client-1.1.0.tgz \
https://api.punchout.medienwerft.de/api/sdk/medienwerft-punchout-react-1.1.0.tgz
Install the React package together with the client. On its own, npm looks for @medienwerft/punchout-client in the public registry, where it does not exist.
Tarball URLs are versioned and their contents never change, so a lockfile entry stays valid. To upgrade, take the new URLs from /sdk and install again. The packages follow semver: a breaking change to the public API means a new major version.
Without a bundler, /sdk also links punchout-client-<version>.js: the client as a single ES module with no imports. Download it and serve it from your own origin, for example as /vendor/punchout-client.js, which is how the plain-HTML examples in this guide import it.
The raw HTTP API is described by its OpenAPI reference at /docs. You should not need it for a storefront integration; this guide is served next to it at /guide. The User Guide for setting up connections in the dashboard is at /user-guide (PDF).
1. How a punchout reaches your shop
A punchout has three legs, and your shop takes part in two of them.
Buyer's procurement system Medienwerft Punchout Your shop
────────────────────────── ──────────────────── ─────────
launch (IDS / OCI / cXML) ──► checks the return address,
identifies the customer,
maps the basket
redirect ───────────────────────► /punchout/resume#t=…
exchange t ──► handoff
◄── lines, submitUrl, submitToken ◄──
buyer shops in your cart
◄──────────────────── form POST ── "transfer basket"
basket in the buyer's ◄── maps it back, writes the
own protocol buyer's document
1 · The redirect. The service sends the buyer's browser to your storefront URL with /punchout/resume appended — for a connection whose storefront URL is https://shop.example.com, that is:
https://shop.example.com/punchout/resume#t=Hc2y…
Any query string on the configured storefront URL is kept (https://shop.example.com/shop?cmsLayout=acme becomes …/shop/punchout/resume?cmsLayout=acme#t=…).
2 · The handoff token. t is a single-use credential, valid for a few minutes. It travels in the URL fragment — the part after # — because browsers never send a fragment to a server: it stays out of your access logs, out of proxies and out of Referer. The price is that only the browser can read it, so the page at /punchout/resume has to run a little JavaScript (or see chapter 7 for the no-JS variant).
3 · The exchange. Your shop trades the handoff token for the basket: the lines the buyer arrived with (often none), and what it needs to send a basket back — a submitUrl and a submitToken.
4 · The return. When the buyer presses "transfer", your cart posts the basket to submitUrl as a plain HTML form. The service answers with a page that carries the basket on into the buyer's system, in the buyer's protocol.
Two things are never in your shop's hands, by design:
- The buyer's return address. It came with the buyer's launch and stays on the service side. The
submitTokenidentifies the session; the service decides where the basket goes. A shop — or someone who copied a link out of it — cannot send a basket anywhere else. - The protocol. Your shop sees the same
PunchoutCartfor an IDS craftsman, an SAP buyer and an Ariba requisition.
Two tokens, two clocks
Handoff token (t) |
Submit token | |
|---|---|---|
| Carried in | the redirect URL's fragment | your session, then the return form |
| Lifetime | minutes | the shopping session (submitExpiresAt) |
| Use | once, to pick up the basket | once, to send it back |
The submit token is given back when the service refuses a transfer before sending anything — see chapter 6.
2. Picking up the basket
Two parts: the page at /punchout/resume reads the token in the browser, and a route on your own server exchanges it.
The exchange — on your server
Do the exchange server-side when you can. The token then never appears in the browser's network log, and the answer arrives where your catalogue already lives — which is where an article number has to become one of your products.
// POST /api/punchout/resume — any runtime with fetch (Node 18+, Deno, Bun, workers)
import { exchangeHandoff, PunchoutError } from '@medienwerft/punchout-client';
export async function resumeRoute(request: Request): Promise<Response> {
const { token } = (await request.json()) as { token?: string };
if (!token) return Response.json({ error: 'missing token' }, { status: 400 });
try {
const cart = await exchangeHandoff(token, { apiUrl: process.env.PUNCHOUT_API_URL });
// The customer and the person, straight from the service — act on them HERE (below).
if (cart.customer) await signInCustomer(cart.customer, cart.buyerUserGenerated ? undefined : cart.buyerUserId);
return Response.json({
connection: cart.connection,
currency: cart.currency,
submitUrl: cart.submitUrl,
submitToken: cart.submitToken,
submitExpiresAt: cart.submitExpiresAt,
submitEncoding: cart.submitEncoding, // the transfer form's enctype, when the service needs one
requirements: cart.requirements,
buyerUserId: cart.buyerUserId,
buyerUserGenerated: cart.buyerUserGenerated,
inquiryNo: cart.inquiryNo, // the buyer's own reference, for display
lines: cart.lines.map(toYourCartLine), // your catalogue lookup
unknown: cart.lines.filter(notInCatalogue).map((l) => l.sku),
});
} catch (e) {
const status = e instanceof PunchoutError && e.status === 404 ? 410 : 502;
return Response.json({ error: e instanceof Error ? e.message : 'exchange failed' }, { status });
}
}
The buyer's reference. cart.inquiryNo is the reference the buyer's software sent with the launch (IDS-Connect InquiryNo, their Anfragenummer). Show it if it helps the buyer. You never have to send it back: the service puts it on the returned basket by itself, unless you pass your own inquiryNo (chapter 5).
Forward every session field. submitExpiresAt, requirements and buyerUserId look optional, and a route that drops them still works — badly. Without submitExpiresAt the session never expires on its own, so a buyer returning tomorrow is offered a transfer that can only fail. Without requirements every customer gets the plain cart button and no custom fields. Without submitEncoding the transfer form posts urlencoded, which a service running on Emporix cannot receive: the buyer presses the button and gets a server error.
Signing the customer in
When the service recognised the customer, the exchange says who it is:
cart.customer // { key: '10042', displayName: 'Acme Plumbing Ltd', shop: { emporixCustomerNo: 'C-42' }, signedIn: true }
cart.buyerUserId // the person: OCI's USER_ID, the cXML end user's e-mail
cart.buyerUserGenerated // true when buyerUserId is a stand-in the service made up
shop is whatever the dashboard keeps under settings.shop on that customer's profile — typically the account number in your commerce system. Sign that account in from the exchange route, and the buyer sees their own prices and assortment, has their own order profile and gets their own roles, exactly as when they log in themselves. The service never calculates a price or decides a permission; your commerce system does.
Only here, on the server. customer arrives in the server-to-server exchange, from the service's own session, so a buyer cannot choose it. Do not copy it into the browser and read it back later: the punchout session is stored in the browser (chapter 3), where it can be edited, and an account chosen from there is an account the buyer chose. For the same reason, check roles against the buyerUserId you received here, never one from the browser — and never grant a role to a stand-in (buyerUserGenerated).
Keep unknown articles, and say so. A line whose SKU is not in your catalogue should go into the cart as the buyer sent it and be listed in unknown. Dropping it silently means the basket quietly loses items between the buyer's system and yours, and nobody notices until the order arrives short.
One message for every bad token. The service answers invalid, expired and already-used tokens identically, so someone probing tokens learns nothing. Pass the message through rather than inventing a more specific one.
Checking the login — your sign-in route
The buyer's system sends a login with every punchout: IDS-Connect a customer number, user and password, OCI a USERNAME and PASSWORD, cXML a shared secret. Only your shop knows whether it is right. With a sign-in address set on the connection (Connections → Policy), the service asks a route of yours before it opens anything, for every launch, search, product link and OCI price check:
// POST /api/punchout/sign-in — any runtime with Request/Response
import { createSignInRoute } from '@medienwerft/punchout-client';
export const POST = createSignInRoute({
secret: process.env.PUNCHOUT_SHOP_SECRET!,
signIn: async ({ customerNo, userName, password }) => {
const account = await checkLogin(customerNo, userName, password);
if (!account) return { ok: false, reason: 'unknown login' };
return { ok: true, customerNo: account.customerNumber, userId: account.userId, displayName: account.companyName };
},
});
-
What your route receives (
PunchoutSignIn):Field IDS-Connect OCI cXML customerNokndnr— — userNamename_kundeUSERNAME— passwordpw_kundePASSWORDSendershared secretbuyerUserId— USER_IDthe end user's e-mail buyerId— — FromidentitysenderId— — Senderidentityfieldsall launch fields all launch fields — Plus
connection(the slug),protocol(ids,oci,cxml) andaction(WKS,LAUNCH,BACKGROUND_SEARCH,VALIDATE, …).fieldsnever contains the password, under whatever name it arrived, and leaves out values over 2,000 characters. -
Your customer number picks the customer. Answer with
customerNoand the service uses it, not the protocol's own key, to choose the customer profile, its unit mappings, custom fields and hooks for the whole punchout. It comes back to your exchange route ascart.customer.key, withsignedIn: true, even when nobody set up a profile for that customer. Leave it out and the protocol's key decides as before. -
Your user id names the person.
userIdcomes back ascart.buyerUserId. It replaces OCI's made-up stand-in, so a role may be granted to it. -
No is no.
{ ok: false }or a 4xx refuses the buyer, who is told the login was refused. A timeout after 10 seconds, a 5xx or an unreachable route refuses too, as the shop's failure. Nothing opens without your yes. -
It is signed, and that is not optional. Your route is a public address that answers "is this login right, and whose is it?". Unsigned, anyone who found it could test passwords against your customer accounts or collect customer numbers. So every call carries
x-punchout-signature, an HMAC over the raw body, and both ends fail closed: the service does not call the route at all until the connection holds the secret, andcreateSignInRouteanswers 401 beforesignInruns when the signature is missing, altered or older than five minutes. Set the secret once on the connection, under Connections → edit → Credentials, with the nameshopSigningSecret, and the same value in your shop asPUNCHOUT_SHOP_SECRET. The order route (chapter 6) uses the same secret. Without the helper, callverifyPunchoutSignature(rawBody, header, secret)on the raw text before parsing; without JavaScript at all, see chapter 11. -
The password is yours alone. The service sends it in this one call and stores it nowhere. Do not log it either.
Normalise the customer number here. The customer profile is matched on the exact customer number. If the buyer's software sends 0010042 and your shop knows 10042, answer with your own form as customerNo, and that is what picks the profile. Without a customerNo in your answer, the protocol's own key picks it: kndnr for IDS-Connect, USERNAME for OCI, the From identity (buyerId) for cXML.
A customer number in the wrong field. Some procurement software sends the customer number in a field of its own, or in name_kunde instead of kndnr. Your route sees every launch field in fields, so it can look there:
signIn: async ({ customerNo, userName, password, fields }) => {
const number = (customerNo ?? fields?.kundennummer ?? '').replace(/^0+/, '');
const account = await checkLogin(number, userName, password);
return account ? { ok: true, customerNo: account.customerNumber } : { ok: false, reason: 'unknown login' };
},
The tenant can fix the same thing for every shop route at once with an onInbound hook. It runs on the raw launch fields before anything reads them, so your route receives what the hook left: return { ...form, kndnr: (form.kndnr || form.kundennummer || '').replace(/^0+/, '') };. A cXML launch is a document, not fields, so neither works there: its customer is the From identity.
What runs before your answer cannot depend on it. onInbound and authenticate run before the sign-in, so only the connection's own hooks run there, never a customer profile's. Everything after it — the customer's unit mappings, custom fields and hooks — follows the customer number you answered.
Without a sign-in route — the authenticate hook
A tenant can bind an authenticate hook instead, in the dashboard's Hooks tab. Hooks are written by the tenant's own Punchout Admin, not by your shop and not by Medienwerft. The hook is the weaker tool, and it is good to know why:
- It sees the launch fields and nothing else. Its inputs are
form(the raw launch fields: IDS-Connectkndnr,name_kunde,pw_kunde; OCIUSERNAME,PASSWORD; empty for cXML),cart,connectionandlog. It has no network access and no connection secrets, so it cannot check a login against your customer accounts. It can only apply fixed rules, such as "a customer number must be present". - It answers yes or no. Return
true(or nothing) to let the punchout open,falseor{ ok: false, reason }to refuse it. A hook that throws refuses too. - It cannot choose the customer. Whatever else it returns is ignored; the customer profile is still picked by the protocol's customer number. To normalise that number without a sign-in route, rewrite it in an
onInboundhook, which runs before the customer is looked up:return { ...form, kndnr: form.kndnr.replace(/^0+/, '') }; - It only runs on a basket launch (IDS-Connect
WKS/WKE, an ordinary OCI or cXML launch). It does not run for searches and product links (IDS-ConnectAS/ADLand their OCI and cXML counterparts) or for OCI price checks. The sign-in route covers all of them.
With neither a sign-in route nor an authenticate hook, nothing is checked: the login the buyer's software sends only picks the customer profile. Such a punchout can still fill a cart and send it back, but no order from it is relayed to your order route or an onOrder hook: anyone who knew a customer number could otherwise order on that customer's account (chapter 6). If both are set, the hook checks first and your route second, and either can refuse.
cXML is checked by the service as well. A cXML buyer, or its network, sends a shared secret in the Sender part of every document. Set the value you agreed with the buyer as the connection credential cxmlSharedSecret, and the service refuses every cXML document that does not carry it, before your sign-in route is asked. It is not shopSigningSecret: the buyer knows this one, and must never be able to sign calls into your shop.
Which service — resolvePunchoutApiUrl
exchangeHandoff talks to Medienwerft's production service unless you pass apiUrl:
import { DEFAULT_PUNCHOUT_API_URL, resolvePunchoutApiUrl } from '@medienwerft/punchout-client';
DEFAULT_PUNCHOUT_API_URL; // 'https://api.punchout.medienwerft.de/api'
resolvePunchoutApiUrl(process.env.PUNCHOUT_API_URL); // your setting, else production
A production shop needs no setting at all. Set it in development and staging — a dev shop without it talks to production without any error. The SDK logs the address it uses once per process ([punchout] using punchout-api at …), which is how that gets noticed on the first punchout. Include the /api mount when you set it.
The address is never taken from the incoming link. Which punchout service a shop trusts is the shop's decision.
The resume page — in the browser
/vendor/punchout-client.js is the client's single-file browser build, downloaded from /sdk and served from your own origin. With a bundler, import from @medienwerft/punchout-client instead.
<!-- /punchout/resume -->
<p id="status">Taking over your basket…</p>
<script type="module">
import { readHandoffToken, readHandoffNext } from '/vendor/punchout-client.js';
const token = readHandoffToken(location.hash);
const next = readHandoffNext(location.hash, location.origin); // search / deep-link punchouts
// Remove the spent credential from the address bar before anything can bookmark it.
history.replaceState(null, '', location.pathname + location.search);
if (!token) {
document.getElementById('status').textContent = 'No punchout token in the address.';
} else {
const res = await fetch('/api/punchout/resume', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ token }),
});
const body = await res.json();
if (!res.ok) {
document.getElementById('status').textContent = `Could not take over the basket: ${body.error}`;
} else {
rememberSession(body); // chapter 3
yourCart.replaceWith(body.lines); // a punchout REPLACES the cart
if (body.unknown.length === 0) location.assign(next ?? '/cart');
else showUnknown(body.unknown); // let the buyer see what could not be matched
}
}
</script>
- Exchange exactly once. The token is single-use; a second exchange fails with the "already used" message. Frameworks that run effects twice in development will show exactly that.
- Replace the cart, do not merge. The buyer's system is the record of what they are buying; adding to whatever was left in the browser produces a basket neither side agreed to.
nextis present for punchouts that start without a basket — an article search, or a deep link to one product: IDSADL, OCIDETAIL, or a cXML Level 2 login naming a product. Send the buyer there instead of to an empty cart. The path comes from the connection'sdeeplinkhook, so your product URLs are the tenant's to map, not the protocol's.readHandoffNextreturns same-origin paths only, so the fragment cannot be turned into an open redirect.
3. Keeping the session
Between picking up the basket and sending it back, the buyer browses your shop. Every page that shows a cart has to know a punchout is in progress, and the cart page needs the submitUrl and submitToken. That is the PunchoutSession:
interface PunchoutSession {
connection: string;
submitUrl: string;
submitToken: string;
submitExpiresAt?: string; // when the return leg closes
submitEncoding?: 'text/plain'; // the transfer form's enctype, when the service needs one
requirements?: PunchoutRequirements; // chapter 4
buyerUserId?: string; // OCI's USER_ID or a stand-in, the cXML end user
buyerUserGenerated?: boolean; // buyerUserId is a stand-in
}
The customer is not part of it on purpose: this session lives in the browser, and who the customer is must not be something the browser can change. Sign the account in when you exchange the token (chapter 2).
Where to keep it
Procurement systems open shops in new windows, in pop-ups and inside frames on their own domain. In a frame, your shop is a third-party context, and browsers are increasingly unwilling to store anything there. So the SDK offers several stores — rungs — and a way to use them together:
| Store | What it is | What it survives |
|---|---|---|
cookieSessionStorage() |
A cookie, SameSite=None; Secure; Partitioned over https. |
New tabs. The only store your server can read. |
webSessionStorage() |
sessionStorage for this tab. |
Engines that reject SameSite=None, a full cookie jar. |
windowNameSessionStorage() |
window.name of this browsing context. |
Frames whose cookies and storage are both blocked. |
Use them layered, written through and read first-hit:
import {
layeredSessionStorage, cookieSessionStorage, webSessionStorage,
windowNameSessionStorage, persistSession,
} from '@medienwerft/punchout-client';
const store = layeredSessionStorage([
{ name: 'cookie', storage: cookieSessionStorage() },
{ name: 'session', storage: webSessionStorage() },
// Last resort only: an old browser keeps window.name across sites.
{ name: 'window', storage: windowNameSessionStorage(), writeIf: (landed) => landed === 0 },
]);
function rememberSession(body) {
const session = {
connection: body.connection,
submitUrl: body.submitUrl,
submitToken: body.submitToken,
submitExpiresAt: body.submitExpiresAt,
submitEncoding: body.submitEncoding,
requirements: body.requirements,
buyerUserId: body.buyerUserId,
buyerUserGenerated: body.buyerUserGenerated,
};
const held = persistSession(store, session); // writes, then reads back
if (!held) showSessionLost(); // say it — do not degrade silently
return store.report(); // which rungs held it: ['cookie', 'session']
}
Check that it stuck. A browser that refuses a cookie in a frame does not throw — it does nothing. persistSession writes and reads back, and returns whether the session survived. When it did not, the basket is in the cart with no way home; tell the buyer (opening the shop in its own window fixes it) rather than showing an ordinary checkout button.
window.name stays last. It is the one place no cookie or storage policy reaches, which is why it can rescue a blocked frame. It is also, on older browsers, carried to the next site opened in that tab — so it is written only when nothing else held the session.
Everything the stores return has been through validateSession: an expired session reads as absent, so an old session never offers a transfer that can only fail.
On the server
The cookie is what lets a server-rendered cart show the right button on the first paint:
import { parseSessionCookie } from '@medienwerft/punchout-client';
const session = parseSessionCookie(request.headers.get('cookie'));
// session ? render "Transfer basket" : render "Checkout"
Without it, the cart can only find out after the page has loaded in the browser, and a punchout buyer sees the ordinary checkout button flash first.
Your own store
A shop with its own server session can implement SessionStorage (get, set, clear — synchronous) and pass that instead. get() should return validateSession(raw).
4. Reading the requirements
What the cart has to offer and collect is not your shop's decision. The service decides it per customer — from the connection and the customer's profile — and tells the shop in session.requirements:
interface PunchoutRequirements {
submit: ('cart' | 'order')[];
fields: { key: string; label: string; level: 'basket' | 'line'; required: boolean; maxLength?: number }[];
classification?: { system: string; version?: string };
}
It never says which protocol the buyer speaks, who the customer is, or which wire field a value lands in. Render what it asks for and nothing else.
Which buttons — submit
submit |
Render |
|---|---|
['cart'] |
One button: transfer the basket. |
['cart', 'order'] |
Two: transfer the basket, and transfer as an order. |
['order'] |
One button, which transfers as an order — label it that way. |
Which inputs — fields
Custom fields the buyer's procurement needs: a cost centre, a project number, a line reference. level: 'basket' is one input for the whole basket; level: 'line' is one input per line. Use key for the value and label for the input's label.
const req = session.requirements ?? { submit: ['cart'], fields: [] };
const basketFields = req.fields.filter((f) => f.level === 'basket');
const lineFields = req.fields.filter((f) => f.level === 'line');
const missing = [
...basketFields.filter((f) => f.required && !basketValues[f.key]?.trim()),
...lineFields.filter((f) => f.required && lines.some((l) => !lineValues[l.sku]?.[f.key]?.trim())),
];
transferButton.disabled = missing.length > 0;
Hold the transfer while a required field is empty. The service refuses such a basket anyway, but stopping it in the cart keeps the buyer on the page where they can fill it in.
Which code — classification
When present, the customer wants a commodity code on every line in this system and release — for example { system: 'ECLASS', version: '13.0' }. You do not have to pick: send every code you hold (chapter 5) and the service chooses. It is here for a shop that wants to show it, or to warn when an article has none.
Absent requirements
requirements is absent from an API that predates it, or from a shop route that did not forward it. Treat that as { submit: ['cart'], fields: [] } — exactly the one button a shop offered before requirements existed.
5. Sending the basket back
The return is a plain HTML form posted to session.submitUrl. Not a fetch: the service answers with a page that carries the basket on into the buyer's system, and that only works if the browser navigates to it. A pleasant consequence is that the return needs no JavaScript at all.
import { buildSubmitPayload, stashPendingSubmit } from '@medienwerft/punchout-client';
function transferForm(session, lines, { asOrder = false, fields = {} } = {}) {
const form = document.createElement('form');
form.method = 'post';
form.action = session.submitUrl;
const hidden = (name, value) => {
const input = Object.assign(document.createElement('input'), { type: 'hidden', name, value });
form.append(input);
};
hidden('token', session.submitToken);
hidden('kind', asOrder ? 'order' : 'cart');
hidden('payload', buildSubmitPayload(lines, { currency: 'EUR', fields }));
form.addEventListener('submit', () => {
stashPendingSubmit(session); // chapter 6: survive a refusal
store.clear(); // the token is single-use; do not offer it again
});
return form;
}
The three fields are the whole contract: token (the submit token), kind (cart or order), and payload (the basket).
The lines — OutboundLine
const lines: OutboundLine[] = cart.items.map((item) => ({
sku: item.sku, // the article number the buyer will recognise
name: item.name,
qty: item.quantity,
priceCents: item.unitPriceCents, // PER ONE UNIT, in minor units
unit: item.unit, // your unit; the service maps it to the buyer's
// optional — send what you have
longText: item.description,
ean: item.gtin,
manufacturerId: item.mpn,
classifications: [
{ system: 'ECLASS', version: '13.0', code: '27-06-01-01' },
{ system: 'UNSPSC', code: '53102500' },
],
category: item.categoryId, // looked up in the connection's mapping table
fields: lineValues[item.sku], // line-level custom fields, by key
note: item.remark,
vat: '19.00',
}));
- Prices are per one unit.
priceCents: 2900goes out as29.00for one piece, whatever the line quantity. Never pre-multiply, and never send a price per 100 or per 1000; the protocols that quote per N units are handled by the service. - Send every commodity code you hold. Which one reaches the buyer — and in which release — is the customer's configuration, decided at submit time. A shop never has to know which eCl@ss release a particular buyer's SAP is on. For a shop without codes,
categorylets the service find one in the connection's mapping table. - Units are yours. Send the unit your cart uses (
Stk,pcs); the connection's and customer's unit tables translate it. - Everything optional is additive. A service that predates a field ignores it, so the SDK and the service release independently.
Basket-level values
buildSubmitPayload(lines, {
currency: 'EUR',
fields: { costCentre: 'CC-204' }, // basket-level custom fields, by key
orderConfNo: yourOrderNumber, // for an order, where your shop assigns numbers
});
All of them are optional, and an empty one is left out of the document rather than sent blank.
inquiryNo, the buyer's reference, comes back by itself. When the buyer's software sent one with the launch (IDS-ConnectInquiryNo), the service puts it on the returned basket. PassinquiryNoonly to send a different value.orderConfNois your order number. A cart transfer never needs it. An IDS-Connect transfer as an order does. When the tenant'sonOrderhook or your order route places the order, their order number is used. If you place the order yourself (placedByShop: true, chapter 6), you must pass it. An order with no number from either is refused.- Not an offer number. IDS-Connect also has an
OfferNo(a quote or offer number). It is a different field, and the SDK does not set it.
The payload is JSON with every value as a string, so that 50.00 never turns into 50 on the way.
6. Orders and refusals
Transferring as an order
Offer "transfer as an order" only when session.requirements.submit includes 'order' (chapter 4), and send it with kind: 'order'.
Best: create the order yourself, then transfer. The buyer is in your shop, signed in as their account (chapter 2), so your commerce system can place the order there and then — at its prices, with the customer's order profile. Transfer with its number and say you placed it:
const payload = buildSubmitPayload(lines, { orderConfNo: order.number, placedByShop: true });
The service then relays the order nowhere (that would place it twice) and marks the transfer as an order for the buyer's system.
Otherwise the service delivers the order itself, before anything goes back to the buyer — but only from a punchout whose login was checked, by your sign-in route or an authenticate hook (chapter 2). From an unchecked one it refuses the transfer (403, login_unchecked) and relays nothing. When it does deliver, it goes to your order route (below), with the tenant's onOrder hook, if one is bound, running first: it can change the order or refuse it before your route sees it. Without an order route, the onOrder hook is the delivery and creates the order itself. If neither exists, IDS-Connect marks the returned basket as an order and nothing is relayed. The transfer is then listed as sent_with_issues, and its detail names the reason, because an order that reached no backend is usually not what anyone wanted. OCI and cXML refuse, because an order there that nothing receives would not exist anywhere.
Orders arriving at your shop
A cXML buyer sends its approved purchase order later, server to server, to the service — never to your shop. With an order address set on the connection (Connections → Policy), the service forwards it to a route of yours, which creates the order in your commerce system and answers with its number:
// POST /api/punchout/orders — any runtime with Request/Response
import { createOrderRoute } from '@medienwerft/punchout-client';
export const POST = createOrderRoute({
secret: process.env.PUNCHOUT_SHOP_SECRET!,
createOrder: async (order) => {
const account = await findAccount(order.customer?.shop); // e.g. shop.emporixCustomerNo
if (!account) return { ok: false, reason: 'unknown customer' };
const placed = await placeOrder(account, order.order.order, { reference: order.documentId });
return { ok: true, orderId: placed.number };
},
});
What arrives (PunchoutOrder): kind (purchaseOrder, or orderOnTransfer when a basket comes back as an order and you did not place it yourself), the buyer's documentId, the customer as in chapter 2, buyerUserId, and the order with its lines, the buyer's reference (order.order.info.inquiryNo: the PO number for cXML, the buyer's InquiryNo for an IDS-Connect basket), delivery address (deliveryPlace) and billing address (billTo).
- Price it yourself. The lines carry the prices the buyer approved — a claim. Create the order at your own prices and decide what a difference means: accept, flag, or refuse with a reason.
- It is signed. Each request carries
x-punchout-signature, an HMAC over the raw body with the secret set on the connection asshopSigningSecret; set the same value asPUNCHOUT_SHOP_SECRET.createOrderRouterefuses anything unsigned, altered or older than five minutes beforecreateOrderruns. Without the route helper, callverifyPunchoutSignature(rawBody, header, secret)yourself — on the raw text, before parsing; without JavaScript at all, see chapter 11. - Silence is a refusal. Anything but
{ ok: true, orderId }— an error, a timeout after 25 seconds,{ ok: false, reason }— refuses the order. The buyer's system is told it was not accepted, and the dashboard's relay alert counts it. - Only from the buyer. A cXML purchase order arrives server to server with nobody in front of it, so your sign-in route is not asked. What proves it came from the buyer is the shared secret in its
Senderpart: the service forwards nothing unless the connection has the credentialcxmlSharedSecretand the order carries that value. Until it is set, every purchase order is refused. - The customer is the
Fromidentity. No sign-in route answers for a purchase order, so the customer profile is picked byFromalone. Keep a cXML customer's profile under itsFromidentity, with your account number insettings.shop, and let your sign-in route answer cXML launches without acustomerNo: punchout and purchase order then pick the same profile, and both reach your shop with the samecustomer.shop. - Retries are already dropped. A buyer that resends the same purchase order is answered from the first attempt without a second forward. Keying your order on
documentIdas well makes a double delivery harmless at your end too.
When the service refuses
Some baskets cannot go back yet: a required custom field is empty, the customer may not order, your backend declined the order. The service then answers the form post with a short refusal page (German and English) that says why, with a link back to the cart — and gives the submit token back, because nothing was sent.
Your shop cleared the session when the buyer pressed "transfer" (chapter 5). So that coming back from the refusal page restores the punchout instead of showing an ordinary cart, stash the session before clearing it, and ask on the way back:
import { stashPendingSubmit, takePendingSubmit, isSubmitOpen, persistSession } from '@medienwerft/punchout-client';
// on submit
stashPendingSubmit(session);
store.clear();
// on every cart page load
let session = store.get();
if (!session) {
const pending = takePendingSubmit(); // removes it; null if none or expired
if (pending && (await isSubmitOpen(pending))) {
persistSession(store, pending); // the token was given back
session = pending;
}
}
isSubmitOpen asks the service whether the token can still be spent: true after a refusal, false after a transfer that went through. Any failure reads as false — offering a button that then fails is the worse mistake. The stash lives in sessionStorage, so it belongs to this tab and is never sent anywhere.
7. Without JavaScript
Some buyers still run procurement software whose embedded browser cannot run a modern script bundle — Internet Explorer mode, an old WebView. For those, a connection can use the query carrier (handoffCarrier: 'query'): the token arrives as ?t=… instead of #t=…, so your server can read it.
https://shop.example.com/punchout/resume?t=Hc2y…
The whole round trip then works with scripting switched off, because the return leg was always a plain form post:
- Exchange on the server, then redirect. Read
t, callexchangeHandoff, store the result in your own server session (anHttpOnlycookie is fine — the browser never needs the token), and redirect to a page without the token in its address. - Render the cart from the session. Your normal server-rendered cart, with the transfer buttons and fields from
requirements. - Render the return form on the server. The same three fields as chapter 5 —
token,kind,payloadfrombuildSubmitPayload— in a<form method="post" action="{submitUrl}">. When the exchanged cart carriessubmitEncoding: 'text/plain', addenctype="text/plain"to that form — the service is running where urlencoded bodies are refused (the public Emporix function).<PunchoutCheckout>does this for you.
// GET /punchout/resume?t=… (server)
const token = new URL(request.url).searchParams.get('t');
const cart = await exchangeHandoff(token, { apiUrl: process.env.PUNCHOUT_API_URL });
await yourSession.save({ punchout: cart }); // exchanged once; a reload reads the session
return redirect('/cart', 303);
Exchange in a route that can set a session, never in the page render. A page that exchanges the token while rendering works exactly once: a reload re-exchanges a spent token and the buyer loses the basket.
Keep the token out of Referer. The token is briefly in the address bar with this carrier; send Referrer-Policy: no-referrer on the resume page so it does not follow the buyer to the next request.
Framed shops. A first-party session cookie is still a third-party cookie when the buyer frames your shop. A server-rendered shop that must survive both puts its session id in its own URLs.
Which carrier a connection uses is set in the dashboard. A resume route can serve both: ?t= on the server, #t= in the browser.
The routes the service calls are server code too. A sign-in route (chapter 2) and an order route (chapter 6) never involve the buyer's browser, so the carrier changes nothing about them. A shop that runs no JavaScript on its server at all, in PHP, Java or .NET, builds both from chapter 11.
8. A customer's own look
A customer profile can send its buyers to a different shop address than the connection's:
| Profile's shop address | Buyers land on |
|---|---|
| empty | the connection's storefront URL |
/shop?cmsLayout=acme&cmsTheme=acme |
the connection's origin, with this path and query |
https://acme.example.com |
that address |
The resume redirect keeps the query (chapter 1), so a shop that themes itself from query parameters receives them on /punchout/resume:
https://shop.example.com/shop/punchout/resume?cmsLayout=acme&cmsTheme=acme#t=…
Keep it for the visit. The query arrives once, on the resume page. If your shop reads the look from it, remember it in the punchout session or a cookie of your own and apply it on every later page — otherwise the buyer's second click shows your default look.
Do not trust it for anything but the look. The address comes from configuration, but the buyer's browser can edit it like any URL. Layout and colours are fine; prices, assortment and permissions belong to what the service tells you in the handoff, not to a query parameter.
Knowing the buyer — buyerUserId
session.buyerUserId is the person punching out: for OCI the SAP user the launch named (USER_ID), for cXML the end user's e-mail (the endUser contact, else Ariba's UserEmail). An OCI launch without one gets a random stand-in (anon-…) and buyerUserGenerated: true. Show it in the header, or keep one basket per person when a buyer organisation shares one account. It is absent when the buyer named nobody.
For a role or a permission, use the value from the exchange on your server (chapter 2), not the one in the browser's session — and never one that is a stand-in.
9. React
@medienwerft/punchout-react is chapters 2 to 6 as three pieces:
| Replaces | |
|---|---|
<PunchoutResume> |
the resume page: fragment, exchange, session, cart, redirect |
usePunchoutSession() |
reading the session, including the way back from a refusal |
<PunchoutCheckout> |
the return form |
You still write the server route from chapter 2 — <PunchoutResume> posts { token } to /api/punchout/resume by default — and one binding to your cart.
The binding
The only shop-specific part: how a line becomes a line in your cart.
// punchout-binding.ts
import type { CartBinding } from '@medienwerft/punchout-react';
import { addLine, clearCart } from './cart';
export interface ResolvedLine { sku: string; productId: string; name: string; priceCents: number; unit?: string; qty: number }
export const binding: CartBinding<ResolvedLine> = {
clear: clearCart,
add: (l) => addLine({ sku: l.sku, productId: l.productId, name: l.name, priceCents: l.priceCents, unit: l.unit }, l.qty),
cartPath: '/cart',
};
ResolvedLine is whatever your server route returns in lines — already matched against your catalogue.
The resume page
'use client';
import { PunchoutResume } from '@medienwerft/punchout-react';
import { binding, type ResolvedLine } from './punchout-binding';
export default function ResumePage() {
return (
<PunchoutResume<ResolvedLine> binding={binding}>
{(state) =>
state.phase === 'working' ? <p>Taking over your basket…</p>
: state.phase === 'error' ? <p>Could not take over the basket: {state.message}</p>
: <>
<p>{state.added} articles taken over</p>
{state.session === 'lost' && <p>Your browser did not keep the punchout session. Open the shop in its own window and start again.</p>}
{state.unknown.length > 0 && <p>Not in our catalogue: {state.unknown.join(', ')}</p>}
</>
}
</PunchoutResume>
);
}
It reads the fragment, removes the token from the address bar, exchanges it once (safe under StrictMode's double effects), writes the session to the layered store from chapter 3 and checks it stuck, replaces the cart, and navigates on — to next for search and deep-link punchouts, otherwise to binding.cartPath. It stays on the page when an article could not be matched, so the buyer sees which.
state.session is stored (the server can read it), volatile (held, but not in the cookie — server rendering cannot see it) or lost (nothing held it; say so).
Props worth knowing: navigate (e.g. router.replace), redirectTo, resolve (resolve lines in the browser instead of on the server), exchange (replace the default POST), storage.
The cart
'use client';
import { useState } from 'react';
import { PunchoutCheckout, usePunchoutSession } from '@medienwerft/punchout-react';
export function CartActions({ lines, initialSession }) {
const session = usePunchoutSession(undefined, initialSession);
const [costCentre, setCostCentre] = useState('');
if (!session) return <CheckoutButton />;
const req = session.requirements ?? { submit: ['cart'], fields: [] };
const needsCostCentre = req.fields.some((f) => f.key === 'costCentre' && f.required);
const outbound = lines.map((l) => ({ sku: l.sku, name: l.name, qty: l.qty, priceCents: l.priceCents, unit: l.unit }));
return (
<>
{needsCostCentre && <input value={costCentre} onChange={(e) => setCostCentre(e.target.value)} />}
{req.submit.map((kind) => (
<PunchoutCheckout
key={kind}
session={session}
lines={outbound}
asOrder={kind === 'order'}
fields={{ costCentre }}
disabled={needsCostCentre && !costCentre.trim()}
buttonClassName="btn btn-primary"
>
{kind === 'order' ? 'Transfer as order' : 'Transfer basket'}
</PunchoutCheckout>
))}
</>
);
}
Render your fields from req.fields generally rather than by key as above; the example names one field to stay short.
<PunchoutCheckout> renders the form from chapter 5 — token, kind, payload — and stashes and clears the session on submit. usePunchoutSession picks the session back up after a refusal (chapter 6).
Server rendering
Pass the session in from the server so the first paint already shows the right button:
// a server component (Next.js App Router)
import { headers } from 'next/headers';
import { parseSessionCookie } from '@medienwerft/punchout-client';
const initialSession = parseSessionCookie((await headers()).get('cookie'));
return <CartActions lines={lines} initialSession={initialSession} />;
Without initial, the hook can read the session only after mount, and a punchout buyer briefly sees the ordinary checkout button.
The package has one entry point. The components carry 'use client', and nothing in it requires Next.js; the same code runs in a Vite or Remix app.
10. Testing your integration
You do not need a buyer's procurement system to test a storefront. The dashboard's test console runs a real punchout against a connection — real hooks, a real session, your real shop — and a built-in inspector stands in for the buyer's system on the way back.
- Point a connection at your shop. In development, a connection whose storefront URL is your local shop (
http://localhost:3000). AddPUNCHOUT_API_URLto your shop's environment if you test against anything but production (chapter 2). - Open the test console and choose the connection — and a customer, to test that customer's buttons, fields and look. Choosing a customer fills in what its software would send.
- Run it. The console shows the trace of every hook point: whether a hook ran, whose it was, what it received and returned. Follow the link into your shop.
- Shop, then transfer. Your resume page should take over the basket, the cart should show the right buttons and fields, and the transfer should land on the return inspector, which shows exactly what the buyer's system would have received — the IDS document, the OCI fields, or the cXML message.
- Check the transfer. In the dashboard's transfer list, the round trip appears with the hooks that ran for it.
What to try on purpose:
- A required field left empty. The cart should hold the transfer; if it does not, the service refuses and the refusal page's "back" should restore the punchout (chapter 6).
- Transfer as an order, on a customer allowed to order. Without
placedByShop, the order should arrive at your order route asorderOnTransferbefore the basket reaches the inspector, and the inspector should show yourorderIdas the order confirmation number. WithplacedByShop, your order route should not be called at all. - An order your shop refuses. Have your order route answer
{ ok: false, reason: '…' }: the transfer should stop at the refusal page with nothing sent, and "back" should restore the punchout (chapter 6). - An order without a login check. On a connection with neither a sign-in address nor an
authenticatehook, an order transfer is refused (403,login_unchecked). Set the sign-in address before you test orders. - A wrong login, if you have a sign-in route. Fill in a password your shop rejects: the console should show the launch refused, with your
reasonon the transfer. Then a correct one: the transfer should name the customer your route returned ascustomerNo, and your exchange route should receive it ascart.customer.key. - An unsigned call. POST anything to your sign-in and order routes without
x-punchout-signature, or with a different secret: both must answer401and do nothing. A route that accepts it can be used by anyone to test passwords or place orders. - A reload of the resume page. It should not try to exchange the spent token a second time.
- The shop in a frame, if your buyers frame it — the case in which cookies are most often refused (chapter 3).
- An article not in your catalogue, sent in the launch basket. It should be kept and listed, not dropped.
The raw API — for a test harness of your own — is described at /docs.
11. The shop routes on the wire
createSignInRoute (chapter 2) and createOrderRoute (chapter 6) are the easy way to answer the service. A shop that runs no JavaScript on its server, in PHP, Java or .NET, builds the same two routes from this chapter.
Every call
The service calls your route with:
POST /your/route HTTP/1.1
Content-Type: application/json
x-punchout-signature: t=1793448000,v1=5f0c…e81a
{"connection":"demo","protocol":"ids","action":"WKS", …}
Check the signature before anything else. The header has two parts: t, the time of signing in Unix seconds, and v1, the lowercase hex HMAC-SHA256 of the string <t>.<raw body>, keyed with the secret set on the connection as shopSigningSecret. To check it:
- Read the body as raw text. Do not parse it and serialise it again first, because that changes the bytes.
- Split the header on
,and each part on the first=. - Refuse when
tis more than 300 seconds away from your clock. A captured request cannot then be replayed later. - Compute
HMAC-SHA256(secret, t + "." + rawBody)as lowercase hex, and compare it withv1in constant time. - On any failure, answer
401and do nothing else.
// PHP
$raw = file_get_contents('php://input');
$parts = [];
foreach (explode(',', $_SERVER['HTTP_X_PUNCHOUT_SIGNATURE'] ?? '') as $p) {
[$k, $v] = array_pad(explode('=', trim($p), 2), 2, '');
$parts[$k] = $v;
}
$t = (int) ($parts['t'] ?? 0);
$expected = hash_hmac('sha256', $t . '.' . $raw, getenv('PUNCHOUT_SHOP_SECRET'));
if (abs(time() - $t) > 300 || !hash_equals($expected, $parts['v1'] ?? '')) {
http_response_code(401);
exit;
}
$request = json_decode($raw, true);
Answer with Content-Type: application/json.
The sign-in route
What arrives. Fields that do not apply are left out, never sent empty:
{
"connection": "demo",
"protocol": "ids",
"action": "WKS",
"customerNo": "0010042",
"userName": "meier",
"password": "…",
"fields": { "action": "WKS", "kndnr": "0010042", "name_kunde": "meier", "hookurl": "https://…", "version": "2.5" }
}
Chapter 2 lists which protocol field fills which property. Treat password as you treat a login form's: check it and forget it, and do not write it to a log.
What to answer.
| Your answer | What happens |
|---|---|
200 with {"ok": true} |
The punchout opens. The protocol's own key picks the customer profile. |
200 with {"ok": true, "customerNo": "10042", "userId": "u-7", "displayName": "Acme Plumbing Ltd"} |
The punchout opens. customerNo picks the profile, userId becomes buyerUserId. All three are optional. |
401, 403 or another 4xx, or 200 without "ok": true |
The buyer is told the login was refused. Put a short reason in the body; it is recorded on the transfer. |
5xx, no answer within 10 seconds, or no connection |
The buyer is refused, and the transfer records it as your shop's failure. |
Values longer than 100 characters (200 for displayName) are cut off.
The order route
What arrives: a PunchoutOrder as chapter 6 describes it:
{
"kind": "purchaseOrder",
"documentId": "1793448000.4711@buyer.example",
"connection": "demo",
"customer": { "key": "AN0100", "displayName": "Acme Plumbing Ltd", "shop": { "emporixCustomerNo": "C-42" } },
"buyerUserId": "jane.doe@acme.example",
"order": { "order": { "info": { "inquiryNo": "PO-2026-118", "currency": "EUR" }, "items": [ … ], "deliveryPlace": { … }, "billTo": { … } } }
}
customer is null when no customer profile matched.
What to answer.
| Your answer | What happens |
|---|---|
200 with {"ok": true, "orderId": "EMX-1001"} |
The order is accepted, and the buyer's system is told so. |
200 with {"ok": false, "reason": "unknown customer"}, any non-2xx, or no answer within 25 seconds |
The order is refused, and the buyer's system is told it was not accepted. |
A resent purchase order with the same documentId is answered by the service from the first attempt. Keying your order on documentId as well makes a double delivery harmless at your end too.
12. Which flow a customer uses
Your shop integrates once. What differs between customers is what their procurement software expects when the basket comes back: a basket to order later, an order placed there and then, or a choice between the two. That is configured per connection and per customer as the order mode, and your shop learns the outcome from requirements.submit (chapter 4). This chapter shows each flow end to end, with the service's endpoints and your shop's routes in it.
In the diagrams, a solid arrow travels through the buyer's browser, a dashed one goes server to server, and a dotted one is made only when its address is set. A blue label links to the API reference or to this guide.
Words that sound alike
Three different things are called a "hook" in conversations about punchout. They are not related.
| Term | What it is | Who writes it | Where it runs |
|---|---|---|---|
Hook (authenticate, onOrder, quote, …) |
A small function at a defined point of the punchout | The tenant's Punchout Admin, in the dashboard | Inside the service. It never runs in your shop. |
| Shop route (sign-in route, order route) | An HTTP endpoint in your shop that the service calls, signed | You, in your shop (createSignInRoute, createOrderRoute, or chapter 11) |
In your shop |
hookurl (IDS), HOOK_URL (OCI) |
The protocols' name for the buyer's return address, where the basket goes back to | The buyer's software | It is an address, not code. It must be on the connection's allowlist. |
The rest of the vocabulary:
| Term | Meaning |
|---|---|
| Resume page | The page in your shop a punchout lands on (/punchout/resume#t=…). Chapter 1. |
| Exchange route | Your server route that trades the handoff token for the basket at GET /handoff/{token}. Chapter 2. |
| Handoff token | Single-use token in the resume page's address. It carries nothing itself. |
| Submit token | Single-use token your cart posts back with the basket. The shop never sees the buyer's return address. |
| Order mode | off, offer or always, per connection and per customer: which transfer buttons your cart shows. |
| Relay | The service delivering an order before anything goes back to the buyer: to your order route, after the tenant's onOrder hook if one is bound. Without an order route, the hook alone delivers it, calling the order API itself. |
shopSigningSecret |
The connection secret every call into your shop is signed with. Your shop keeps the same value as PUNCHOUT_SHOP_SECRET. |
cxmlSharedSecret |
The secret a cXML buyer's system presents. The other direction, and never the same value. |
Who checks the login
Every punchout arrives with a login, and the service does not know your customers' passwords. What is checked depends on what is set up.
| IDS-Connect | SAP OCI | cXML | |
|---|---|---|---|
| What the buyer's system sends | kndnr, name_kunde, pw_kunde |
USERNAME, PASSWORD |
From identity, Sender shared secret |
| Who picks the customer profile | kndnr, or the customerNo your sign-in route returns |
USERNAME, or your customerNo |
From, or your customerNo |
| Who can check the password | Your sign-in route; an authenticate hook |
Your sign-in route; an authenticate hook |
cxmlSharedSecret checks the system; your sign-in route can check the rest |
- Your sign-in route is asked for every launch, search, product link and OCI price check (chapter 2). It is the only check that knows your shop's accounts.
- An
authenticatehook runs inside the service on basket launches only, and sees the launch fields (none for cXML, whose setup is a document). When both are set, the hook runs first and your sign-in route is asked only if it allows the launch: an identity nobody has checked must not pick customer-specific hooks. It cannot reach your accounts, so it suits fixed rules, not passwords. - With neither, the login only picks the customer profile, and orders are never relayed: a basket submitted as an order is refused with
login_unchecked(chapter 6). Someone who knows a customer number could otherwise order on that customer's account. - A cXML purchase order arrives with nobody in front of it, so no sign-in route is asked. The shared secret is the proof, and purchase orders are refused until
cxmlSharedSecretis set.
IDS-Connect
Craftsman software opens the shop in its embedded browser, sometimes with a basket it already has (WKS with a Warenkorb). That basket arrives in the exchange as lines, unknown articles listed rather than dropped, in every pattern below. The default order mode for IDS is offer.
| What the craftsman expects | Order mode | requirements.submit |
Your cart shows | The order is created by |
|---|---|---|---|---|
| A basket to order later in their software, or today's prices for a basket they prepared | off |
["cart"] |
"Warenkorb übertragen" | Nobody here; their software orders later |
| Every transfer is the order | always |
["order"] |
"Bestellen" | Your shop (placedByShop), or the relay |
| A choice, at the cart | offer |
["cart", "order"] |
Both | The same, when "Bestellen" is chosen |
Basket only
The shop is a catalogue with current prices. Refreshing the prices of a prepared basket is this flow too: the craftsman sees the basket at today's prices and transfers it back.
Ordered on transfer
The order has to exist before the basket goes back, because its number travels with it as the order confirmation number.
- A: your shop places the order. Create it in your commerce system, then transfer with
buildSubmitPayload(lines, { orderConfNo: order.number, placedByShop: true }). Nothing is relayed. - B: the service relays it. Transfer without
placedByShop. If the tenant bound anonOrderhook, it runs first, inside the service: return nothing to pass the order on,{ order }to change it, or{ ok: false, reason }to refuse it. Then the service posts it to your order route, which creates it and answers its number. Without an order route, the hook is the delivery: it calls the order API itself (it hasfetchand the connection's credentials) and must answer{ ok: true, orderId }. This needs a checked login. - With neither A nor a relay, IDS still marks the document "mit Bestellung" and your shop must send
orderConfNoitself. No order exists in your system then; the transfer is listed with an issue saying so.
Checkout next to the transfer
Both buttons, and the craftsman decides per basket. "Bestellen" then works exactly as in Ordered on transfer.
SAP OCI
OCI brings no basket, and its return has no order in it: SAP turns the cart into a purchase order after its own approval. The default order mode is off.
Basket only
Order on transfer
For a customer whose contract makes the transfer the order. The order is created through the relay (or by your shop, with placedByShop), and SAP receives the basket as usual. Without an onOrder hook or an order route the transfer is refused, because an OCI order that nothing receives would not exist anywhere.
Price check
SAP asks for today's price of one article without opening the shop. The answer comes from the tenant's quote hook, which calls your price API. That is wherever today's prices live: your ERP, a price service or your shop's backend. The hook has fetch and the connection's credentials, and the service turns its answer into the OCI fields the requesting SAP expects. There is no shop route for this, and your storefront need not be involved. If the connection has a sign-in address, the login is checked there first, as for a launch. Without a quote hook the price check is refused, never answered with zero, which an approval would read as free.
cXML
Ariba, Coupa and similar platforms. The setup is server to server, the basket returns through the browser, and the firm order normally follows later as its own document. The default order mode is off.
Punchout and basket
Purchase order
After approval, server to server. It reaches your order route as kind: "purchaseOrder", after the tenant's onOrder hook if one is bound; without an order route, the hook alone delivers it. It is acknowledged in band, and is never relayed twice for the same payloadID.
Order on transfer
For customers whose contract skips the approval step. As for OCI. The login must be checked by your sign-in route or an authenticate hook; the shared secret alone does not count, because it proves the system, not the person.
What your shop builds for which flow
| Your shop needs | Basket only | Order: your shop places it | Order: relayed |
|---|---|---|---|
| Resume page and exchange route (chapters 1–2) | Yes | Yes | Yes |
Cart buttons from requirements.submit (chapter 4) |
Yes | Yes | Yes |
| Sign-in route (chapter 2) | Recommended | Recommended | Required, or an authenticate hook |
Order route (chapter 6), or the tenant's onOrder hook |
No | No | Yes |
placedByShop and orderConfNo on the submit |
No | Yes | No |