Create checkout
create_checkoutCreate checkout for one chosen offer and shipping speed. Hosted payment is the default. Call this after the user chooses the offer and shipping speed. This tool takes NO personal details: never ask for — and never pass — a name, address, email, or phone; the secure payment page collects the shipping address, email, and phone (and billing) itself, even when the user volunteered them in chat. In hosted-payment mode, returns checkout_url — the AFN's order page (what is being made, by which shop, the all-in price) with a Continue to payment button to the secure hosted payment page; give the link to the user. UFP places the vendor order automatically after payment. An offer whose shop still has to confirm it (manufacturability_check.status "unchecked", or confirmed more than 15 minutes ago) is confirmed by this call itself, and one whose status is "checking" is waited for (the price is set; the shop is confirming it can make the part as drawn) — no separate check_offer call. Pass max_total_cents: the price the user agreed to (the offer's subtotal_cents plus the chosen shipping cost_cents). THE CHECKOUT RULE, enforced by the network for every client: an offer can be ordered only when the shop's own system has accepted this part at this price — its manufacturability check has passed, the price is the shop's own number (price_basis "vendor_api"), and no price confirmation is outstanding. That acceptance is good for 15 minutes (the offer's confirmed_until). THE CHECKOUT CONFIRMS WHAT NEEDS CONFIRMING ITSELF: when the option's shop has not confirmed it, or did more than 15 minutes ago, the checkout asks that ONE shop (it joins the ask already running when choosing the option started one) and waits up to wait_s for the answer; when the wait runs out first the answer is offer_not_ready with retry_after_s — send the SAME call again, it joins the ask and nothing is asked twice. THE PAY RULE: when the confirmed total is at or below the amount the user agreed to, checkout uses the selected payment method (hosted payment by default, or the saved card when pay is saved on a keyed connection); a price the shop confirmed HIGHER than the user agreed to stops ONCE (price_went_up, with old_total_cents and new_total_cents) and nothing is created — tell the user both figures, then send the call again (with the new max_total_cents when you sent one); the new price stands for 15 minutes and no shop is asked again. A passed offer whose price_refresh is still "pending" is refused the same way (offer_not_ready, with retry_after_s): the shop is still confirming its price — re-read the quote and retry then. An offer whose check failed, whose price_refresh reads "failed", or whose fulfillment is "not_connected" cannot be ordered at all (offer_check_failed) — offer the user another option or re-quote. Nothing is charged on any refusal. An offer whose shop could not confirm the part — it declined the part, or did not answer within two minutes of being asked — leaves the quote: it is no longer listed in offers, and its id is refused the same way. If an offer you showed earlier is missing when you re-read the quote, tell the user plainly that the shop could not confirm the part, and carry on with the offers that are listed. ORDER BY THE PICK: instead of offer_id + shipping_option_id, pass quote_id with selection true to order the one option the quote's stored pick comes to (the quote's selection_match). It orders only when that reads status "one"; with none or several it is refused (selection_not_unique, saying how many matched) and nothing is created — say more in the pick with refine_quote selection, then call again. When the pick names a shipping speed the option does not show right now (selection_match.speed_fallback) it is refused too (selection_speed_unavailable): the cheapest speed is never ordered in its place — store the pick with a speed the option lists. An offer_id or shipping speed the quote's own rules keep off its board (the acceptable-materials list, within_days) is refused the same way: order what the quote lists now. So the whole of it is two calls: refine_quote with the pick (its one shop starts confirming), then create_checkout with quote_id and selection true — the selected checkout result, price_went_up once, or offer_not_ready (call again). The checkout rule above applies to the picked option exactly as to any other. TO PLACE EXACTLY ONE ORDER WITH NO MISTAKES: (1) on get_fabrication_quote list only that shop in vendors and state the pick in selection — the shop, plus the material, finish and shipping speed wanted; (2) read selection_match on the quote: status "one" means exactly one option answers the pick, "many" means say more in the pick (color, thickness, quantity), "none" means nothing on the quote answers it; (3) call create_checkout with quote_id and selection true — it orders that one option at the picked shipping speed, or refuses and creates nothing (selection_not_unique: the pick is not exactly one option; selection_speed_unavailable: the option does not show the picked speed now — an order never takes another speed in its place). It returns the selected checkout result: a hosted payment link by default, or the saved-card outcome when pay is saved on a keyed connection.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "create_checkout"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| check | No | Default true: when the option has not had its shop's manufacturability check yet ("unchecked"), or its shop confirmed it more than 15 minutes ago, this call asks that one shop and waits for its answer (wait_s), then goes on or refuses as the checkout rule says. false = ask nobody: such an option is refused at once (offer_not_ready). Usually OMIT | |
| wait_s | No | Seconds this call may wait for the shop (default 45). When it runs out first the answer is offer_not_ready — send the same call again | |
| offer_id | No | The offer to order. Required unless selection is true | |
| quote_id | No | With selection true: the quote whose picked option to order | |
| selection | No | true = order the quote's stored pick (its selection) instead of naming an offer: pass quote_id and leave offer_id and shipping_option_id out. Orders only when the quote's selection_match reads "one"; otherwise it is refused (selection_not_unique) and nothing is created; refused as well (selection_speed_unavailable) when the pick names a shipping speed that option does not show now | |
| return_url | No | Exact URL of the page the user is on right now, IF the client application knows it (a web app embedding this tool passes its own page URL). The post-payment page shows a 'Return to <site>' button pointing here. Omit when unknown — never invent one. | |
| coupon_code | No | Coupon code, only if the user provided one (early-adopter codes from the AFN team). Case-insensitive. The discount appears on the payment page; a 100%-off code makes the total $0 with no card required. Never invent or guess a code. | |
| max_total_cents | No | The most the user agreed to pay for this option at this shipping speed, in cents, before any coupon: the subtotal_cents plus the speed's cost_cents you showed them. At or under it the order is made; a higher confirmed price is refused once (price_went_up) and nothing is created. Leave it out and the network compares with the price it last told this quote's reader | |
| shipping_option_id | No | One of the offer's shipping option ids. Required with offer_id; leave out with selection true |